[staging CI] unslothai/unsloth#14510 by danielhanchen · Pull Request #511 · Imagineer99/unsloth · GitHub
Skip to content

[staging CI] unslothai/unsloth#14510 - #511

Closed
danielhanchen wants to merge 10 commits into
upstream-mainfrom
pr-14510-xplat-ci
Closed

danielhanchen wants to merge 10 commits into
upstream-mainfrom
pr-14510-xplat-ci

Conversation

@danielhanchen

Copy link
Copy Markdown
Collaborator

Disposable CI run for unslothai#14510. Do not merge; closed after CI.

danielhanchen and others added 10 commits October 21, 2026 05:24
An fp8 or fp8_scaled ComfyUI Krea 2 file (13 GB) on a GPU with no fp8 runtime
is widened to bf16 in host RAM (about 26 GB) before the denoiser is placed.
With too little free memory the process was killed (Linux OOM killer, Windows
commit limit), taking the whole app down instead of failing the load.

Price the new host memory from the safetensors header (tensors already at the
compute dtype stay memory-mapped and cost nothing) and refuse with a readable
message before any widening, in both the original-layout loader and the
ComfyUI-quantized loader. UNSLOTH_DIFFUSION_HOST_RAM_CHECK=0 skips the check.
With an fp16 pipeline and _keep_in_fp32_modules the ComfyUI loader only
postpones the dtype choice; with no fp8 runtime (never available off bf16)
every quantized layer is still expanded. Price those layers as widened, and
block formats under a key map, which are always dequantized.
An nvfp4 header describes packed uint8 with K / 2 columns, while the
dequantization allocates the dense N x K weight, so the check counted half
of it. nvfp4 is the only packed ComfyUI format the loader reads; int8, fp8
and mxfp8 store one code per element.
The header estimate could not see per-layer choices the loader makes later,
so it kept drifting from what was really written: layers a runtime filter
rejects are still dequantized, a kept nvfp4 weight gets a nibble-swapped copy
plus untiled scales, and FNUZ float8 tensors were skipped entirely.

A HostRamBudget now holds free RAM minus the small-host reserve for the
whole load. The header estimate still refuses up front (it now prices FNUZ
float8 too), and every allocating helper (dequant, dequant_block, the
nibble swap, scale untiling, dtype casts, segment joins) charges the budget
before it allocates, so the load is refused before the allocation that would
not fit instead of running the host out of memory.
With UNSLOTH_DIFFUSION_HOST_RAM_CHECK=0 (or host RAM unreadable) the budget
could never refuse, but it was still installed and charged by every helper.
Leave it inactive so the kill switch costs nothing.

[skip ci]
@danielhanchen
danielhanchen deleted the pr-14510-xplat-ci branch October 21, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant