tensorRT: encoder/decoder fp8 tiers + DiT precision rename (fp16mixed→fp16); retire w8_bf16 & medium bf16 - #92
Merged
Conversation
…ofile, pad node) Train-free fp8 and int8-weight tiers for the SAME-S/SAME-L encoders and decoders, grafted onto the published bf16 export and preserved with GPTQ + per-op precision placement. Adds build_tiers.py (wide dynamic profile: L=1..8192) and pad_encoder.py (silence-pad node so encoders accept any audio length). ONNX artifacts ship on HF. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…fp8-vs-fp8_fast Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a --dec-precision selector (canonical / fp8 / w8_bf16 / fp8_fast), orthogonal to the DiT --precision, to both CLIs (sa3_trt.py graph mode + sa3_trt_core.py). New tier engines auto-download from HF. gradio's decoder-variant picker now offers the tiers and passes the selected tier to SA3Inference. install.sh usage documents them. Back-compat preserved: --dec-precision canonical still follows --precision for the decoder (e.g. --precision fp32 loads dec_dynamic_fp32.trt as before). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ch.py build_tiers.py now picks the SWA plugin impl by GPU arch (AOT on sm_120 — JIT isn't stream-capturable on Blackwell and silently drops the decode in the runtime mega-graph; JIT on sm_90). _arch.py (detect_arch → plain sm_XX for PTX retargeting) was referenced by the AOT plugin but never committed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
int8 weight-only ("w8_bf16") is a STORAGE format, not a compute format: its
DequantizeLinear constant-folds to bf16 at TRT build time, so the engine is
byte-for-byte the same size and speed as the plain bf16 baseline — only with
lossier weights. Strictly dominated, so pull it as a shipped tier.
- delete the 8 w8_bf16 .trt engines from HF (sm_90 + sm_120, same-s/l, dec/enc)
- drop w8_bf16 from DECODER_TIERS / *_TIER_FILENAME in sa3_trt_core.py
(--dec-precision now: canonical | fp8 | fp8_fast); gradio + install.sh follow
- README: reframe to two tiers + a retirement note carrying the
"ONNX size != engine size" lesson; remove w8_bf16 from all 4 tables,
the per-tier section, and "which to pick"
- keep the gptq_w8 / gptq_samel grafters + the w8_bf16 ONNX on HF for reference
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…m bf16 tier "fp16mixed" was noise — every tier is mixed-precision — so the canonical DiT + T5Gemma engines are now dit_fp16.trt / t5gemma_fp16.trt and the precision token is `fp16`. The medium-only `bf16` DiT tier is retired: it was ~3% faster but drifted at long sequence (bf16 RoPE angle ~4155 rad @L4092 vs 32-rad spacing), and fp16 matches its FMHA fusion without the drift. Back-compat: `--precision fp16mixed` and `--precision bf16` both silently alias to `fp16` (normalize_precision + _PRECISION_ALIAS), with a one-line note. - sa3_trt_core.py: DIT/DECODER engine maps, PRECISIONS=(fp8,fp16,fp32), drop medium bf16, add normalize_precision; argparse accepts the aliases - sa3_trt.py / sa3_gradio.py / install.sh: same rename + alias handling - README (tensorRT + build): fp16 naming, bf16 tier → retirement note - build/: rename build_dit_fp16mixed.py → build_dit_fp16.py and build_same_s_dec_fp16mixed.py → build_same_s_dec_fp16.py (+ the import); build_dit_bf16.py stays (it's the shared fp8 RoPE-baker, not the tier) HF (stabilityai/stable-audio-3-optimized): the fp16 engine/onnx names were server-side-copied alongside the old fp16mixed names; the old names + the 2 dit_bf16.trt are deleted in a follow-up once this merges (so main never references a name HF has dropped). dit_bf16.onnx kept as build reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cortexelus
marked this pull request as ready for review
August 2, 2026 08:12
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.
Quantized encoder + decoder tiers (SAME-S / SAME-L)
Train-free fp8 and int8-weight tiers for both encoders and decoders, each grafted onto the
published bf16 export and preserved with GPTQ + per-op precision placement. Adds a wide-profile
build script and a silence-pad node so encoders take any audio length.
The tier ONNX + sm_90 engines ship on HF (
stabilityai/stable-audio-3-optimized, next to the existingdec_dynamic_bf16.onnx/enc_dynamic_*); this PR adds the recipe, the build script, and the runtimewiring. The bf16 baseline is the first row of each table; decoder dB is vs that baseline, encoder
dB/cos is vs eager (the latent). Speed = whole-model median @1292.
Selecting a tier:
--dec-precision {canonical|fp8|w8_bf16|fp8_fast}(orthogonal to the DiT--precision) in both CLIs (sa3_trt.py,sa3_trt_core.py); the gradio decoder picker offers them too.Engines auto-download from HF on first use. Back-compat preserved:
--dec-precision canonicalstillfollows
--precisionfor the decoder (--precision fp32→dec_dynamic_fp32.trtas before).SAME-S decoder
dec_dynamic_bf16(baseline)dec_w8_bf16dec_fp8dec_fp8_fastSAME-L decoder
dec_dynamic_triton_swa(baseline)dec_w8_bf16dec_fp8SAME-S encoder — dB / cos vs eager (encoder is cheap → win is size, not speed)
enc_dynamic_bf16(baseline)enc_w8_bf16enc_fp8enc_fp8_fastSAME-L encoder — dB / cos vs eager
enc_dynamic_triton_swa(baseline)enc_w8_bf16enc_fp8The two knobs
fp8= fp8 compute (tensor cores) → real speedup, ~31 dB floor from fp8 activations (GPTQ can't lift it).w8_bf16= int8 weight-only storage, bf16 compute → smallest + most transparent, no speedup.fp8vsfp8_fastBoth run the FFN GEMMs (
ff.0/ff.2) in fp8. The difference is the attention projections:fp8leavesto_qkv/to_outin bf16 compute (weight-only fp8 for storage) → attention inputsstay full-precision → near-transparent.
fp8_fastrunsto_qkv/to_outin fp8 too → the extra +0.08× (1.14 → 1.22×), but itfp8-rounds Q/K/V before the (still-bf16) attention core, and the softmax path is fp8-sensitive → the
quality drop (31 → 26 dB). SAME-S only — SAME-L's attn projections are fp32 islands, so it has no
_fast.Sequence length
The graphs are fully dynamic — verified correct at L=1 → 8192 vs eager (odd/even/prime, no size
effect; quant tiers track bf16 identically at every length).
build_tiers.pybakes a wide profile(
latent [1,1292,8192]/audio [1,·,33.5M]), so L=1..31 work (can't be chunked) and long files runnatively — the old
[32,4096]was a conservative default, not a model limit. Encoders carry asilence-pad node (
pad_encoder.py) so any N is accepted; single-shot is accurate at any length (theruntime's
encode_chunkedturns out to be unnecessary).Notes for review
the ready-made HF ONNX need none of that.
would pull them to ~500 MB (follow-up).
🤖 Generated with Claude Code