Skip to content

fp8 medium DiT: calibrated tier — same bf16-fused speed, better worst-step fidelity (calibration by @ryanontheinside, #47) - #86

Merged
Cortexelus merged 2 commits into
mainfrom
fp8-calibrated-tier
Jul 31, 2026
Merged

fp8 medium DiT: calibrated tier — same bf16-fused speed, better worst-step fidelity (calibration by @ryanontheinside, #47)#86
Cortexelus merged 2 commits into
mainfrom
fp8-calibrated-tier

Conversation

@Cortexelus

Copy link
Copy Markdown
Collaborator

Upgrades the fp8 medium-DiT tier to a calibrated engine — same bf16-fused speed, meaningfully better worst-case per-step fidelity.

What changed. The shipped dit_fp8 (#84) used uncalibrated fp8 scales. This grafts the calibrated activation + per-channel weight scales from @ryanontheinside's fp8 work (#47) onto the existing bakedmin structure (baked fp32 RoPE + bf16 fused MHA + weakly-typed). Real-conditioning calibration capture is his make_calib.py.

Result (H200, L=4096, same-run).

  • Speed unchanged: 31.2 ms/fwd vs the uncalibrated 30.8 (+0.3, noise) — calibration is speed-free.
  • Fidelity: worst-step velocity-cos vs fp32 on adversarial seeds lifts 0.52/0.57/0.64 → 0.92/0.94/0.92; steps 1–7 track the fully-calibrated reference within 0.001. Restores the energy the uncalibrated engine lost at the highest-noise first step.

Still medium-only, ≤4096, default stays fp16mixed. Speed/quality knob: @ryanontheinside's fp16-attention variant (#47) buys the last ~0.03 of step-0 fidelity for +2 ms/fwd; this tier keeps bf16 attention for the speed.

Calibration approach + make_calib.py tooling by @ryanontheinside (#47).

🤖 Generated with Claude Code

ryanontheinside and others added 2 commits July 31, 2026 03:17
Captures the FP8 calibration .npz for the medium DiT by driving the model's own pingpong generate() and recording the six DiT engine inputs at every sampling step. Native by construction: loads via the repo's own load_diffusion_cond, prompts from interface/reprompt.py, the real pingpong sigma schedule (no re-implementation of the inference path).

From #47 (feat/dit-fp8); included here to support the calibrated fp8 tier.
Grafts @ryanontheinside's calibrated fp8 scales (#47) onto the shipped bakedmin
fp8 structure (baked fp32 RoPE constant + bf16 fused MHA + weakly-typed), so the
`dit_fp8` tier keeps its bf16-fused speed while gaining much better worst-step
fidelity. The build recipe is unchanged — calibration lives entirely in the ONNX
scale values.

- transplant_scales.py: match every quantized Linear by weight-initializer name
  and swap only the fp8 scale VALUES (per-tensor activation amax + per-channel
  weight scales) from #47's calibrated ONNX onto our RoPE-baked graph; the 5.8 GB
  fp32 weights are untouched (TRT re-quantizes at build).
- build_from_onnx.py: update the sa3-m-fp8 recipe notes — dit_fp8 is now the
  calibrated engine.
- build/README.md + tensorRT/README.md: document the calibrated tier, the
  bake -> transplant producer flow, and that a from-scratch recalibration uses
  #47's full pipeline (make_calib.py -> build_dit_fp8.py).

Measured H200 (L=4096, same run): speed unchanged (31.2 vs uncalibrated 30.8
ms/fwd, within noise); worst-step velocity-cos vs fp32 on adversarial seeds
0.52/0.57/0.64 -> 0.92/0.94/0.92, with steps 1-7 tracking the fully-calibrated
#47 reference within ~0.001.

Calibration approach + make_calib.py tooling by @ryanontheinside (#47).

Co-authored-by: RyanOnTheInside <7623207+ryanontheinside@users.noreply.github.com>
@Cortexelus
Cortexelus merged commit 7dab8b2 into main Jul 31, 2026
1 check failed
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.

2 participants