Repository navigation
feat(model): support FireRed-Image-Edit-1.1 (+ fix Qwen-Image 1.x TP head_dim) - #1236
Merged
Merged
Conversation
diffusers >= 0.40 (huggingface/diffusers#13718) made `QwenDoubleStreamAttnProcessor2_0` derive `head_dim = attn.inner_dim // attn.heads` and then unflatten with `(-1, head_dim)`, while the planner still divided only `attn.heads`. Every Qwen-Image 1.x checkpoint (Qwen-Image, Edit-2509/2511, FireRed-Image-Edit 1.0/1.1) therefore crashed in the QK-norm: RuntimeError: The size of tensor a (256) must match the size of tensor b (128) Divide both attributes so that the ratio - and thus `head_dim` - stays invariant. That is also what the diffusers < 0.40 formulation (`unflatten(-1, (attn.heads, -1))`) needs, so both generations work; dividing only `heads` would still break < 0.40 and keeping `heads` whole only fixes >= 0.40. Same pattern as the longcat_audio_dit, nucleus_moe and flux2 planners. Verified on FireRed-Image-Edit-1.1: TP2 51.21 dB PSNR / 0.9973 SSIM, TP2+compile 50.27 dB vs the single-GPU bf16 reference. The new CPU test pins the invariant (`to_q.out_features // tp == heads * (inner_dim // heads)`) so both wrong fixes fail, and a weight-free 2-rank guard reproduces the old RuntimeError on the pre-fix plan.
FireRed-Image-Edit 1.0/1.1 is a stock `QwenImageEditPlusPipeline` checkpoint (six upstream components, no vendored module), so it needs no `BlockAdapter` or planner of its own: cache, CP, TP, quantization and layerwise offload all run through the existing Qwen-Image planners. Measured on one RTX PRO 5000 at 1024x1024 / 40 steps / bf16, warmup 2 + repeat 2, seed 43: cache 2.05x (38.58 dB / 0.9351 SSIM), vendor cache recipe 1.98x (44.90 dB / 0.9927), fp8_per_row 2.17x (45.40 dB / 0.9912), W4A4 svdq nvfp4 r64 2.44x (39.67 dB / 0.9729), TP2 1.68x (51.21 dB), CP2 1.80x (50.87 dB), layerwise offload bit-exact (inf). The bf16 baseline is bit-identical run to run. CP rows need `--ulysses-anything` for this prompt family: the text stream is 223 tokens (odd), so `pos_embed`'s `txt_freqs` cannot be split evenly across 2 ranks.
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.
Closes #1235
Summary
from diffusers import QwenImageEditPlusPipeline(inference.py:10,:80-88), and the checkpoint'smodel_index.jsonlists only upstream classes (QwenImageEditPlusPipeline/QwenImageTransformer2DModel/Qwen2_5_VLForConditionalGeneration/AutoencoderKLQwenImage/FlowMatchEulerDiscreteScheduler/Qwen2VLProcessor). Its ownutils/fast_pipeline.py:9-10alreadyimport cache_ditand usesDBCacheConfig(Fn=8, Bn=0, rdt=0.15, warmup=3)+TaylorSeer(1).README.mdanddocs/README.md(byte-identical rows), pinned to🤗[email protected]— the release that first shippedQwenImageEditPlusPipeline(diffusers#12357 /df267ee4e;git tag --containsstarts atv0.36.0), plus🤗HFandVariants=2.docs/supported_matrix/NVIDIA_GPU.mdalready lists both variants with Cache/CP/TP/TE-P/VAE-P ✅ and matches the measurements, so it is unchanged.QwenImageTensorParallelismPlannermust shardinner_dimtogether withheads. diffusers >= 0.40 (v0.40.0, diffusers#13718) rewrites the Qwen-Image attention processor tohead_dim = attn.inner_dim // attn.heads, so sharding onlyheadsmakes it compute2 * head_dimand crash in the QK-norm (RuntimeError: The size of tensor a (256) must match the size of tensor b (128)). Dividing both keeps the< 0.40path (unflatten(-1, (attn.heads, -1))) correct as well, so no version branch is needed. This affects the wholeQwenImageTransformer2DModelfamily, not only FireRed; it is a separate commit and can be reverted independently. A new unit test locks the shard contract.Acceptance matrix (Tier A, RTX PRO 5000 72GB, 1024x1024 / 40 steps / bf16 / SEED 43,
--warmup 2 --repeat 2)Single prompt / single reference image, so mean == min. Determinism floor is
inf(two bf16 runs are bit-identical). All rows pass thetesting.md§7.6(b) acceptance gates.Generated outputs (visual check)
Same prompt / same seed across configurations, left→right then top→bottom: bf16 reference, cache R0.12, fp8 + compile, W4A4 + compile, CP2, TP2, layerwise offload (bit-exact), CP2 + W4A4.
Notes on the matrix
--ulysses-anything. The official prompt encodes to 223 text tokens (odd), sopos_embed.txt_freqscannot be split across 2 ranks and plain--parallel ulyssesasserts in_context_parallel.py. The four CP rows run with--uaa. Row tags are unchanged; this is documented here rather than as a footnote in the model table.inf) and the 5.42 GiB fallback; the recommendation is to use it only under VRAM pressure.main(see Verification).Verification
U1_C0_Q0_NONE_avs_b=PSNR inf / SSIM 1.0000.b7d927d;_C_*.sorebuilt in a dedicated environment (CACHE_DIT_BUILD_CUDA=1 pip install -e . --no-build-isolation --no-deps), new_C_svdquantmd5402ef725...,nm -Dshows the new CuTe symbols and theopssurface is unchanged (no silent fallback). The reference-row PNG is byte-identical to the pre-rebase one (md5equal,max_abs_diff=0), and the TP2 PNG is also bit-identical, so the 12 non-quantized rows remain valid; the 4 quantized rows were re-measured.11 failed, 1469 passed, 12 skipped; baselineb7d927dparent (32e38bd) =11 failed, 1465 passed, 12 skipped. TheFAILEDsets are identical (verified withdiff), and the 4 extra passing tests are the newtests/parallelism/test_qwen_image_tp_plan.pycases. The 11 pre-existing failures are unrelated to this PR (concentrated in the svdq/cudagraph/quantization area plus a known"Wan"bare-prefix planner shadowing).pre-commit run --all-filesexits 0, all hooks pass, no file rewritten, no--no-verify.Compliance
main, branch rebased onto the latestorigin/main(b7d927d), no conflictsCloses #1235pr-assetsREADME.md+docs/README.md(byte-identical rows);docs/supported_matrix/NVIDIA_GPU.mdunchanged (already lists both variants, consistent with the measurements)+ torch.compilevariant--warmup 2, mean of--repeat 2grep -i fireredinreferences/rfc_pending_models.mdreturns 0 -> N/A (no pending entry to update).github/workflows/cpu-tests.ymluntouched--cache,--parallel tp,--parallel ulysses --ulysses-anything,--quantize-type float8_per_row,--quantize-type svdq_nvfp4_r64_dq,--layerwise-offloadall exercised throughcache_dit.generate_R+ hits)