Repository navigation
fix(gguf): avoid device over-reservation for host decoding - #9862
Open
wunianze666-netizen wants to merge 1 commit into
Open
wunianze666-netizen wants to merge 1 commit into
wunianze666-netizen wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Correct GGUF Linear device working-memory reservations for types decoded through the NumPy host fallback. IQ4_NL/IQ4_XS currently receive the worst-case device-kernel intermediate allowance (8 bytes per element), although that route decodes on the host and transfers only its cast result.
Use the decoder's existing dispatch registries to distinguish host fallback from torch-compatible/device-kernel types. Preserve the packed input, compute-dtype result and maximum-single-layer accounting. Existing kernel table entries are unchanged; newly registered device kernels without a measured entry still receive the conservative 8-byte allowance.
This removes an incorrect reservation, not measured allocated VRAM or a demonstrated speed gain. No decoder, numerical output, kernel, dtype, API or stored format changes.
Related Issues / Discussions
Closes #9718
QA Instructions
On main
358257bca6acb9268c89d61c052c729c5c6a1a0a, the new focused cases produce 6 failed, 1 passed. Both IQ formats decode real nonzero packed blocks; only the byte-reservation assertions fail. For example, 512 IQ4_NL elements with fp16 compute reserve 5,408 bytes instead of 1,312. After the patch the same seven cases pass. The control registers an unmeasured device kernel and retains its conservative bound.Commands below use the existing test environment and repository root. The recorded Windows runs set application roots, caches and temporary paths to isolated task directories, restrict BLAS threads to one and disable network model downloads.
CPU-only execution covers IQ4_NL/IQ4_XS at fp16, bf16 and fp32, exact decoded outputs/shapes/dtypes, both owning and shared estimators, existing Q8/int8/mixed-layer behavior and the FLUX.1 reservation wire. No bf16 matmul is introduced. Eight CUDA-dependent cases are skipped; no local GPU allocation benchmark, full-model generation, full repository suite or build is claimed. The W7900 measurements in #9718 belong to its maintainer author, not this submission.
Review
No material review findings remain on the frozen candidate. The submission changes only reservation accounting; it does not change the decoder or generated values.
The host float32 decode still consumes host RAM; this change corrects the device reservation only. The existing non-IQ kernel estimates and their measurement precision are deliberately outside scope. A separate per-IQ lookup was rejected because it would diverge when a type gains a device kernel.
AI-assisted tooling was used to inspect the maintainer-reported path and develop the patch and tests. Listed results were executed; unavailable hardware checks are explicit.
Checklist
What's Newcopy (if doing a release after this PR) (not a release PR)Need help on this PR? Tag
@codesmith-botwith what you need.