Repository navigation
cuda: gate Flash Attention zero-fill workaround to NVCC 13.4 - #1143
Conversation
|
@askmyteapot Thanks for the PR. Can you test whether the change has any performance impact? |
|
@0xShug0 I tested this with a short paragraph on the RTX PRO 5000 Blackwell (sm_120a), Windows / CUDA 13.4, using BreezeTTS 2 BF16. No substantial end-to-end slowdown was observed for this workload. Method
Results
Total-generation ranges were 6272.903–6303.645 ms original and 6259.115–6303.221 ms patched. Decoder ranges were 83.346–88.746 ms original and 85.067–92.413 ms patched. The differences are small and the observed ranges overlap; this supports negligible end-to-end impact for this paragraph, not a universal zero-overhead claim or a formal statistical conclusion. For completeness, an earlier shorter sentence (3.44 seconds of output, ten measured requests after two warmups) gave 1154.893 → 1167.205 ms total (+1.07%), also with overlapping ranges. Input and tracesParagraph:
Command shape, run once for each executable with the paragraph repeated on seven lines in Measured requests 3–7, extracted directly from the timing logs (milliseconds): The attached archive contains both complete timing/trace logs and metrics stdout, all seven requests including warmups, input text, CSV, analysis script, and build/method notes. Local model/cache paths are omitted; timing values and timestamps are unchanged. These are application timing traces, not Nsight/GPU profiler traces. Separately, I rebuilt the full server and confirmed the original silent-audio problem is fixed. The timing comparison above still uses the diagnostic CLI pair described here. Other models and GPU architectures have not been performance-benchmarked. AI disclosure: Codex assisted with running the benchmarks, analyzing the recorded timings, and drafting this reply. |
|
Just converting this to draft while I investigate if other models are impacted by this. |
|
@0xShug0 Follow-up on the broader-impact investigation: I tested the original and patched kernels at head dimensions 64, 80, 96, 112, 128, and 256. All 216 patched cases passed against an independent CPU softmax reference.
Method: Windows / CUDA 13.4, with The original kernel reproduced NaNs only for dimension 64 on Blackwell, at lengths 17, 43, and 86 in both mask modes. The patch fixes those six cases. The other dimensions passed both before and after, so this establishes no regression in the tested cases rather than proving those dimensions previously had the same defect. The loader is shared by other models, so the fix applies wherever that loader is instantiated. Code inspection identified potentially exposed paths in F5-TTS, GLM-TTS, Audio8 TTS, and Demucs, but I have not reproduced failures in those complete model pipelines. Their padding, dimensions, and kernel selection can affect exposure. This matrix also does not cover every dtype, grouped-query ratio, batch/layout, or unequal Q/K/V dimension. Attached are the full original/patched results, test source, kernel-instantiation sources, summary, and analysis script. These are supplemental standalone tests; the committed regression test remains the dimension-64 case. Returning this PR to ready for review now that the additional dimension checks have passed. The paragraph benchmark above still shows negligible end-to-end speed impact for the tested workload. AI disclosure: Codex assisted with running and analyzing these checks and drafting this update. |
|
@askmyteapot Thanks for the detailed investigation! I reproduced the issue with BreezeTTS2 on Linux using CUDA 13.4, while the other models I tested worked without the same corruption. Disabling split compilation also fixed it with the original kernel unchanged. I'd prefer a narrowly scoped compiler workaround that preserves the original path, so we can remove it once NVIDIA fixes the 13.4 compiler issue. Gating it to affected builds would also avoid requiring broad regression testing on other CUDA versions and HIP, which shares this CUDA kernel source. |
|
@0xShug0 Updated in 5f6390c with the suggested I recompiled the gated variant with CUDA 13.4 / The description now reflects this revision and links the earlier detailed results and timing traces. The performance benchmark was not rerun after adding the gate. AI assistance: Codex helped implement, validate, and draft this update. |
|
@askmyteapot Thanks! PR merged! |
BreezeTTS 2 voice design can produce flat PCM audio when NVCC 13.4 compiles the Flash Attention partial-tile loader with
--split-compile=8. The standalone reproducer produces NaNs; disabling split compilation avoids the failure.Scope the explicit valid-row copy / direct
int4zero-store workaround to NVIDIA NVCC 13.4 usingGGML_CUDA_FA_NVCC_13_4_ZERO_FILL_FIX, as requested. Other compiler versions and HIP retain the original implementation. The gate applies to NVCC 13.4 builds regardless of whether split compilation is enabled. The precise faulty generated instruction has not been identified.The final diff changes only
external/ggml/src/ggml-cuda/fattn-mma-f16.cuh; no test files or CMake changes are included.Validation
--split-compile=8, fast math, and sm_86/sm_120a targets. All 216/216 standalone cases passed against an independent CPU softmax reference (absolute tolerance 0.003) on RTX PRO 5000 Blackwell and RTX 3090. Coverage: head dimensions 64, 80, 96, 112, 128, 256; sequence lengths 1, 7, 17, 43, 86, 128, 212, 300, 325; causal-window and unmasked attention.git diff --checkpasses. Tests were run locally and are not included in the PR.The broader head-dimension results and traces document the original versus unconditional workaround comparison. The paragraph benchmark and timing logs showed no substantial end-to-end slowdown for that workload (6289.060 → 6283.628 ms median, -0.09%); that benchmark predates the compiler gate and was not rerun for this revision.
AI disclosure
OpenAI Codex assisted with the investigation, code changes, local validation, benchmark analysis, and PR text. Reported results come from tests run on the local hardware.