MiniMax H3: malloc graph keeps its VRAM between sampling steps, so step 2 OOMs on model_output.float() with ~28 MB free
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- backend, machine-learning
Research direction
Start with comfy/ldm/minimax/model.py and trace how malloc_graph_begin() and output copying interact with cleanup_malloc_graph() in comfy/model_prefetch.py. Reproduce the reported step 2 OOM with the linked long-sequence workflow, then check whether releasing the graph after each forward is safe and whether it affects shorter runs or cards with more VRAM. Done when repeated sampling steps complete without the OOM and the graph's intended reuse behavior is addressed.
Written by the indexing model from the issue text.
Description
MiniMaxH3Model.forward (comfy/ldm/minimax/model.py) calls comfy.model_prefetch.malloc_graph_begin() around the blocks, but cleanup_malloc_graph() only runs from cleanup_prefetch_queues() when sampling ends. From step 2 on, the graph's arena keeps its physical pages after the forward returns, so the next ordinary allocation outside the graph fails. On a 12 GB card it is the 40 MB model_output.float():
File "comfy/model_base.py", line 263, in _apply_model
return self.model_sampling.calculate_denoised(sigma, model_output.float(), x)
torch.OutOfMemoryError: Allocation on device 0 would exceed allowed memory. (out of memory)
At that point torch.cuda.mem_get_info() reported about 28 MB free while PyTorch held under 700 MB allocated. --vram-headroom 1.5 did not change it. An aimdo DETAIL trace showed vbar_mb=0, so the memory was not model weights.
Environment: ComfyUI v0.45.0 (code also checked unchanged on master b2f6707443), comfy-aimdo 0.6.0, comfy-kitchen 0.2.41, PyTorch 2.15.0+cu132, RTX 3060 12 GB, Linux, Dynamic VRAM on (default). Workflow: the official video_fastvideo_fasth3_t2v / i2v / video_fasth3_ominiref_r2v templates with length 362 (15 s) at 1344x768, about 109k video tokens. Reproduced three times at the end of step 2's forward with the T2V template (after working around the RoPE cache issue, #17700).
Fix direction. The forward's outputs are copied into tensors allocated outside the graph (out[0].copy_(graph_out[0])), so releasing the graph after each forward is safe; the next step records a new one, as step 1 does. Locally this wrapper fixed it, and step time went from about 130 s to 117 s:
def forward(self, x, *args, **kwargs):
out = original_forward(self, x, *args, **kwargs)
if long_sequence(x) and comfy.model_prefetch.malloc_graph_recording():
comfy.model_prefetch.cleanup_malloc_graph()
return out
I gated it on 50k+ video tokens to leave short runs alone. A maintainer should decide whether keeping the graph across steps is meant to save re-recording time, and if so, whether the arena can return its pages between forwards instead. Not verified: behaviour on cards with more VRAM, where the graph may fit and reuse may be faster.
Filed by Claude Opus 5.5 in Claude Code.
- Dominant language
- Python
- Stars
- 146k
- Forks
- 17.4k
- Avg merge
- 19h 44m
- Merged PRs (30d)
- 178
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Comfy-Org/ComfyUI
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
ROCm gfx1100: contiguous-k/v SDPA workaround is gfx1151-only, MiniMax H3 sampling 2.2x slower on RX 7900 XTXPossibly taken @TwelveNights claimed this 3 days ago. OpenPotential Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Sub-quadratic attention is ~10x slower on long sequences on RDNA2 (gfx1030) because the key passed to bmm is non-contiguousPossibly taken @KornienkoDev claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
MoGe-3 output is nondeterministic on CUDA: sparse_pool3d_mean sums with float index_add_ (atomics)Possibly taken @potoior claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Comfy-Org/ComfyUI#17498 · 1 comment ·
Maintainers usually reply within 1 day
-
TRELLIS.2 texture bake fails under --bf16-vae: BakeTextureFromVoxel 'Got unsupported ScalarType BFloat16'Possibly taken @Shubham-Padkonde claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
All issues in Comfy-Org/ComfyUI
Similar issues
-
add entry to blockOpen
Difficulty 1/5 Under an hour Newbie friendliness 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Possibly taken @0z5a claimed this today. Openneeds-triage
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
plot_graph crashes when a mesh node has no m2m edgePossibly taken @tygvi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mllam/neural-lam#883 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
future-agi/future-agi#4092 · 1 comment ·
Maintainers usually reply within 1 day
-
transcript analytics: a text whose only protected spans the prose pass redacts is withheld wholeOpen
Difficulty 1/5 Under an hour Newbie friendliness 82/100
WingedGuardian/GENesis-AGI#4641 ·
Maintainers usually reply within 1 day