Repository navigation
hrx: the alternate-value fallback took a transposed view or a write's storage - it takes only a full ordered layout alias (engine#3383) - #503
Merged
bong-water-water-bong merged 1 commit intoNov 24, 2026
Conversation
… storage - it takes only a full ordered layout alias (engine#3383) find_alternate_value(graph, plan, ...) falls back from the requested value to an alternate published for another value, and took it whenever same_full_value_range() matched: storage, offset and byte_count only (dispatch/command-plan.h:94, :101, :124 at 39ed69b). That accepted - a transposed view (contiguous = false) of the source, although its bytes are permuted, and - a value whose producer writes the storage (CPY, SET_ROWS), whose bytes are the writer's, not the source's. Both are a kernel reading a copy that does not hold the value it thinks it holds. - The fallbacks now compare with the ordered layout comparators that were only on AMD's generated-resource path: alternate_value_layout_compatible() picks the geometry the alternate's reader needs - F16: the full ordered range; Q8_1: the x4 128-element rows; every other format: the packed rows. A pure reshape over the same ordered bytes still takes the alternate. - A value whose producer is not a layout alias is refused outright, and the alias walk stops at a value its own producer wrote. The graph index is the only record of a write that reused the storage, so the fallback needs it. - support.alternate_value_alias_lookup (tests/hrx-ops-test.cpp:769) leaves known_fail_host_case and is a host_case now. - tests/test-hrx-ops.cpp's arm builds the same graph without producer nodes; it adds the VIEW/RESHAPE nodes and the index, which is what the provenance check reads. Evidence (host tier, no device needed): - At 39ed69b, hrx-ops-test --hrx-test-case support.alternate_value_alias_lookup fails at "tests/hrx-ops-test.cpp:854: requirement failed: through_reordered_alias == nullptr", exit 134; with this change it exits 0. - Full host tier at 39ed69b: 9 passed, 0 failed, 1 known-fail, 0 unexpected-pass, 10 total. With this change: 10 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 10 total. - test-hrx-ops host tier with this change: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass. - check_stale_expectations.py --check: 490 expectation literal(s), every one selectable; --self-test ok. The target was built on this box against the installed hrx/loomc snapshot (AMD main a5b9a7e59, Oct 13): no build of the engine's hrx-system pin (7f423692) is installed here, and the two share the loomc link_index API this target uses. The case is header-only and never enters libhrx/libloomc; the suite's device rows are skipped without a GPU either way. Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Nov 24, 2026
bong-water-water-bong
pushed a commit
that referenced
this pull request
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
added a commit
that referenced
this pull request
Nov 24, 2026
…ape - an ordered reshape takes the requested value's rows (engine#3380) (#508) **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 Co-authored-by: bong-water-water-bong <[email protected]>
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#3383: the alternate-value fallback reads a copy only through a full ordered layout alias.
The defect.
find_alternate_value(graph, plan, ...)falls back from the requested value to an alternate published for another value, and took it wheneversame_full_value_range()matched (storage, offset, byte_count only -dispatch/command-plan.h:94, :101, :124at39ed69b58). That accepted a transposed view (contiguous = false) and a value whose producer writes the storage (CPY,SET_ROWS): a kernel then reads a copy that does not hold the value it thinks it holds. The rowsupport.alternate_value_alias_lookup(tests/hrx-ops-test.cpp:769) asserts both and wasknown_fail_host_caseat:9444.The fix.
alternate_value_layout_compatible()picks the geometry the alternate's reader needs - F16: the full ordered range; Q8_1: the x4 128-element rows; every other format: the packed rows. A pure reshape over the same ordered bytes still takes the alternate.known_fail_host_case.tests/test-hrx-ops.cpp's arm builds the same graph without producer nodes; it now adds the VIEW/RESHAPE nodes and the index that the provenance check reads.Control (host tier, no device needed; the "HRX runtime did not initialise" line in the log is the box having no HRX device, and the host case runs anyway). Built at
39ed69b58and at this branch withcmake --build build-oct13 --target hrx-ops-test test-hrx-ops -j 6:hrx-ops-test --hrx-test-case support.alternate_value_alias_lookup39ed69b58tests/hrx-ops-test.cpp:854: requirement failed: through_reordered_alias == nullptr, exit 13439ed69b58hrx-ops-testtest-hrx-opscheck_stale_expectations.py --check(engine#2774's row): 490 expectation literal(s), every one selectable by a registration;--self-testok.Build provenance. The box has no build of the engine's hrx-system pin (
7f423692), so the target linked the installed hrx/loomc snapshot (AMD maina5b9a7e59, Oct 13), which has the same loomclink_indexAPI this target uses. The case is header-only and never enters libhrx/libloomc; the device rows are skipped without a GPU either way.Follow-up (engine side, not this PR): the pin bump carries
third_party/llama.cpp-> this merge andregistry/architectures.jsonregenerated byscripts/registry-regen.sh(itsllama.cpp (hrx)source sha); noconfig/gpu-kernels.configmove and notools/ci/ctest_known_fail.txtchange, since those are per-executable. Then engine#3383 can close.Refs 1bit-MONSTER/engine#3383
🤖 Generated with Claude Code