Skip to content

feat(model): support FireRed-Image-Edit-1.1 (+ fix Qwen-Image 1.x TP head_dim) - #1236

Merged
DefTruth merged 3 commits into
mainfrom
team/firered-ie/firered-ie
Nov 5, 2026
Merged

DefTruth merged 3 commits into
mainfrom
team/firered-ie/firered-ie

Conversation

@DefTruth

@DefTruth DefTruth commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Closes #1235

Summary

  • FireRed-Image-Edit-1.1 needs no custom model path. Its official entry point is from diffusers import QwenImageEditPlusPipeline (inference.py:10, :80-88), and the checkpoint's model_index.json lists only upstream classes (QwenImageEditPlusPipeline / QwenImageTransformer2DModel / Qwen2_5_VLForConditionalGeneration / AutoencoderKLQwenImage / FlowMatchEulerDiscreteScheduler / Qwen2VLProcessor). Its own utils/fast_pipeline.py:9-10 already import cache_dit and uses DBCacheConfig(Fn=8, Bn=0, rdt=0.15, warmup=3) + TaylorSeer(1).
  • Docs: add FireRed-Image-Edit to the diffusers model table in README.md and docs/README.md (byte-identical rows), pinned to 🤗[email protected] — the release that first shipped QwenImageEditPlusPipeline (diffusers#12357 / df267ee4e; git tag --contains starts at v0.36.0), plus 🤗HF and Variants=2. docs/supported_matrix/NVIDIA_GPU.md already lists both variants with Cache/CP/TP/TE-P/VAE-P ✅ and matches the measurements, so it is unchanged.
  • Fix: QwenImageTensorParallelismPlanner must shard inner_dim together with heads. diffusers >= 0.40 (v0.40.0, diffusers#13718) rewrites the Qwen-Image attention processor to head_dim = attn.inner_dim // attn.heads, so sharding only heads makes it compute 2 * head_dim and 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.40 path (unflatten(-1, (attn.heads, -1))) correct as well, so no version branch is needed. This affects the whole QwenImageTransformer2DModel family, 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)

Configuration Latency Speedup PSNR mean/min SSIM mean/min
single-GPU bf16 (reference) 111.48 s 1.00x – –
same, rerun (determinism) 111.49 s 1.00x inf 1.0000
+ compile 101.43 s 1.10x 50.47 0.9966
+ cache R0.12 (21/40 hits) 54.27 s 2.05x 38.58 0.9351
+ cache vendor recipe R0.15/F8B0/W3/TS(1) (23/40) 56.25 s 1.98x 44.90 0.9927
+ cache vendor + compile 51.21 s 2.18x 44.39 0.9905
+ fp8_per_row + compile 51.33 s 2.17x 45.33 0.9915
+ W4A4 svdq nvfp4 r64 few_shot + compile 45.83 s 2.43x 40.19 0.9788
+ layerwise offload 173.63 s 0.64x inf 1.0000
+ offload + async transfer 151.86 s 0.73x inf 1.0000
+ offload + compile 168.63 s 0.66x 50.96 0.9972
+ offload + async + compile 119.44 s 0.93x 51.38 0.9974
TP2 66.59 s 1.67x 51.21 0.9973
TP2 + compile 60.16 s 1.85x 50.27 0.9965
CP2 (ulysses + UAA) 62.04 s 1.80x 50.87 0.9968
CP2 + compile 57.64 s 1.93x 50.67 0.9968
CP2 + fp8_per_row + compile 36.18 s 3.08x 45.35 0.9916
CP2 + W4A4 + compile 34.73 s 3.21x 39.67 0.9729
TP2 + TE-P (run-only) 66.71 s – 51.42 0.9973
TP2 + VAE-P (run-only) 66.24 s – 50.64 0.9959

Single prompt / single reference image, so mean == min. Determinism floor is inf (two bf16 runs are bit-identical). All rows pass the testing.md §7.6(b) acceptance gates.

acceptance matrix

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.

generated outputs

Notes on the matrix

  • CP requires --ulysses-anything. The official prompt encodes to 223 text tokens (odd), so pos_embed.txt_freqs cannot be split across 2 ranks and plain --parallel ulysses asserts 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.
  • Offload is a negative performance result on this card (0.64x / 0.73x). Its value is the bit-exact correctness proof (inf) and the 5.42 GiB fallback; the recommendation is to use it only under VRAM pressure.
  • W4A4 is +0.52 dB / +0.0059 SSIM vs the pre-rebase numbers (39.67 -> 40.19). That comes from feat(svdq): 1/N add CuTe NVFP4 workflow with native default #1229 switching the NVFP4 W4A4 default path to the CuTe implementation, not from anything FireRed-specific.
  • fp8 and W4A4 rows are measured with the rebuilt extension against the rebased main (see Verification).

Verification

  • Determinism: U1_C0_Q0_NONE_a vs _b = PSNR inf / SSIM 1.0000.
  • Rebase + extension rebuild: branch rebased onto b7d927d; _C_*.so rebuilt in a dedicated environment (CACHE_DIT_BUILD_CUDA=1 pip install -e . --no-build-isolation --no-deps), new _C_svdquant md5 402ef725..., nm -D shows the new CuTe symbols and the ops surface is unchanged (no silent fallback). The reference-row PNG is byte-identical to the pre-rebase one (md5 equal, 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.
  • Tests: full suite on the branch = 11 failed, 1469 passed, 12 skipped; baseline b7d927d parent (32e38bd) = 11 failed, 1465 passed, 12 skipped. The FAILED sets are identical (verified with diff), and the 4 extra passing tests are the new tests/parallelism/test_qwen_image_tp_plan.py cases. 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: pre-commit run --all-files exits 0, all hooks pass, no file rewritten, no --no-verify.

Compliance

  • Base is main, branch rebased onto the latest origin/main (b7d927d), no conflicts
  • Linked issue: Closes #1235
  • Performance / accuracy table in the body, with PSNR and SSIM mean/min columns; figure hosted on pr-assets
  • Docs in the same commit: README.md + docs/README.md (byte-identical rows); docs/supported_matrix/NVIDIA_GPU.md unchanged (already lists both variants, consistent with the measurements)
  • Coverage: Cache / TP / CP / fp8_per_row / svdq W4A4 NVFP4 / layerwise offload (async on) / TE-P / VAE-P, each with the + torch.compile variant
  • All timings taken after --warmup 2, mean of --repeat 2
  • Session presentation: table + latency|quality figure
  • RFC: grep -i firered in references/rfc_pending_models.md returns 0 -> N/A (no pending entry to update)
  • .github/workflows/cpu-tests.yml untouched
  • CLI reachability: --cache, --parallel tp, --parallel ulysses --ulysses-anything, --quantize-type float8_per_row, --quantize-type svdq_nvfp4_r64_dq, --layerwise-offload all exercised through cache_dit.generate
  • Numbers traceable: recipe fingerprint read from each row's log (steps / CFG / resolution / quantization / cache _R + hits)

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.
@DefTruth
DefTruth merged commit 10c5daa into main Nov 5, 2026
4 checks passed
@DefTruth
DefTruth deleted the team/firered-ie/firered-ie branch November 5, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support FireRed-Image-Edit-1.1

1 participant