Repository navigation
fix(wan): unpack BF16 and embedder tensors when loading GGUF transformers - #10256
Open
Pfannkuchensack wants to merge 1 commit into
Open
Pfannkuchensack wants to merge 1 commit into
Pfannkuchensack wants to merge 1 commit into
Conversation
…mers The Wan GGUF loader now uses the shared unpack_ggml_at_load, so BF16 tensors and the condition embedder no longer stay packed as uint8 and crash the first denoise step with "mat1 and mat2 must have the same dtype, but got Byte and BFloat16".
joshistoast
approved these changes
Nov 13, 2026
joshistoast
left a comment
Collaborator
There was a problem hiding this comment.
wan small fix for tensors, wan giant leap for video gen
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
Wan 2.2 GGUF transformers that store non-block tensors as BF16 fail on the first denoise step with
RuntimeError: mat1 and mat2 must have the same dtype, but got Byte and BFloat16. One example isdarksidewalker/DaSiWa-WAN2.2-I2Vv11Q4_K_M, which storestime_embedding,text_embedding,time_projectionandheadas BF16.gguf_sd_loaderwraps BF16 like a quantized type, so the tensor reports itsuint8storage dtype. Wan's GGUF loader had its own unwrap helper, which only unpacked F32/F16 and left BF16 packed. diffusers'WanTimeTextImageEmbeddingcasts the timestep tonext(time_embedder.parameters()).dtype, which here isuint8. A release that quantizes the time embedder fails the same way.The Wan GGUF transformer loader now uses the shared
unpack_ggml_at_load, like every other GGUF transformer loader. It unpacks:patch_embedding,condition_embedderand norms.Quantized block Linears stay packed. The private helper is removed.
Related Issues / Discussions
User report on the v7 beta, DaSiWa Wan 2.2 I2V GGUF.
QA Instructions
pytest tests/backend/model_manager/load/test_wan_loader.py tests/backend/model_manager/load/test_wan_checkpoint_loader.py tests/backend/quantization/gguf: 142 passed. These ran CPU-only.The new test,
test_gguf_loader_unpacks_bf16_and_quantized_condition_embedder_weights, uses a tiny realWanTransformer3DModel. It feeds in the following tensor types:patch_embeddingandscale_shift_table;It checks that the BF16 bytes are reinterpreted exactly, the Q8_0 weights match gguf-py's dequantization, and the block Linear stays packed. It then runs a full forward pass. Against
main's loader it fails because the BF16 time-embedder weight is still packed.Real file, RTX 4090: DaSiWa v11 I2V A14B high and low
Q4_K_Mpair, 832×480, 17 frames, 6 steps.mainthe first run fails withmat1 and mat2 must have the same dtype, but got Byte and BFloat16.On CPU with the same file,
condition_embeddergives:main: aGGMLTensorreportingtorch.uint8, then the error above;Review
No material findings remain open.
Memory, worked out from the file headers:
time_projis gone.make_roomlike the other GGUF loaders. That is about 0.3 GiB above the file size; the extra is the in-flight term.Checklist
What's Newcopy (if doing a release after this PR)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.