feat(ops): add GGMLTensor.dequantize() for generic core cast path - #468
Open
Log-Dog012 wants to merge 1 commit into
Open
feat(ops): add GGMLTensor.dequantize() for generic core cast path#468Log-Dog012 wants to merge 1 commit into
Log-Dog012 wants to merge 1 commit into
Conversation
Expose a dequantize(dtype=None) method on GGMLTensor that delegates to dequantize_tensor, mirroring what GGMLLayer.get_weight already does. This lets ComfyUI core's generic comfy.ops.cast_bias_weight dequantize GGUF weights instead of leaking the block-packed storage into matmul (which crashes on a shape mismatch for e.g. Qwen2.5-VL generate()).
Author
|
Paired core PR: Comfy-Org/ComfyUI#15049 — that change makes the generic |
There was a problem hiding this comment.
Pull request overview
This PR adds a duck-typed GGMLTensor.dequantize(dtype=None) API so ComfyUI core’s generic casting path can dequantize GGUF-backed weights before they reach F.linear, avoiding shape-mismatch crashes caused by block-packed storage.
Changes:
- Add
GGMLTensor.dequantize(dtype=None)delegating todequantize_tensor. - Document why this method exists (core duck-typing and the
F.linearshape-mismatch failure mode).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+103
to
+106
| dt = dtype if dtype is not None else torch.float32 | ||
| w = dequantize_tensor(self, dt, None) | ||
| # prevent propagating the custom tensor class | ||
| return torch.Tensor(w) |
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.
What
Expose a
dequantize(dtype=None)method onGGMLTensorthat delegates todequantize_tensor, mirroring whatGGMLLayer.get_weightalready does.This lets ComfyUI core's generic
comfy.ops.cast_bias_weightdequantize GGUFweights instead of leaking the block-packed storage into matmul, which crashes
on a shape mismatch for e.g. Qwen2.5-VL
generate():Why duck-typed
Core's
cast_bias_weightonly handlesQuantizedTensor. Rather than have coreimport GGUF types, we expose
dequantize()here and core checks for it by ducktyping (see Comfy-Org/ComfyUI#CORE_PR).
Verification
Paired with the core change, loading a real Qwen2.5-VL GGUF clip and calling
the unmodified
transformer.logitsreturns(1, 1, 152064)instead of crashing.