Repository navigation
yue2: eager NAR attention on Intel Vulkan - #557
Merged
Merged
Conversation
…option ggml-vulkan's flash-attention kernels lose to the eager matmul+softmax lowering on Intel GPUs. On an Arc Pro B70 the Yue2 NAR drops from 275 s to 126 s (song wall 354 s -> 205 s, 32 ODE steps, 4226 semantic tokens). - add --session-option yue2.attention=auto|flash|eager (same pattern as higgs_audio_tts / breeze_tts) - add additive engine::core::vulkan_device_is_intel(); resolve_flash_attention() itself is unchanged, so no other family's behaviour moves on any backend - yue2 pipeline: auto drops to eager on Intel Vulkan; explicit modes bypass - NAR gets a GPU eager lowering using ggml_mul_mat's GQA head broadcast (no F16 ggml_repeat, which ggml-vulkan lacks); AR stays on flash (measured 1.75 s -> 7.7 s CFG decode when switched) Explicit flash is byte-identical to the previous output; eager vs flash on the same seed is 36.1 dB.
Owner
|
@engival Appreciate the optimization for Intel GPUs. PR merged! |
engival
added a commit
to engival/audio.cpp
that referenced
this pull request
Sep 22, 2026
The eager lowering (0xShug0#557; the auto choice on Intel Vulkan and Volta/Turing CUDA) holds the whole score matrix in one graph tensor: query steps x kv steps x heads x 4 bytes, quadratic in song length. A 243 s song (6075 frames) needs a single 5.6 GB tensor; Intel and RADV cap one buffer at 4 GiB, so the run died with "failed to allocate Yue2 NAR graph" after the whole AR stage. A song is one NAR chunk up to ~11k frames, where the matrix would be 16 GiB. 0xShug0#557 was validated on 8.8 s and 169 s renders; at 169 s the matrix is about half the size and fit, so the limit was never reached in testing. The query rows are now computed in balanced tiles, as few as keep one tile's scores under 3 GiB, and joined in order so the allocator reuses one tile's memory for the next. Softmax is per query row, so the result is exact: renders are bit-identical at every tiling tested. A song whose scores already fit is one tile and builds the same graph as before. Each query slice is made contiguous first: a row-sliced view keeps the full head stride, and ggml-vulkan's batched mul_mat reads it as packed. yue2.attention_tile_rows (session option, 0 = auto) forces a tile size; yue2.nar.graph.buffer_bytes and yue2.nar.graph.attention_tiles are logged with the other NAR graph scalars. The flash and CPU paths are unchanged.
0xShug0
pushed a commit
that referenced
this pull request
Sep 22, 2026
…642) The eager lowering (#557; the auto choice on Intel Vulkan and Volta/Turing CUDA) holds the whole score matrix in one graph tensor: query steps x kv steps x heads x 4 bytes, quadratic in song length. A 243 s song (6075 frames) needs a single 5.6 GB tensor; Intel and RADV cap one buffer at 4 GiB, so the run died with "failed to allocate Yue2 NAR graph" after the whole AR stage. A song is one NAR chunk up to ~11k frames, where the matrix would be 16 GiB. #557 was validated on 8.8 s and 169 s renders; at 169 s the matrix is about half the size and fit, so the limit was never reached in testing. The query rows are now computed in balanced tiles, as few as keep one tile's scores under 3 GiB, and joined in order so the allocator reuses one tile's memory for the next. Softmax is per query row, so the result is exact: renders are bit-identical at every tiling tested. A song whose scores already fit is one tile and builds the same graph as before. Each query slice is made contiguous first: a row-sliced view keeps the full head stride, and ggml-vulkan's batched mul_mat reads it as packed. yue2.attention_tile_rows (session option, 0 = auto) forces a tile size; yue2.nar.graph.buffer_bytes and yue2.nar.graph.attention_tiles are logged with the other NAR graph scalars. The flash and CPU paths are unchanged.
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.
Why: ggml-vulkan's flash-attention kernels are slower than the plain matmul+softmax path on Intel GPUs, so the Yue2 NAR was spending most of the song on a losing kernel.
How: Adds a
yue2.attention=auto|flash|eagersession option and an additivevulkan_device_is_intel()probe;autopicks eager for the NAR only when the Vulkan device is Intel. The sharedresolve_flash_attention()is untouched, so no other model family or backend changes behaviour, and the AR stays on flash (eager measured 4x slower there).Result: On an Arc Pro B70 (cot=full, 32 ODE steps) the NAR drops from 275 s to 126 s and song wall time from 354 s to 205 s. Explicit
flashis byte-identical to the previous output; eager vs flash on the same seed is 36 dB.