[GH-ISSUE #13] comfy-aimdo is not compatible with Torch compile (it only seems to bug with cuda130). #1

Open
opened 2026-10-26 22:23:23 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @dill-shower on GitHub (Mar 4, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-aimdo/issues/13

Causes multiple recompilations when compiling the model.

AUTOTUNE addmm(330x4608, 330x1536, 1536x4608)
strides: [0, 1], [s16, 1], [1, s16]
dtypes: torch.float16, torch.float16, torch.float16
addmm 0.1874 ms 100.0%
bias_addmm 0.2560 ms 73.2%
SingleProcess AUTOTUNE benchmarking takes 0.0793 seconds and 0.0001 seconds precompiling for 2 choices
W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] torch._dynamo hit config.recompile_limit (64)
W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] function: 'torch_dynamo_resume_in_get_tensor_from_raw_ptr_at_16' (/home/user/miniforge3/envs/comfy/lib/python3.11/site-packages/comfy_aimdo/torch.py:16)
W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] last reason: 10/63: ___check_obj_id(___stack0, 139610556710336), type=<class 'comfy_aimdo.torch.get_tensor_from_raw_ptr..Holder'> # holder = Holder() # comfy_aimdo/torch.py:19 in torch_dynamo_resume_in_get_tensor_from_raw_ptr_at_16
W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] To log all recompilation reasons, use TORCH_LOGS="recompiles".
W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] To diagnose recompilation issues, see https://pytorch.org/docs/main/compile/programming_model.recompilation.html
W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] torch._dynamo hit config.recompile_limit (64)
W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] function: 'cast_bias_weight_with_vbar' (/home/user/ComfyUI/comfy/ops.py:82)
W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] last reason: 7/63: s._v[1] == 66657769472 # signature = comfy_aimdo.model_vbar.vbar_fault(s._v) # ComfyUI/comfy/ops.py:86 in cast_bias_weight_with_vbar (HINT: torch.compile considers integer attributes of the nn.Module to be static. If you are observing recompilation, you might want to make this integer dynamic using torch._dynamo.config.allow_unspec_int_on_nn_module = True, or convert this integer into a tensor.)
W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] To log all recompilation reasons, use TORCH_LOGS="recompiles".
W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] To diagnose recompilation issues, see https://pytorch.org/docs/main/compile/programming_model.recompilation.html
W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] torch._dynamo hit config.recompile_limit (64)
W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] function: 'uncast_bias_weight' (/home/user/ComfyUI/comfy/ops.py:267)
W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] last reason: 13/63: offload_stream[0] is None # comfy_aimdo.model_vbar.vbar_unpin(s._v) # ComfyUI/comfy/ops.py:274 in uncast_bias_weight
W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] To log all recompilation reasons, use TORCH_LOGS="recompiles".
W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] To diagnose recompilation issues, see https://pytorch.org/docs/main/compile/programming_model.recompilation.html
[adaptive_pid] ae_dopri5: 90.6301%|██████▎| 24 [05:44<00:13, 1.47s/%, σ=0.0937]Autotune Choices Stats:

Originally created by @dill-shower on GitHub (Mar 4, 2026). Original GitHub issue: https://github.com/Comfy-Org/comfy-aimdo/issues/13 Causes multiple recompilations when compiling the model. AUTOTUNE addmm(330x4608, 330x1536, 1536x4608) strides: [0, 1], [s16, 1], [1, s16] dtypes: torch.float16, torch.float16, torch.float16 addmm 0.1874 ms 100.0% bias_addmm 0.2560 ms 73.2% SingleProcess AUTOTUNE benchmarking takes 0.0793 seconds and 0.0001 seconds precompiling for 2 choices W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] torch._dynamo hit config.recompile_limit (64) W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] function: 'torch_dynamo_resume_in_get_tensor_from_raw_ptr_at_16' (/home/user/miniforge3/envs/comfy/lib/python3.11/site-packages/comfy_aimdo/torch.py:16) W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] last reason: 10/63: ___check_obj_id(___stack0, 139610556710336), type=<class 'comfy_aimdo.torch.get_tensor_from_raw_ptr.<locals>.Holder'> # holder = Holder() # comfy_aimdo/torch.py:19 in torch_dynamo_resume_in_get_tensor_from_raw_ptr_at_16 W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] To log all recompilation reasons, use TORCH_LOGS="recompiles". W0304 22:24:11.700000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [10/64] To diagnose recompilation issues, see https://pytorch.org/docs/main/compile/programming_model.recompilation.html W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] torch._dynamo hit config.recompile_limit (64) W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] function: 'cast_bias_weight_with_vbar' (/home/user/ComfyUI/comfy/ops.py:82) W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] last reason: 7/63: s._v[1] == 66657769472 # signature = comfy_aimdo.model_vbar.vbar_fault(s._v) # ComfyUI/comfy/ops.py:86 in cast_bias_weight_with_vbar (HINT: torch.compile considers integer attributes of the nn.Module to be static. If you are observing recompilation, you might want to make this integer dynamic using torch._dynamo.config.allow_unspec_int_on_nn_module = True, or convert this integer into a tensor.) W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] To log all recompilation reasons, use TORCH_LOGS="recompiles". W0304 22:24:14.611000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [7/64] To diagnose recompilation issues, see https://pytorch.org/docs/main/compile/programming_model.recompilation.html W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] torch._dynamo hit config.recompile_limit (64) W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] function: 'uncast_bias_weight' (/home/user/ComfyUI/comfy/ops.py:267) W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] last reason: 13/63: offload_stream[0] is None # comfy_aimdo.model_vbar.vbar_unpin(s._v) # ComfyUI/comfy/ops.py:274 in uncast_bias_weight W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] To log all recompilation reasons, use TORCH_LOGS="recompiles". W0304 22:24:14.958000 6869 site-packages/torch/_dynamo/convert_frame.py:1676] [13/64] To diagnose recompilation issues, see https://pytorch.org/docs/main/compile/programming_model.recompilation.html [adaptive_pid] ae_dopri5: 90.6301%|██████▎| 24 [05:44<00:13, 1.47s/%, σ=0.0937]Autotune Choices Stats:
Author
Owner

@rattus128 commented on GitHub (Mar 4, 2026):

Yes torch compiler+Aimdo is a TBD. What we do is we demote the ModelPatcherDynamic down to ModelPatcher in the torch compiler nodes.

https://github.com/Comfy-Org/ComfyUI/blob/master/comfy_extras/nodes_torch_compile.py#L28

Do you have a custom node pack providing your torch compiler node? I know KJNodes added the switch to disable dynamic to get it to work as before.

<!-- gh-comment-id:4000936048 --> @rattus128 commented on GitHub (Mar 4, 2026): Yes torch compiler+Aimdo is a TBD. What we do is we demote the ModelPatcherDynamic down to ModelPatcher in the torch compiler nodes. https://github.com/Comfy-Org/ComfyUI/blob/master/comfy_extras/nodes_torch_compile.py#L28 Do you have a custom node pack providing your torch compiler node? I know KJNodes added the switch to disable dynamic to get it to work as before.
Author
Owner

@dill-shower commented on GitHub (Mar 5, 2026):

I use res4lyf extension (torchCompileModelSd35 node).
But... Compile work fine with pytorch cu126. Recompilation looks like only with 130

I will test with compile by comfyui node

<!-- gh-comment-id:4001362895 --> @dill-shower commented on GitHub (Mar 5, 2026): I use res4lyf extension (torchCompileModelSd35 node). But... Compile work fine with pytorch cu126. Recompilation looks like only with 130 I will test with compile by comfyui node
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-aimdo#1
No description provided.