Skip to content

yue2: eager NAR attention on Intel Vulkan - #557

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
engival:intel-vulkan-yue2-attention
Sep 15, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
engival:intel-vulkan-yue2-attention

Conversation

@engival

@engival engival commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

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|eager session option and an additive vulkan_device_is_intel() probe; auto picks eager for the NAR only when the Vulkan device is Intel. The shared resolve_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 flash is byte-identical to the previous output; eager vs flash on the same seed is 36 dB.

…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.
@0xShug0
0xShug0 merged commit 6d4703e into 0xShug0:main Sep 15, 2026
6 checks passed
@0xShug0

0xShug0 commented Sep 15, 2026

Copy link
Copy Markdown
Owner

@engival Appreciate the optimization for Intel GPUs. PR merged!

@engival
engival deleted the intel-vulkan-yue2-attention branch September 21, 2026 18:03
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.
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.

2 participants