Using the TorchCompile nodes with WAN model causes log warnings and increases generation time.
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
The TorchCompile node should not cause errors/warnings or increase generation time.
### Actual Behavior
**Using the TorchCompile node causes errors (log warnings) and increases generation time:**
aimdo: /project/src/model-vbar.c:74:WARNING:VBAR 0x7f8410d28ce0: Page 356 pin_count=1
aimdo: /project/src/model-vbar.c:69:WARNING:VBAR 0x7f8410d28ce0: Resident page 357 is ABOVE watermark 0
aimdo: /project/src/model-vbar.c:74:WARNING:VBAR 0x7f8410d28ce0: Page 357 pin_count=1
**If I run ComfyUI with the "--reserve-vram 8" parameter, the warning in the logs will change to the following:**
W0618 14:26:16.647000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [11/8] function: 'forward' (/root/1data/apps/local/ComfyUI/comfy/ldm/wan/model.py:59)
W0618 14:26:16.647000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [11/8] last reason: 11/7: self._modules['k'].weight_function[0].key == 'diffusion_model.blocks.6.self_attn.k.weight' # patches = self.prepared_patches if self.prepared_patches is not None else self.patches[self.key] # comfy/model_patcher.py:153 in __call__
W0618 14:26:16.647000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [11/8] To log all recompilation reasons, use TORCH_LOGS="recompiles".
W0618 14:26:16.647000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [11/8] To diagnose recompilation issues, see https://pytorch.org/docs/main/torch.compiler_troubleshooting.html
W0618 14:26:16.975000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [18/8] torch._dynamo hit config.recompile_limit (8)
W0618 14:26:16.975000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [18/8] function: 'forward' (/root/1data/apps/local/ComfyUI/comfy/ldm/wan/model.py:101)
W0618 14:26:16.975000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [18/8] last reason: 18/7: self._modules['k'].weight_function[0].key == 'diffusion_model.blocks.6.cross_attn.k.weight' # patches = self.prepared_patches if self.prepared_patches is not None else self.patches[self.key] # comfy/model_patcher.py:153 in __call__
W0618 14:26:16.975000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [18/8] To log all recompilation reasons, use TORCH_LOGS="recompiles".
W0618 14:26:16.975000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [18/8] To diagnose recompilation issues, see https://pytorch.org/docs/main/torch.compiler_troubleshooting.html
W0618 14:26:17.010000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [20/8] torch._dynamo hit config.recompile_limit (8)
W0618 14:26:17.010000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [20/8] function: 'torch_dynamo_resume_in_forward_at_252' (/root/1data/apps/local/ComfyUI/comfy/ldm/wan/model.py:252)
W0618 14:26:17.010000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [20/8] last reason: 20/7: self._modules['ffn']._modules['0'].weight_function[0].key == 'diffusion_model.blocks.6.ffn.0.weight' # patches = self.prepared_patches if self.prepared_patches is not None else self.patches[self.key] # comfy/model_patcher.py:153 in __call__
W0618 14:26:17.010000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [20/8] To log all recompilation reasons, use TORCH_LOGS="recompiles".
W0618 14:26:17.010000 112591 venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py:1358] [20/8] To diagnose recompilation issues, see https://pytorch.org/docs/main/torch.compiler_troubleshooting.html
### Steps to Reproduce
Insert the TorchCompile node between the "Diffusion Model Loader KJ" node and the native KSampler node and run generation on my PC.
### Debug Logs
```powershell
Logs, when start without --reserve-vram 8
[INFO] loaded partially; 4835.79 MB usable, 4050.79 MB loaded, 29019.61 MB offloaded, 840.08 MB buffer reserved, lowvram patches: 370
0%| | 0/6 [00:00
Contributor guide
Research direction
Reproduce the workflow by inserting TorchCompile between the Diffusion Model Loader KJ and native KSampler, with and without --reserve-vram 8. Start by reading comfy/ldm/wan/model.py at the logged lines and comfy/model_patcher.py:153; done means WAN generation no longer produces the reported warnings or repeated TorchDynamo recompilation messages and does not incur the reported slowdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- ai, machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100