Repository navigation
[Fix] diffusion/lora: revalidate FLUX.2 FP8/NVFP4 fast paths after LoRA attach - #40171
Merged
mickqian merged 3 commits intoOct 17, 2026
Merged
Conversation
…tach LoRA wrapping replaces quantized linears with wrappers that do not expose quant_method/input_scale. The _enable_fp8_token_cat/_enable_nvfp4_token_cat flags decided in Flux2ParallelSelfAttention.__init__ against the raw modules then go stale, and forward() reads those attributes off the wrapper and crashes. Add revalidate_fp8_fast_paths() on Flux2ParallelSelfAttention and Flux2Transformer2DModel, and call it from LoRAPipeline after wrappers are installed so each DiT rechecks fusion eligibility (getattr-safe) and disables the fused path instead of crashing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
heiculi98
requested review from
AgainstEntropy,
BBuf,
HaiShaw,
mickqian,
ping1jing2 and
yichiche
as code owners
September 18, 2026 10:41
Contributor
Author
|
Hi maintainers — this is a small bugfix for the FLUX.2 runtime LoRA + FP8 crash, verified end-to-end on an L20 GPU (A/B results in the description: crash without the patch, clean generation with it). Since CI is gated on the run-ci label, could someone with permission help trigger it? Happy to address any feedback. |
mickqian
approved these changes
Oct 14, 2026
Collaborator
|
/tag-and-rerun-ci |
detain
pushed a commit
to detain/sglang
that referenced
this pull request
Oct 15, 2026
…t paths after LoRA attach [batch-apply-b 2026-10-14] Cherry-pick -x of cdaa999 (single commit). PR base 9784d5f pre-dates merges sgl-project#3/sgl-project#4 (both files drifted +394/-72) yet 3way auto-merged: hunks are pure additions with unchanged context (post-__init__ slot in Flux2ParallelSelfAttention, tail of convert_to_lora_layers after critic conversion). Manually verified landing spots: required symbols (ModelOptFp{8,4}LinearMethod imports, configure_fp8_norm_quant) exist; only return in enclosing method is the lora_initialized guard so the revalidate loop is reachable. Composition with sgl-project#43793 (42e43cf, in merge sgl-project#4): disjoint files (group_coordinator/layer.py vs flux_2/lora-pipeline), both concerns live — sgl-project#43793 non-contiguous K/V gather fix retained at layer.py:488-491.
This comment has been minimized.
This comment has been minimized.
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.
Fix a crash when attaching a LoRA adapter at runtime to a FLUX.2 (multimodal_gen) model loaded from an FP8-quantized checkpoint (ModelOpt FP8).
Motivation
Flux2ParallelSelfAttention.__init__decides the fused fast-path flags_enable_fp8_token_cat/_enable_nvfp4_token_catby inspectingself.to_out.quant_methodon the raw quantizedRowParallelLinear. When aLoRA adapter is attached, the LoRA pipeline replaces those quantized linears
with wrapper modules that do not expose
quant_method/input_scale. Theinit-time flags then go stale, and
forward()reads those attributes off thewrapper, crashing instead of falling back to the unfused path.
Reproduced on an L20 GPU (SM89) with the official FLUX.2-klein-9b-fp8
checkpoint and a runtime-attached LoRA adapter (locally trained, cannot be
shared): the model crashes on the first forward pass after the adapter is
mounted.
Related: #35970 (diffusion LoRA + FP8 crash on static merge) — the merge-policy
half is handled by the
can_merge_base_weightdynamic fallback; this PR fixesthe stale fast-path flags on the dynamic path.
Modifications
attributes, the fusion is simply disabled.
Flux2Transformer2DModel.revalidate_fp8_fast_paths()which also re-runsconfigure_fp8_norm_quant()per block.LoRAPipelineafter the wrappers are installed (formodules that expose it, e.g.
transformer/transformer_2).No behavior change when no LoRA is attached — the revalidation hook only runs
after LoRA wrappers are installed.
Accuracy Tests
End-to-end A/B on a single L20 GPU (SM89) with the official
FLUX.2-klein-9b-fp8 checkpoint and a runtime-attached LoRA adapter (locally
trained, cannot be shared), built on this PR branch (latest main):
POST /v1/set_lora(merge_mode=dynamic), the first LoRA generation fails immediately with
AttributeError: 'ColumnParallelLinearWithLoRA' object has no attribute 'input_scale'insideFlux2Transformer2DModel.forward.1024x1024 output; no errors in the server log.
patch yields bit-identical output images.
Speed Tests and Profiling
N/A — this change only disables fused fast paths that would otherwise crash
under LoRA; it does not affect the non-LoRA serving path.
CI States
Latest PR Test (Base): ✅ Run #39017061749
Latest PR Test (Extra): ❌ Run #39017061730
Latest PR Test (AMD ROCm 10): ❌ Run #39017061718