whisper.cpp/src
Guenter Bartsch 6ce8e7028c whisper : mask padded K/V in flash-attention encoder and cross-attention
With flash attention enabled, the encoder self-attention and the decoder
cross-attention view their K/V buffers padded to GGML_PAD(n_ctx, 256)
but only write n_ctx rows, and call ggml_flash_attn_ext with a null
mask. The unwritten pad rows are attended at full weight; their content
is whatever the buffer holds - zeros on a fresh state, or leftovers of
previous whisper_full calls with a different audio_ctx (layer strides
il*n_ctx_pad shift between window sizes, so runs overwrite each other's
pad regions).

On a long-running server this makes transcriptions depend on request
history: e.g. large-v3-turbo with audio_ctx=250 on a 3 s clip produced
5x sentence duplication on a fresh state, 2x after one audio_ctx=500
request, and clean output after full-window requests. The default full
window is affected too (36 unmasked rows out of 1536), just diluted
enough to go unnoticed.

Fix: give both call sites a proper mask input (mirroring the decoder
self-attention KQ_mask) with -INFINITY over [n_ctx, n_ctx_pad), filled
in whisper_encode_internal / whisper_decode_internal. Outputs at reduced
audio_ctx are now deterministic regardless of prior requests; timing is
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 11:35:40 +02:00
..
coreml coreml : backport CoreML features to macos < 14 (#3255) 2025-06-24 09:24:27 +02:00
openvino whisper : reorganize source code + improve CMake (#2256) 2024-06-26 19:34:09 +03:00
CMakeLists.txt parakeet : add support for NVIDIA Parakeet (#3735) 2026-06-16 20:44:10 +02:00
parakeet-arch.h parakeet : add support for NVIDIA Parakeet (#3735) 2026-06-16 20:44:10 +02:00
parakeet.cpp parakeet : add support for NVIDIA Parakeet (#3735) 2026-06-16 20:44:10 +02:00
whisper-arch.h vad : add initial Voice Activity Detection (VAD) support (#3065) 2025-05-12 16:10:11 +02:00
whisper.cpp whisper : mask padded K/V in flash-attention encoder and cross-attention 2026-07-16 11:35:40 +02:00