ComfyUI-MultiGPU icon indicating copy to clipboard operation
ComfyUI-MultiGPU copied to clipboard

Distorch2 nodes are not offloading onto donor device

Open an80sPWNstar opened this issue 7 months ago • 2 comments

Is there a roadmap or estimated date of when the multigpu nodes will be updated to support the new dynamic vram that comfyui implemented? I have no idea what it would take to do this but curiosity is killing me due to how much I love these nodes :)

an80sPWNstar avatar Apr 16 '26 16:04 an80sPWNstar

I hit exactly this symptom on a dual-GPU Windows box and root-caused it. Posting the full analysis here since this issue already tracks it (also related: #186, where the --disable-dynamic-vram workaround was found). Short version: with ComfyUI's DynamicVRAM enabled (the default), every DisTorch2 safetensor load — ratio and expert mode — is a silent no-op. The [MultiGPU DisTorch V2] Full allocation string: banner still prints, but no allocation ever runs and the donor GPU never receives a byte. GGUF DisTorch2 is unaffected.

Environment

  • Windows 11, ComfyUI 0.32.0 (commit bd34f338), ComfyUI-MultiGPU 2.6.4 (b51c99a)
  • PyTorch 2.11.0+cu128
  • cuda:0 = RTX 5070 Ti 16 GB (compute), cuda:1 = RTX 5060 Ti 16 GB (donor)
  • comfy-aimdo healthy on both devices (startup log: DynamicVRAM support detected and enabled)

Reproduction (controlled, 5 arms)

Same graphs/seeds throughout: Qwen-Image bf16 checkpoint (~39 GB) with UNETLoaderDisTorch2MultiGPU expert mode cuda:0,11gb;cuda:1,13gb;cpu,*, 12 steps; FLUX.1-Krea bf16 (~24.5 GB) with ratio mode virtual_vram_gb=12, 8 steps; both 2048×1024. Per-card VRAM sampled via nvidia-smi with cards mapped by GPU UUID (not index).

arm launch flags DisTorch2 load donor (cuda:1) VRAM delta log signature wall
A stock (DynamicVRAM on) expert, first load of a fresh process +0 MiB (flat ~1150 MiB, 57 samples) banner only, then Model QwenImage prepared for dynamic VRAM loading. 38967MB Staged 120.3 s
B1 stock ratio (Krea) +0 MiB banner only 60.1 s
B2 stock expert again, same process +0 MiB banner only 120.2 s
C --disable-dynamic-vram expert, first load of a fresh process +13,324 MiB (peak 14,474) full allocation tables: Assigning 11264.00MB … cuda:0 / 13312.00MB … cuda:1 / 14391.90MB … cpu, DisTorch loading completed. Total memory: 38967.90MB 198.2 s
C2 --disable-dynamic-vram ratio (Krea) +12,224 MiB (peak 13,386) Virtual VRAM Analysis table 84.7 s

Expected: the requested placement (or a hard failure if it can't be honored). Actual (stock flags): banner prints, allocation analysis never runs, model loads via aimdo host-RAM streaming, donor card stays at desktop baseline. No warning anywhere.

Code path

  1. When comfy-aimdo is healthy and dynamic VRAM is enabled (default, comfy/cli_args.py:311-314), ComfyUI main.py:278 sets comfy.model_patcher.CoreModelPatcher = comfy.model_patcher.ModelPatcherDynamic, and UNET loads instantiate CoreModelPatcher (comfy/sd.py:2150, comfy/sd.py:2291).
  2. MultiGPU installs DisTorch2 as a base-class monkey-patch — distorch_2.py:330: comfy.model_patcher.ModelPatcher.partially_load = new_partially_load (the actual allocation runs inside it via analyze_safetensor_loading, distorch_2.py:253).
  3. ModelPatcherDynamic (defined at comfy/model_patcher.py:1749) has its own partially_load at comfy/model_patcher.py:2113. A method defined on the subclass shadows an attribute assigned on the base class, so new_partially_load never executes for any dynamic patcher instance.
  4. MultiGPU's only DynamicVRAM awareness is the aimdo device-context guard (__init__.py:400-424), which falls back to the legacy ModelPatcher only when comfy-aimdo has no context for the target device — never because DisTorch2 placement was requested. So on a box where aimdo initialized every device (the common case), the guard never fires and DisTorch2 safetensor loads always take the shadowed path. This also means the README's compatibility note ("preserves MultiGPU placement … even when comfy-aimdo only initialized the primary device") covers the uninitialized-device case but not this one.
  5. Banner masking: the node override prints [MultiGPU DisTorch V2] Full allocation string: … from the wrapper (wrappers.py:122) at node-execution time, before any load happens — so the log looks like DisTorch2 is active even when allocation never runs. That's what makes this failure so easy to miss (it cost me a while, and I suspect it's why reports of this are vague).
  6. Why GGUF still works: ComfyUI-GGUF/nodes.py:35 defines GGUFModelPatcher(comfy.model_patcher.ModelPatcher) — it subclasses the base class and does not override partially_load, so GGUF DisTorch2 loads inherit the patch and pool correctly under stock flags.

Workaround and why it won't last

--disable-dynamic-vram fully restores DisTorch2 (arms C/C2 — expert honored the exact byte string: 11264/13312/14391.9 MB split). But ComfyUI's own startup warning (main.py:576) says this argument "will be removed soon", so the flag is a wasting asset. A durable fix probably has to live in this node — e.g. also hooking/patching ModelPatcherDynamic.partially_load, or forcing the legacy patcher for DisTorch-annotated loads (the guard in __init__.py already demonstrates the mechanism), or at minimum detecting the dynamic patcher and logging loudly that DisTorch2 placement is being skipped instead of printing the allocation banner. I don't have a strong opinion on which; happy to test a branch on this dual-GPU box.

One honest data point for prioritization: in these runs aimdo's host-RAM streaming was actually faster on wall time than DisTorch2 pooling (120 vs 198 s on the 39 GB model). The bug isn't that dynamic mode performs badly — it's that the node silently does nothing while claiming otherwise, and users who need cross-GPU placement (or want the donor's VRAM in play) currently can't get it on default flags.

dmmdea avatar Aug 14 '26 06:08 dmmdea

I noticed the same thing for me. What sucked was enabling dynamic vram with no multigpu is actually FASTER than disabling dynamic vram and using multigpu. I hope this gets updated soon.

On Fri, Aug 14, 2026, 12:14 AM Daniel Martinez Morales < @.***> wrote:

dmmdea left a comment (pollockjj/ComfyUI-MultiGPU#191) https://github.com/pollockjj/ComfyUI-MultiGPU/issues/191#issuecomment-5290128673

I hit exactly this symptom on a dual-GPU Windows box and root-caused it. Posting the full analysis here since this issue already tracks it (also related: #186 https://github.com/pollockjj/ComfyUI-MultiGPU/issues/186, where the --disable-dynamic-vram workaround was found). Short version: with ComfyUI's DynamicVRAM enabled (the default), every DisTorch2 safetensor load — ratio and expert mode — is a silent no-op. The [MultiGPU DisTorch V2] Full allocation string: banner still prints, but no allocation ever runs and the donor GPU never receives a byte. GGUF DisTorch2 is unaffected. Environment

  • Windows 11, ComfyUI 0.32.0 (commit bd34f338), ComfyUI-MultiGPU 2.6.4 (b51c99a)
  • PyTorch 2.11.0+cu128
  • cuda:0 = RTX 5070 Ti 16 GB (compute), cuda:1 = RTX 5060 Ti 16 GB (donor)
  • comfy-aimdo healthy on both devices (startup log: DynamicVRAM support detected and enabled)

Reproduction (controlled, 5 arms)

Same graphs/seeds throughout: Qwen-Image bf16 checkpoint (~39 GB) with UNETLoaderDisTorch2MultiGPU expert mode cuda:0,11gb;cuda:1,13gb;cpu,*, 12 steps; FLUX.1-Krea bf16 (~24.5 GB) with ratio mode virtual_vram_gb=12, 8 steps; both 2048×1024. Per-card VRAM sampled via nvidia-smi with cards mapped by GPU UUID (not index). arm launch flags DisTorch2 load donor (cuda:1) VRAM delta log signature wall A stock (DynamicVRAM on) expert, first load of a fresh process +0 MiB (flat ~1150 MiB, 57 samples) banner only, then Model QwenImage prepared for dynamic VRAM loading. 38967MB Staged 120.3 s B1 stock ratio (Krea) +0 MiB banner only 60.1 s B2 stock expert again, same process +0 MiB banner only 120.2 s C --disable-dynamic-vram expert, first load of a fresh process +13,324 MiB (peak 14,474) full allocation tables: Assigning 11264.00MB … cuda:0 / 13312.00MB … cuda:1 / 14391.90MB … cpu, DisTorch loading completed. Total memory: 38967.90MB 198.2 s C2 --disable-dynamic-vram ratio (Krea) +12,224 MiB (peak 13,386) Virtual VRAM Analysis table 84.7 s

Expected: the requested placement (or a hard failure if it can't be honored). Actual (stock flags): banner prints, allocation analysis never runs, model loads via aimdo host-RAM streaming, donor card stays at desktop baseline. No warning anywhere. Code path

  1. When comfy-aimdo is healthy and dynamic VRAM is enabled (default, comfy/cli_args.py:311-314), ComfyUI main.py:278 sets comfy.model_patcher.CoreModelPatcher = comfy.model_patcher.ModelPatcherDynamic, and UNET loads instantiate CoreModelPatcher (comfy/sd.py:2150, comfy/sd.py:2291).
  2. MultiGPU installs DisTorch2 as a base-class monkey-patch — distorch_2.py:330: comfy.model_patcher.ModelPatcher.partially_load = new_partially_load (the actual allocation runs inside it via analyze_safetensor_loading, distorch_2.py:253).
  3. ModelPatcherDynamic (defined at comfy/model_patcher.py:1749) has its own partially_load at comfy/model_patcher.py:2113. A method defined on the subclass shadows an attribute assigned on the base class, so new_partially_load never executes for any dynamic patcher instance.
  4. MultiGPU's only DynamicVRAM awareness is the aimdo device-context guard (init.py:400-424), which falls back to the legacy ModelPatcher only when comfy-aimdo has no context for the target device — never because DisTorch2 placement was requested. So on a box where aimdo initialized every device (the common case), the guard never fires and DisTorch2 safetensor loads always take the shadowed path. This also means the README's compatibility note ("preserves MultiGPU placement … even when comfy-aimdo only initialized the primary device") covers the uninitialized-device case but not this one.
  5. Banner masking: the node override prints [MultiGPU DisTorch V2] Full allocation string: … from the wrapper (wrappers.py:122) at node-execution time, before any load happens — so the log looks like DisTorch2 is active even when allocation never runs. That's what makes this failure so easy to miss (it cost me a while, and I suspect it's why reports of this are vague).
  6. Why GGUF still works: ComfyUI-GGUF/nodes.py:35 defines GGUFModelPatcher(comfy.model_patcher.ModelPatcher) — it subclasses the base class and does not override partially_load, so GGUF DisTorch2 loads inherit the patch and pool correctly under stock flags.

Workaround and why it won't last

--disable-dynamic-vram fully restores DisTorch2 (arms C/C2 — expert honored the exact byte string: 11264/13312/14391.9 MB split). But ComfyUI's own startup warning (main.py:576) says this argument "will be removed soon", so the flag is a wasting asset. A durable fix probably has to live in this node — e.g. also hooking/patching ModelPatcherDynamic.partially_load, or forcing the legacy patcher for DisTorch-annotated loads (the guard in init.py already demonstrates the mechanism), or at minimum detecting the dynamic patcher and logging loudly that DisTorch2 placement is being skipped instead of printing the allocation banner. I don't have a strong opinion on which; happy to test a branch on this dual-GPU box.

One honest data point for prioritization: in these runs aimdo's host-RAM streaming was actually faster on wall time than DisTorch2 pooling (120 vs 198 s on the 39 GB model). The bug isn't that dynamic mode performs badly — it's that the node silently does nothing while claiming otherwise, and users who need cross-GPU placement (or want the donor's VRAM in play) currently can't get it on default flags.

— Reply to this email directly, view it on GitHub https://github.com/pollockjj/ComfyUI-MultiGPU/issues/191?email_source=notifications&email_token=AJ66VP75NYPIPFHOT4F6LID5J2U27A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMRZGAYTEOBWG4Z2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-5290128673, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ66VP5ELLENH22NXUIXBVD5J2U27AVCNFSNUABFKJSXA33TNF2G64TZHM4TANJUG4YTINBSHNEXG43VMU5TIMRXG4YDIMRSGAZ2C5QC . You are receiving this because you authored the thread.Message ID: @.***>

an80sPWNstar avatar Aug 15 '26 02:08 an80sPWNstar