Repository navigation
ggml-hrx: no V transpose for MLA strided V (GLM-4.7-Flash prompts >= 512 tokens: PPL 315,664 -> 5.92) - #70
Merged
bong-water-water-bong merged 1 commit intoOct 2, 2026
Conversation
…= 512 tokens) prepare_flash_attention_value transposes V with ggml_copy_transpose_f16 once a prompt batch has >= 256 queries and >= 512 KV rows. That kernel reads `kv_heads x value_head_size`-wide contiguous rows, but MLA (deepseek2/GLM) stores V with the QK head-size stride, the layout the prefill matcher accepts since #95: 576 elements per row, of which V is the first 512. The transpose then read misaligned rows and attention used the wrong values. A V whose rows aren't contiguous now keeps the row-major layout; that kernel takes the real row stride (value->nb[1]). GLM-4.7-Flash Q4_K_M, llama-perplexity -c 512 -b 512, 4 chunks (transpose path): HRX0 before PPL 315,664 +/- 40,417 HRX0 after PPL 5.9160 +/- 0.479 CPU PPL 5.9592 +/- 0.484 Non-MLA models have contiguous V rows and keep the transpose: Qwen3.8-27B-Q4_0-H32 PPL 5.8714 before and after (4 chunks). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Review (PR-Agent duty): approve. This is a minimal guard (+5/-1) in AMD's flash-attention dispatch: the V transpose path is taken only when V rows are contiguous ( |
bong-water-water-bong
merged commit Oct 2, 2026
6339066
into
1bit/hrx-vulkan-patched
10 of 24 checks passed
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.
ggml-hrx: no V transpose for MLA's strided V (GLM-4.7-Flash prompts >= 512 tokens)
prepare_flash_attention_value transposes V with ggml_copy_transpose_f16
once a prompt batch has >= 256 queries and >= 512 KV rows. That kernel
reads
kv_heads x value_head_size-wide contiguous rows, but MLA(deepseek2/GLM) stores V with the QK head-size stride, the layout the
prefill matcher accepts since #95: 576 elements per row, of which V is the
first 512. The transpose then read misaligned rows and attention used the
wrong values. A V whose rows aren't contiguous now keeps the row-major
layout; that kernel takes the real row stride (value->nb[1]).
GLM-4.7-Flash Q4_K_M, llama-perplexity -c 512 -b 512, 4 chunks
(transpose path):
HRX0 before PPL 315,664 +/- 40,417
HRX0 after PPL 5.9160 +/- 0.479
CPU PPL 5.9592 +/- 0.484
Non-MLA models have contiguous V rows and keep the transpose:
Qwen3.8-27B-Q4_0-H32 PPL 5.8714 before and after (4 chunks).
🤖 Generated with Claude Code