Skip to content

Stabilize Higgs Audio termination and prefill#141

Open
LiangSu8899 wants to merge 6 commits into
mainfrom
fix/higgs-bf16-batched-prefill-eoc
Open

Stabilize Higgs Audio termination and prefill#141
LiangSu8899 wants to merge 6 commits into
mainfrom
fix/higgs-bf16-batched-prefill-eoc

Conversation

@LiangSu8899

@LiangSu8899 LiangSu8899 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Kernelize the Higgs BF16 batched prefill path for embedding lookup, projection GEMMs, q/k norm + RoPE, and KV writes.
  • Add a shared delayed-codebook helper for per-frame argmax, delay handling, and codebook embedding accumulation.
  • Gate the delayed-codebook helper behind FLASHRT_ENABLE_AUDIO_CODEBOOK so source, binding, and required-symbol checks stay in lockstep.
  • Fix delayed EOC handling so short BF16 prompts terminate instead of running to the generation cap.
  • Make FP8 activation calibration independent of the first user request by using a fixed built-in calibration prompt.
  • Add a deterministic repeated-code stop guard for pathological no-EOC FP8 loops.
  • Refresh Higgs performance docs with the same single-stream benchmark methodology.

Root cause

The 40 s output cap was not a BF16 fallback issue. There were two related termination failures:

  • BF16 batched prefill wrote a slightly different prompt KV state and the old delayed-EOC check only handled the first codebook reliably. Short prompts could miss EOC and run to the cap.
  • FP8 used activation scales calibrated from the first user prompt. Different first prompts selected different scale sets; for some scale/prompt pairs the free-running discrete audio decode entered a stable repeated-code loop where EOC was no longer close to top-1.

The FP8 fix avoids first-request scale sensitivity and keeps a bounded deterministic termination guard for repeated code loops. Normal EOC termination remains unchanged.

Performance

Same single-stream Higgs benchmark setup as the docs.

Metric Before After
BF16 Four score. output duration 40.68 s cap about 1 s
BF16 prefill, P=6 8.42 ms 6.73 ms
BF16 prefill, P=13 11.74 ms 6.82 ms
BF16 warm RTF, benchmark sentence 0.15 0.152
BF16 TTFA, benchmark sentence ~138 ms 127 ms
BF16 AR decode, benchmark sentence ~6.1 ms/frame 6.02 ms/frame
FP8 warm RTF, benchmark sentence 0.095-0.11 0.09
FP8 TTFA, benchmark sentence ~94 ms 79 ms
FP8 AR decode, benchmark sentence ~3.2 ms/frame 3.6 ms/frame

Known FP8 startup-order regressions were checked with first requests Four score., Four years ago., Hello from FlashRT., and the benchmark sentence; all subsequent Four score. / Four years ago. runs terminate normally.

The remaining torch matmul/embedding/argmax grep hits are limited to the one-time FP8 calibration reference path, not the BF16/FP8 request prefill/decode hot path.

Validation

  • cmake -S . -B build -DGPU_ARCH=120 -DFLASHRT_ENABLE_AUDIO_CODEBOOK=ON
  • cmake --build build --target flash_rt_kernels -j$(nproc)
  • pytest -q tests/test_higgs_audio_v3_eoc.py tests/test_build_inventory.py tests/test_generic_kernel_bindings.py
  • FLASHRT_BUILD_DIR=build-sm89-inventory pytest -q tests/test_build_inventory.py
  • FLASHRT_BUILD_DIR=build-sm89-slim-inventory pytest -q tests/test_build_inventory.py
  • FLASHRT_BUILD_DIR=build-sm89-audio-off-inventory pytest -q tests/test_build_inventory.py
  • python -m py_compile flash_rt/frontends/torch/_higgs_audio_v3_fp8.py flash_rt/frontends/torch/_higgs_audio_v3_bf16.py flash_rt/frontends/torch/higgs_audio_v3_rtx.py
  • git diff --check
  • Import and required-symbol checks for Higgs kernel bindings
  • Manual FP8 startup-order matrix for short-prompt termination
  • Manual BF16 Higgs benchmark for Four score., Four years ago., and the documented benchmark sentence
  • Diff-scoped scan for private paths, secrets, debug traces, and generated markers

@LiangSu8899 LiangSu8899 linked an issue Jul 9, 2026 that may be closed by this pull request
@LiangSu8899 LiangSu8899 changed the title Fix Higgs BF16 batched prefill EOC Stabilize Higgs Audio termination and prefill Jul 9, 2026
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.

higgs tts input异常

1 participant