Repository navigation
hrx: the Q8_1 alternate-value fallback kept the alias source's row shape - an ordered reshape takes the requested value's rows (engine#3380) - #508
Merged
bong-water-water-bong merged 1 commit intoNov 24, 2026
Conversation
This was referenced Nov 24, 2026
…ape - an ordered reshape takes the requested value's rows (engine#3380) **engine#3380**: the split-FA device rows regressed at 6164e5b; fork #503 (c6c654c) is the cause. **The defect.** #503 made the alternate-value fallback compare layouts, not just full value ranges. The Q8_1 branch took same_q8_1_x4_geometry(lhs, rhs), which requires *both* values' ne[0] to be 128-aligned (ggml/src/ggml-hrx/dispatch/command-plan.h:91). The alias source's ne[0] is its own shape, not the row width the x4 copy was written with. A split-FA output is [value_head_size, heads, tokens] and the o_proj consumer reads ggml_reshape_2d(output, hidden_size, tokens); with value_head_size 64 the source's ne[0] is 64, so find_alternate_value() refused the alternate published for the FA output and returned nullptr. The row's q8_alternate != nullptr failed, and for the 4-query row the plan also lost its q8 next-projection dispatch (fewer than query_token_count + 1 dispatches). At head size 128 the source's ne[0] is 128 and the same lookup passed, which is why only the head96/value64 rows broke. **The fix.** The Q8_1 x4 rows are the *requested* value's rows: that is the row width the reader and the publisher use, and the alternate's byte_count is the same ordered range either way. q8_1_x4_rows_compatible() keeps the ordered-range requirement - storage, offset, byte_count, type, element count and contiguity all equal, so a transposed view or a write's storage is still refused exactly as #503 requires - and checks the 128-element row alignment on the requested value. The two rows move to the host tier. Like the attention-output rows #506 moved, they build a graph and read the plan back and never open a device; as device cases nothing could see this regression on a host, and the pre-fix tree fails them on a host (both asserts reproduce, see the Evidence section). Refs 1bit-MONSTER/engine#3380 Refs 1bit-MONSTER/engine#3383
bong-water-water-bong
force-pushed
the
fix/3380-alternate-value-ordered-reshape
branch
from
November 24, 2026 12:05
9c2c2de to
f39a6c1
Compare
bong-water-water-bong
deleted the
fix/3380-alternate-value-ordered-reshape
branch
November 24, 2026 12:05
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.
engine#3380 / engine#3383: the split-FA head96/value64 device rows regressed at 6164e5b. Fork #503 (c6c654c) is the cause: its Q8_1 layout comparison reads the alias source's row shape, and a split-FA alias source is shaped by its head size, not by the packed row width.
The defect
PR #503 replaced the alternate-value fallback's full-range comparison with layout comparison. For Q8_1 it calls
same_q8_1_x4_geometry(lhs, rhs), which requires both values' ne[0] to be 128-aligned
(ggml/src/ggml-hrx/dispatch/command-plan.h:91 at 6164e5b).
The rows build one token of split flash attention, then read the published Q8_1 x4 alternate through the consumer's
view of the output:
[value_head_size, heads, tokens] = [64, 32, 1]
(ggml/src/ggml-hrx/dispatch_registration/common/dispatch-flash-attention.cpp:703);
(tests/hrx-ops-test.cpp:5398).
The reshape is a pure ordered range over the same bytes (contiguous, same storage/offset/byte_count/type/element
count). The alias source's ne[0] is 64, so same_q8_1_x4_geometry() is false even though the requested value's rows are
2048 elements (128-aligned), and find_alternate_value() returns nullptr. At the default head size 128 the source's
ne[0] is 128, so the identical lookup passes: that is why only ...masked.head96.value64 broke.
At the pin this shows up as both device failures reported by lane-dv2:
(the 4-query row loses its q8 next-projection dispatch, so it fails the plan-size assert first).
The fix
A Q8_1 x4 copy carries the requested value's rows - that is the row width the reader and the publisher both use, and
the alternate's byte_count is the same ordered range either way. q8_1_x4_rows_compatible() keeps the ordered-range
requirement (storage, offset, byte_count, type, element count, contiguity all equal, so a transposed view and a
write's storage are still refused exactly as #503 requires) and checks the 128-element row alignment on the requested
value instead of the alias source.
The two rows move to the host tier. Like the attention-output rows #506 moved, they build a graph and read the plan
back and never open a device; as device cases no host run could see this, and the pre-fix tree fails them on a host.
Cause proof: a plain #503 revert is not the fix
Rebuilt the fork at 6164e5b in a throwaway tree with ggml/src/ggml-hrx/dispatch/command-plan.h moved back to its
pre-#503 content (c6c654c^), same configure (add-on, -j 6):
So the regression is #503's comparator, but reverting #503 re-opens engine#3383. This change keeps both green.
Control: pre-fix vs this branch, host tier (device-free, CI-reachable)
Both trees are the same source and the same host-tier registration of the two rows.
Device evidence (gfx1151, one box-hold both ticket, as root)
Built with the recipe the pinned device builds use (add-on, ggml-hrx, gfx1151, CMAKE_PREFIX_PATH=hrx-install); ran with
the pin's runtime libs from the staged package (pkg/hrx/llama/bin), box env HRX_ALLOW_NO_SVM=1 etc. The 23-Nov build
needed libomp from that same package dir in LD_LIBRARY_PATH.
Full add-on device suite on this branch: 409 passed, 1 failed, 1 known-fail, 411 total (the pin is 407 / 3 / 1).
The one remaining failure is mixed_weight_layout_program.q6_k, which is engine#3389's row and unrelated to this
change: it asks for a packed Q6_K decode on a weight imported from a host pointer (a device buffer with no repackable
source), and the real device plan binds it stored. No GPU reset during the ticket (dmesg).
Logs on strixhalo: /data/dev/cl-hrxtest/runs/fa.status, fa-old23-p6a.log, fa-new6164-6164a.log, fa-own-clean.log,
fa-own-fix.log, fa-own-fix-full.log; local host-tier logs are in the lane's scratch.
Refs 1bit-MONSTER/engine#3380
Refs 1bit-MONSTER/engine#3383