Repository navigation
feat(model-manager): load nvfp4 Qwen3-VL text encoders (Krea-2, Ideogram 4) - #9804
Open
Pfannkuchensack wants to merge 1 commit into
Open
Pfannkuchensack wants to merge 1 commit into
Pfannkuchensack wants to merge 1 commit into
Conversation
Keep Comfy nvfp4 layers of the single-file Qwen3-VL 4B/8B encoder packed, reserved and remapped, and drop the LM head with the visual tower before any tensor work. Refuse undecodable nvfp4 layers at install through the loader's validator, keep a folded scaled embedding out of the fp8 storage pass, and fold large fp8 tensors in row slabs. Mark Qwen3-VL nvfp4 as supported in the model format docs.
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
Single-file nvfp4 builds of the Qwen3-VL 4B/8B text encoder (Krea-2, Ideogram 4) installed, then failed at the first generation with
size mismatch ... [out, in/2], after the model cache had already been cleared for them: the checkpoint loader passednvfp4_payloads={}and never took the packed layers out. They now load packed (NVFP4Linear, dequantized per forward), the way the Qwen3, Qwen2.5-VL and Mistral encoder loaders already do, and nvfp4 layers the loader cannot decode are refused at install.qwen3vl_8b_nvfp4.safetensors(Ideogram 4)weight_scale_2Qwen3VLEncoderCheckpointLoader): nvfp4 layers leave the state dict before the int8 branch (which strips every remaining.comfy_quantmarker) and the fp8 extraction (which discards non-fp8 block scales), are remapped to the transformers paths, counted in the branch's one reservation, and installed packed. The LM head is dropped with the visual tower before any tensor work (drop_qwen3vl_unloaded_keys); the 8B fp8 builds no longer fold a 151936x4096 head only to discard it.Qwen3VLEncoder_Checkpoint_Configruns the loader's own validator,find_nvfp4_layers(made public), over the keys the loader reads, with the.comfy_quantmarkers read from the file, since identification only holds meta tensors.dequantize_fp8_scaledfolds tensors above 2^24 elements a slab of rows at a time. On the 8B embedding the RAM peak drops from 5.80 to 1.13 GiB, bit-identical result.Related Issues / Discussions
Closes #9735
QA Instructions
Automated (Windows, CPU):
pytest -n 4 tests/backend/model_manager tests/backend/quantization tests/app/invocations tests/model_identification: 4809 passed, 159 skipped, 7 xfailed. New tests:tests/backend/model_manager/load/test_qwen3_vl_encoder_nvfp4_loader.py(a real toyQwen3VLModelwith the official layout, marker- and header-named, in fold / fp8-compute / fp8-storage modes; an int8 neighbour; MXFP8 under fp8 storage; refusals before the loader's reservation), new cases intests/backend/model_manager/configs/test_qwen3_vl_encoder_config.py, andTestFoldInSlabsintests/backend/quantization/test_fp8_scaled.py.ruff@0.11.2 checkandformat --checkon the changed files: clean.pnpm -C docs test,pnpm -C docs build,check-deploy-outputpass;scripts/generate_docs_json.pyleavesdocs/src/generatedunchanged.Manual, through the real loader with the model cache's custom layers (RTX 4090; RX 9060 XT with ROCm 10 on Windows):
Review
Material findings resolved:
Remaining limitations:
Checklist
What's Newcopy (if doing a release after this PR)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.