Skip to content

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 into
1bit/hrx-vulkan-patchedfrom
fix/3383-alternate-value-alias
Nov 24, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
fix/3383-alternate-value-alias

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

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 whenever same_full_value_range() matched (storage, offset, byte_count only - dispatch/command-plan.h:94, :101, :124 at 39ed69b58). 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 row support.alternate_value_alias_lookup (tests/hrx-ops-test.cpp:769) asserts both and was known_fail_host_case at :9444.

The fix.

  • The fallbacks use 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 snapshot's only record of a write that reused the storage, so the fallback needs it.
  • The row leaves 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 39ed69b58 and at this branch with cmake --build build-oct13 --target hrx-ops-test test-hrx-ops -j 6:

tree hrx-ops-test --hrx-test-case support.alternate_value_alias_lookup
39ed69b58 FAIL tests/hrx-ops-test.cpp:854: requirement failed: through_reordered_alias == nullptr, exit 134
this branch pass, exit 0
full host tier 39ed69b58 this branch
hrx-ops-test 9 passed, 0 failed, 1 known-fail, 0 unexpected-pass, 10 total 10 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 10 total
test-hrx-ops (not run pre-fix) 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass

check_stale_expectations.py --check (engine#2774's row): 490 expectation literal(s), every one selectable by a registration; --self-test ok.

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 main a5b9a7e59, Oct 13), which has the same loomc link_index API 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 and registry/architectures.json regenerated by scripts/registry-regen.sh (its llama.cpp (hrx) source sha); no config/gpu-kernels.config move and no tools/ci/ctest_known_fail.txt change, since those are per-executable. Then engine#3383 can close.

Refs 1bit-MONSTER/engine#3383

🤖 Generated with Claude Code

… 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]>
@bong-water-water-bong
bong-water-water-bong merged commit c6c654c into 1bit/hrx-vulkan-patched Nov 24, 2026
@bong-water-water-bong
bong-water-water-bong deleted the fix/3383-alternate-value-alias branch November 24, 2026 08:17
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]>
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.

1 participant