[diffusion] Support nvfp4 for Flux.2#20137
Merged
mickqian merged 70 commits intosgl-project:mainfrom Mar 25, 2026
Merged
Conversation
parameters for packed qkv
Contributor
Author
|
/rerun-failed-ci |
Collaborator
|
/rerun-failed-ci |
4 similar comments
Collaborator
|
/rerun-failed-ci |
Collaborator
|
/rerun-failed-ci |
Collaborator
|
/rerun-failed-ci |
Collaborator
|
/rerun-failed-ci |
0-693
pushed a commit
to 0-693/sglang
that referenced
this pull request
Mar 25, 2026
Co-authored-by: zcnrex <zcnrex@gmail.com> Co-authored-by: BBuf <1182563586@qq.com> Co-authored-by: Yikang Cai <dcai@catalyst-fleet1.cs.cmu.edu> Co-authored-by: CHEN Xi <78632976+RubiaCx@users.noreply.github.com> Co-authored-by: RubiaCx <1084281732@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mick <mickjagger19@icloud.com>
johnnycxm
pushed a commit
to johnnycxm/sglang
that referenced
this pull request
Mar 25, 2026
Co-authored-by: zcnrex <zcnrex@gmail.com> Co-authored-by: BBuf <1182563586@qq.com> Co-authored-by: Yikang Cai <dcai@catalyst-fleet1.cs.cmu.edu> Co-authored-by: CHEN Xi <78632976+RubiaCx@users.noreply.github.com> Co-authored-by: RubiaCx <1084281732@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mick <mickjagger19@icloud.com>
johnnycxm
pushed a commit
to johnnycxm/sglang
that referenced
this pull request
Mar 25, 2026
Co-authored-by: zcnrex <zcnrex@gmail.com> Co-authored-by: BBuf <1182563586@qq.com> Co-authored-by: Yikang Cai <dcai@catalyst-fleet1.cs.cmu.edu> Co-authored-by: CHEN Xi <78632976+RubiaCx@users.noreply.github.com> Co-authored-by: RubiaCx <1084281732@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mick <mickjagger19@icloud.com>
yhyang201
added a commit
to yhyang201/sglang
that referenced
this pull request
Mar 30, 2026
The single-stream block's to_out (RowParallelLinear) receives input as [attn_shard | mlp_shard], where each part is independently sharded by MergedColumnParallelLinear. However, RowParallelLinear's default weight loader slices weight columns as a contiguous block, causing a mismatch between weight columns and input features when TP > 1. Fix: patch the weight loader to select the correct non-contiguous columns (attn slice + mlp slice) from the full checkpoint weight per rank. Introduced by 281fe10 (sgl-project#20137). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
yhyang201
added a commit
to yhyang201/sglang
that referenced
this pull request
Mar 30, 2026
The single-stream block's to_out (RowParallelLinear) receives input as [attn_shard | mlp_shard], where each part is independently sharded by MergedColumnParallelLinear. However, RowParallelLinear's default weight loader slices weight columns as a contiguous block, causing a mismatch between weight columns and input features when TP > 1. Fix: patch the weight loader to select the correct non-contiguous columns (attn slice + mlp slice) from the full checkpoint weight per rank. Introduced by 281fe10 (sgl-project#20137).
satyamk7054
pushed a commit
to satyamk7054/sglang
that referenced
this pull request
Apr 3, 2026
Co-authored-by: zcnrex <zcnrex@gmail.com> Co-authored-by: BBuf <1182563586@qq.com> Co-authored-by: Yikang Cai <dcai@catalyst-fleet1.cs.cmu.edu> Co-authored-by: CHEN Xi <78632976+RubiaCx@users.noreply.github.com> Co-authored-by: RubiaCx <1084281732@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mick <mickjagger19@icloud.com>
lishunyang12
added a commit
to lishunyang12/vllm-omni
that referenced
this pull request
Apr 6, 2026
Add NVIDIA FP4 (NVFP4) quantization support for Flux.2 diffusion models, enabling running FLUX.2-dev-NVFP4 pre-quantized checkpoints via ModelOpt. Key changes: - Add BFL checkpoint weight name mapping (WeightsMapper) to Flux2Transformer2DModel.load_weights() with auto-detection - Add transformer_weights_path to OmniDiffusionConfig for loading transformer weights from a separate checkpoint path - Add NVFP4 auto-detection from safetensors file headers - Update FluxPipeline and Flux2KleinPipeline to support separate transformer weight paths - Add unit tests for weight mapping, format detection, and auto-detection Leverages vLLM's existing ModelOptNvFp4Config and ModelOptNvFp4LinearMethod registered as "modelopt_fp4" — no custom quantization config needed. Reference: sgl-project/sglang#20137 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lishunyang12
added a commit
to lishunyang12/vllm-omni
that referenced
this pull request
Apr 6, 2026
Add NVIDIA FP4 (NVFP4) quantization support for Flux.2 diffusion models, enabling running FLUX.2-dev-NVFP4 pre-quantized checkpoints via ModelOpt. Key changes: - Add BFL checkpoint weight name mapping (WeightsMapper) to Flux2Transformer2DModel.load_weights() with auto-detection - Add transformer_weights_path to OmniDiffusionConfig for loading transformer weights from a separate checkpoint path - Add NVFP4 auto-detection from safetensors file headers - Update FluxPipeline and Flux2KleinPipeline to support separate transformer weight paths - Add unit tests for weight mapping, format detection, and auto-detection Leverages vLLM's existing ModelOptNvFp4Config and ModelOptNvFp4LinearMethod registered as "modelopt_fp4" — no custom quantization config needed. Reference: sgl-project/sglang#20137 Signed-off-by: lishunyang <lishunyang12@163.com>
JustinTong0323
pushed a commit
to JustinTong0323/sglang
that referenced
this pull request
Apr 7, 2026
Co-authored-by: zcnrex <zcnrex@gmail.com> Co-authored-by: BBuf <1182563586@qq.com> Co-authored-by: Yikang Cai <dcai@catalyst-fleet1.cs.cmu.edu> Co-authored-by: CHEN Xi <78632976+RubiaCx@users.noreply.github.com> Co-authored-by: RubiaCx <1084281732@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mick <mickjagger19@icloud.com>
yhyang201
pushed a commit
to yhyang201/sglang
that referenced
this pull request
Apr 22, 2026
Co-authored-by: zcnrex <zcnrex@gmail.com> Co-authored-by: BBuf <1182563586@qq.com> Co-authored-by: Yikang Cai <dcai@catalyst-fleet1.cs.cmu.edu> Co-authored-by: CHEN Xi <78632976+RubiaCx@users.noreply.github.com> Co-authored-by: RubiaCx <1084281732@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mick <mickjagger19@icloud.com>
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.
Modifications
ModelOptNvfp4Layer, which is adopted from a similar layer fromsrtfrom the previous PR. However, theweight_scaless in flux2 checkpoints differ from the format required from this layer. and another reference implementation based on comfyui is included. Currently, the nvfp4 version of flux2 is only supported in comfyui.There are two checkpoints in the repo:
flux2-dev-nvfp4andflux2-dev-nvfp4-mixed. The mixed checkpoint doesn't haveinput_scalefor quantized layers and have some more layers in bf16.Run diffusion model with:
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci