ComfyUI/comfy/ldm/modules/diffusionmodules
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
..
__init__.py Initial commit. 2023-01-16 22:37:14 -05:00
mmdit.py Z Image model. (#10892) 2025-11-25 18:41:45 -05:00
model.py fix(directml): replace try/except with device-type guard; fix both ZeroDivisionError sites 2026-05-14 21:09:35 -04:00
openaimodel.py feat: SUPIR model support (CORE-17) (#13250) 2026-04-18 23:02:01 -04:00
upscaling.py Lint unused import (#5973) 2024-12-09 15:24:39 -05:00
util.py Fix typos (#10986) 2026-05-08 17:14:45 +08:00