Files
Strata/tools/image/sdcpp_dit
Niko1221 09d67a33d4 image: own DiT GEMMs for the native Qwen-Image-2.1 runner (D1+D2, test builds only)
D1 and D2 together: every multiply of the native runner's DiT call on our own GEMM
(src/image/dit/dit_gemm.cu: weights decoded to f16 by te_dequant, activations to f16,
cuBLAS / hipBLAS GemmEx with float32 sums). Groups: blocks + img_in (D1); timestep MLP,
modulation, norm_out; txt_in; the head (D2). Wired into the pinned stable-diffusion.cpp
by tools/image/sdcpp_dit/apply.py (build_variant.py --dit) behind
--model-args strata_dit_gemm=1. No build or product path uses it; sd.cpp stays the
default and the fallback.

Measured together, not D1 alone: D1 alone was 0.00331 from the f32 reference against
the emulation's 0.00065 (5x); only all four groups together reach the emulation's level,
because the multiplies left on ggml's MMQ (8-bit activations) then dominate.
vel_0 rel L2 to f32, 512 prompts 0-3 (mean), per group switched on:
  none (native runner) 0.00609 | all (D1+D2) 0.00065 | D1 0.00331 |
  D1 + timestep/modulation/norm_out 0.00271 | D1 + txt_in 0.00342 | D1 + head 0.00200 |
  f16 emulation 0.00065 | stock 0.00678

Stage rule (coordinator's restated rule: mean within 1.25x the emulation, no case above
1.5x, every case closer than stock and native). Nine cases (prompts 0-7 at 512, prompt 0
at 1024), velocity rel L2 to f32:
  against the emulation with float32 sums (dit_ref mode f16acc32): mean ratio 1.039,
  largest 1.177 (512 p6); against the emulation with exact sums (mode f16op): mean
  ratio 1.116, 512 p5 at 2.078. Every case 0.00048-0.00114 from f32; stock 0.0049-0.0090,
  native 0.0052-0.0083.
The comparison was changed to the float32-sum emulation after the measurement
(coordinator, 11-11): on prompt 5 the exact-sum emulation moves from 0.00055 to 0.00086
when started from inputs that differ by 3e-6; a per-block trace found no step that differs
from the emulation's arithmetic (block 20 replayed from our input agrees to 0.0002). Both
modes stay in dit_ref.py; tools/image/gate/dit_acc32_cases.py reproduces the table.

Gate (a): with the argument off, 16 pictures (prompts 0-7, seeds 42 and 1234, 1024)
byte-identical to the build before D1: 16 of 16 (dgxspark-20261111-0513-8147).
Pictures, 16 against stock sd.cpp, PSNR mean / min, SSIM mean / min (GB10):
  sd.cpp cuBLAS-forced 33.35 / 23.06 dB, 0.979 / 0.937
  sd.cpp native runner 34.32 / 21.32 dB, 0.982 / 0.923
  ours (D1+D2)         34.45 / 23.74 dB, 0.982 / 0.948
  ours vs native       35.90 / 20.71 dB, 0.982 / 0.912
Sampling median at 1024: stock 19.57 s, native 12.32 s, ours 12.54 s.

Also: te_type_supported / te_row_bytes moved into te_dequant.cu (needed without the
host decoder); run_set.py --model-arg; test-only trace hooks in apply.py
(STRATA_DIT_TRACE_DIR / STRATA_DIT_TRACE_BLOCK, read after a backend sync, change no
value); dit_replay.py / dit_replay2.py (the prompt-5 trace tools).
Tests: tools/test_sdcpp_dit.py, tools/image/gate/test_dit_ref.py (modes).
2026-11-11 05:26:49 +01:00
..