fix(attention): fallback for GPUs without flash MMA kernels (sm70) - #423
fix(attention): fallback for GPUs without flash MMA kernels (sm70)#423Th-Underscore wants to merge 1 commit into
Conversation
Auto-resolve flash vs eager attention from CUDA compute capability:
Volta/Turing (700 <= cc < 800) fall back to eager, since large prefill
shapes select the MMA kernel which has no usable device code there
('flash_attn_ext_f16 has no device code compatible with CUDA arch 700').
- New engine::core::attention_fallback unit: preference parsing
(per-model '<family>.attention' session option + AUDIOCPP_ATTENTION),
CC gating via the CUDA driver (supports_op cannot detect this: it
returns true on sm70 for shapes that later crash at launch).
- Wire auto fallback + session options into higgs_audio_tts and
breeze_tts (backbone, depth, encoder, decoder); process-wide
AUDIOCPP_ATTENTION=eager backstop in the shared SDPA/GQA/QwenDecoder
modules; trace logging of the resolved path.
- Fix latent QwenDecoder prefix-concat dtype assert exposed by the
eager path (cast cached prefix KV on every path, not just flash).
- Unit test, breeze_tts model-spec entry, docs.
b2a888b to
ca67a82
Compare
|
@Th-Underscore Thanks! I was just about to rebase it myself. |
|
@Th-Underscore The Qwen eager path is essentially dead in the current code and is not reached by any model’s default path, so that change is safe. Interestingly, I could not reproduce the issue locally on RTX 5090, SM 120, and CUDA runtime 13.2. Higgs TTS works correctly with eager. Would you like to share the exact log? The concern is PR is broad. It exposes a global user-facing knob for what is basically a backend compatibility workaround for old CUDA devices. On Ampere/Ada/Blackwell, users may never need it. Another option is to remove the auto fallback too and make this fully explicit (with clear doc). For example, users on affected old CUDA GPUs can set Another issue: The documented prefixed option |
Summary
Volta/Turing GPUs (700 <= cc < 800) crash on TTS prefills that select the CUDA MMA flash-attention kernel, which has no usable device code there ("flash_attn_ext_f16 has no device code compatible with CUDA arch 700", followed by MUL_MAT failures). This PR auto-resolves flash vs eager attention from CUDA compute capability and falls back to the exact repeat-KV + matmul/softmax graph:
engine::core::attention_fallbackunit: preference parsing (per-model<family>.attentionsession option +AUDIOCPP_ATTENTIONenv), CC gating via the CUDA driver.ggml_backend_supports_op()cannot be used for detection: on Volta it returns true for shapes that later crash at launch.higgs_audio_ttsandbreeze_tts(backbone, depth, encoder, decoder); process-wideAUDIOCPP_ATTENTION=eagerbackstop in the shared SDPA/GQA/QwenDecoder modules;--logtrace lines for the resolved path.attention_fallback_test),breeze_ttsmodel-spec entry, docs.The change is additive: unknown backends fail open to flash, constructor defaults keep
allow_flash_attention=true, and the flash graph is untouched, so families that do not opt in keep byte-identical behavior.Validation
Build:
scripts/build_linux.sh --backend cuda --with-tests --cuda-arch "70"Backend: CUDA, Tesla V100-SXM2-16GB (sm70, underclocked to 765 MHz — wall times understate full-clock performance). Models:
higgs-audio-v3-tts-4b-q8_0.gguf,breeze-tts-2-q8_0.gguf,fish-audio-s2-pro-q8_0.gguf. Voice ref: VCTK p225 15 s concat preset.--task tts, auto, short textallow_flash=0, 3.0 s audio in 2.8 s wall, no CUDA errorsattention=flash, short textmax_tokensbefore EOC — reproduced on flash too; bracket tags (no Higgs parser) derail AR, unrelated to this PR--task clon, auto--backend cpuallow_flash=1), generates/v1/audio/speech, Higgs)flash_attn/MUL_MATerrorsctestattention_fallback_testChecked families/routes:
higgs_audio_tts(CLI + server),breeze_tts(CLI streaming + offline),fish_audio(CLI regression), CPU backend. All other families keep default behavior (fail-open).Eager vs flash is the same op with ulp-level logit differences (AR trajectories can diverge, e.g. 2.32 s vs 2.56 s output for one short sentence); eager is ~1.5x slower on short samples.
Known limitations