ComfyUI/comfy/ldm/modules
Emiliooooo 61235fc35a fix(directml): replace try/except with device-type guard; fix both ZeroDivisionError sites
Improves on the previous directml commit with three research-based refinements:

1. model_management.py — module_mmap_residency() and cast_to_gathered()
   Replace broad try/except NotImplementedError with an explicit
   `t.device.type == 'privateuseone'` guard. Checking device type is
   faster in a hot loop and makes the intent self-documenting.
   Fixes: github.com/Comfy-Org/ComfyUI/issues/8347

2. attention.py — attention_split()
   Replace the "assume 4 GB free" heuristic with `steps = 64`.
   64-slice chunking is safe and correct regardless of card size;
   the 4 GB assumption was fragile on cards with less or more VRAM.

3. diffusionmodules/model.py — slice_attention()
   Apply the identical `steps = 64` guard to the second call site
   for the same ZeroDivisionError (was missed in the previous commit).
   Fixes: github.com/comfyanonymous/ComfyUI/issues/1518

Tested end-to-end on AMD RX 5600 XT (6 GB VRAM), Windows 11,
torch-directml 0.2.5, ComfyUI 0.21.1, DreamShaper 8 (SD 1.5).
Full 20-step txt2img pipeline completes and returns a valid PNG.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-05-14 21:09:35 -04:00
..
diffusionmodules fix(directml): replace try/except with device-type guard; fix both ZeroDivisionError sites 2026-05-14 21:09:35 -04:00
distributions Small optimizations. 2024-12-18 18:23:28 -05:00
encoders Remove dead code. (#13251) 2026-04-01 20:22:06 -04:00
attention.py fix(directml): replace try/except with device-type guard; fix both ZeroDivisionError sites 2026-05-14 21:09:35 -04:00
ema.py New Year ruff cleanup. (#11595) 2026-01-01 22:06:14 -05:00
sdpose.py SDPose: resize input always (#13349) 2026-04-10 11:26:55 -10:00
sub_quadratic_attention.py Widen OOM_EXCEPTION to AcceleratorError form (#12835) 2026-03-10 00:41:02 -04:00
temporal_ae.py Basic Hunyuan Video model support. 2024-12-16 19:35:40 -05:00