Skip to content

GPU fixture for VOP3P neg_lo/neg_hi on v_dot4_i32_i8 (SHADER-1254) - #8239

Closed
kett1m wants to merge 1 commit into
ItsNotRexed:mainfrom
kett1m:fixture-dot4
Closed

kett1m wants to merge 1 commit into
ItsNotRexed:mainfrom
kett1m:fixture-dot4

Conversation

@kett1m

@kett1m kett1m commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as SHADER-1254.

Depends on: #7293, which translates the neg_lo/neg_hi fields; without it the translator refuses the instruction.

What and why

#7293 pins the hardware rule with semantic tests and spirv-val only: on S0/S1 neg_lo flips bit 15 and neg_hi bit 31, and on the addend neg_hi clears bit 31 before neg_lo flips it. There was no GPU fixture for the instruction at all, so the gfx1036 table stayed the only hardware evidence.

cs_dot4_neg.asm is one thread and eight stores: the plain dot, neg_lo and neg_hi on S1, both on S1, neg_lo and neg_hi on S0, the addend's neg_lo, and a clamp that saturates. check.py compares the eight words (DOT4_NEG), and the .asm header carries the derivation.

v_dot4_i32_i8 does not assemble for gfx1013, which every reader hardcoded, so a fixture can name its target with a ; mcpu: leading comment in all four places that assemble one: build.py, scripts/run_gpu_tests.py, tests/conftest.py and tests/test_rdna2_decode.py. The default stays gfx1013, so no existing fixture changes.

This reworks the first head, which junaydirfan showed would have broken run_gpu_tests.py and two pytest cases by teaching only build.py about the header. It also replaces the earlier attempt to stack on #7237, which has since gone conflicting: the header mechanism is duplicated here (the same idea, ; mcpu:), so this PR stands on main alone. Whichever of the two lands first, the other rebases.

Tested

With #7293 applied, on main 47428cc2:

  • build.py: 1 of 1 translated, 1 pass spirv-val; check.py gives cs_dot4_neg ok on an RTX 3090 (Linux, driver 620.70.06), with
    out[0..7] = 00000040 ffffff40 00000240 00000140 fffffd40 00000440 7fffffff 80000040, matching the header's derivation.
  • scripts/run_gpu_tests.py --filter cs_fma --build runtime/build/linux: the whole fixture set assembles (no llvm-mc failure) and the selected case passes.
  • python -m pytest tests/test_translate.py -k cs_dot4_neg: 2 passed.
  • python -m pytest tests/test_rdna2_decode.py: 1 failed, 15 passed, exactly as on main without this change (that failure is cs_w32_permlane_fi.asm's op_sel, unrelated).

Writing the derivation caught my own sign error in out[5]: S1's fourth byte is -8, so negating S0's fourth byte from 4 to -124 makes that product positive, 988, not -996.

AI-assisted: yes

@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), AMD Windows driver 32.0.32029.2010, Windows 11, with #7293's diff applied on top of this PR's head (91368c3):

build.py <out> cs_dot4_neg  -> 1 translated, 1 pass spirv-val
vk_compute_test cs_dot4_neg.spv 1 dump
device: AMD Radeon RX 7700 XT (subgroup 32..64)
out[0..7] = 00000040 ffffff40 00000240 00000140 fffffd40 00000440 7fffffff 80000040

All 8 words match DOT4_NEG, so a second vendor/driver agrees with the RTX 3090 run.

One gap: scripts/run_gpu_tests.py doesn't pick this fixture up. Its assemble_to_s (line 99) hard-codes -mcpu=gfx1013 and only reads ; mattr:, so --filter cs_dot4_neg fails in llvm-mc (instruction not supported on this GPU (gfx1013): v_dot4_i32_i8). Even with that fixed, there's no GPU test row for it there ("no runnable GPU test cases"). Either honouring ; mcpu: in assemble_to_s (or ; mattr: +dot1-insts, which also assembles it for gfx1013) and adding a row would cover the run_gpu_tests.py path too.

AI-assisted (Claude Code).

@kamilolejnik

Copy link
Copy Markdown

Tested 91368c3 with #7293 (24aa3a428) on Intel Iris Xe Graphics (TGL GT2, Xe-LP, subgroup 8..32), Mesa ANV 26.3.1, Vulkan 1.4.363, Linux 6.12 (Arch container), llvm-mc 23.1.5, SPIRV-Tools v2026.4: pass. Both were merged onto current main dde82f27e, clean merges. The first Intel run.

  • build.py <out> cs_dot4_neg, then check.py <out> <programs>: cs_dot4_neg ok, so all eight DOT4_NEG words match on ANV.
  • Note: scripts/run_gpu_tests.py --filter cs_dot4 runs nothing, because the fixture is registered in check.py only. If it's meant to run in the one-command runner too, it needs an entry in run_gpu_tests.py's wave32 dump list.

Synthetic fixture only, no game files. AI-assisted (Claude Code).

@tupacfan04 tupacfan04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixture and expected words are consistent, and the build.py/check.py path is integrated, but the standard GPU runner cannot assemble or run it.

  • runtime/test/shaders/build.py:86-102 adds asm_mcpu() and :173 applies the fixture's ; mcpu: gfx1030; check.py:205-210 defines DOT4_NEG and :1786-1789 runs it. The eight words, the plain-dot control, and the neg_lo/neg_hi cases are consistent.
  • scripts/run_gpu_tests.py:95-108 assemble_to_s() still hardcodes -mcpu=gfx1013 and only scans for ; mattr:. It ignores ; mcpu: gfx1030, so python -I scripts/run_gpu_tests.py --filter cs_dot4_neg fails in llvm-mc with v_dot4_i32_i8 unsupported on gfx1013.
  • Even with assembly fixed, run_gpu_tests.py does not import/register DOT4_NEG from check.py; there is no runnable case row, so the filter ends with no GPU test cases rather than executing the fixture. The auto-discovered .asm list only builds the shader; expected-word dispatch is separate.

Fix: make assemble_to_s() honor ; mcpu: (or accept ; mattr: +dot1-insts for gfx1013), and import/register DOT4_NEG in the run_gpu_tests.py compute cases with the same eight expected words, so --filter cs_dot4_neg assembles as gfx1030 and runs. The mcpu header does not change the existing gfx1013 default. Synthetic only; no game files. AI-assisted (OpenCode).

@junaydirfan

Copy link
Copy Markdown

Tested 91368c3d with #7293 (24aa3a42), both merged into main dde82f27 (clean), on Linux (CachyOS). The fixture is right, but merging this would break scripts/run_gpu_tests.py for everyone, and 2 pytest cases.

The fixture. build.py + check.py gives cs_dot4_neg ok on both an Intel Raptor Lake-S iGPU (Xe-LP) with Mesa ANV 26.3.1 and an RTX 4080 Laptop with NVIDIA 620.73.04.

The problem. The new ; mcpu: header is read only by build.py. Three other places still assemble every fixture with -mcpu=gfx1013:

reader on the merge
scripts/run_gpu_tests.py (assemble_to_s) RuntimeError: llvm-mc failed on cs_dot4_neg: ... instruction not supported on this GPU (gfx1013): v_dot4_i32_i8. The whole run stops with exit code 1 before running any test, not only with --filter cs_dot4.
tests/conftest.py (Shader) FAILED tests/test_translate.py::test_gpu_samples_translate_and_validate[cs_dot4_neg.asm] and ...::test_wave64_emulate_uses_no_subgroup_ops[cs_dot4_neg.asm]
tests/test_rdna2_decode.py (llvm-mc parity) hard-codes gfx1013 too. This test already fails on main for an unrelated op_sel reason, so it can't show this

#7237 (cs_global_csub) adds the same ; mcpu: header for the same reason (global_atomic_csub isn't on gfx1013), and it updates all four readers: build.py, run_gpu_tests.py (asm_target), tests/conftest.py and tests/test_rdna2_decode.py. Building on #7237 (Depends on: #7237) and dropping this PR's own asm_mcpu would fix all three, and avoid the two PRs conflicting in build.py.

@kett1m

kett1m commented Nov 23, 2026

Copy link
Copy Markdown
Author

Fixed by rebuilding on #7237 as you suggested: the branch is now #7237's head plus one commit that adds only cs_dot4_neg.asm and its DOT4_NEG row in check.py; my own asm_mcpu is gone.

Re-checked the three readers you listed:

  • scripts/run_gpu_tests.py --filter cs_fma --build runtime/build/linux: the whole fixture set assembles, including cs_dot4_neg, and the selected case passes.
  • python -m pytest tests/test_translate.py -k cs_dot4_neg: 2 passed (test_gpu_samples_translate_and_validate and test_wave64_emulate_uses_no_subgroup_ops).
  • check.py gives cs_dot4_neg ok on the RTX 3090.

Depends on: #7237 and #7293 are in the body, and it says the diff shows #7237's files with the fixture commit last.

… fixture header (SHADER-1254)

ItsNotRexed#7293 translates the neg_lo / neg_hi fields of v_dot4_i32_i8 to the rule measured on gfx1036, but only semantic tests
and spirv-val covered it. cs_dot4_neg.asm runs the same program on a GPU: one thread, eight stores, the plain dot,
neg_lo and neg_hi on S0 and S1, both, the addend's neg_lo, and a clamp that saturates.

v_dot4_i32_i8 does not assemble for gfx1013, which every reader hardcoded, so a fixture can now name its target with a
"; mcpu:" leading comment in all four places that assemble one: build.py, scripts/run_gpu_tests.py, tests/conftest.py
and tests/test_rdna2_decode.py. The default stays gfx1013. The same header is in ItsNotRexed#7237 for global_atomic_csub; this is
a duplicate of that mechanism, kept here so the fixture does not depend on an unmerged, conflicting branch.

Depends on: ItsNotRexed#7293.
@kett1m

kett1m commented Nov 23, 2026

Copy link
Copy Markdown
Author

Rebased onto current main 47428cc2 as a standalone change: the ; mcpu: header is now honoured by all four readers (build.py, scripts/run_gpu_tests.py, tests/conftest.py, tests/test_rdna2_decode.py), so the conflict with #7237 is gone from this branch and the PR depends only on #7293.

Re-checked: check.py cs_dot4_neg ok on the RTX 3090, run_gpu_tests.py --filter cs_fma assembles the whole set and passes, pytest -k cs_dot4_neg 2 passed, and tests/test_rdna2_decode.py has the same single unrelated op_sel failure as main.

@pmaho

pmaho commented Nov 23, 2026

Copy link
Copy Markdown

Independent RDNA4 check on Linux (RADV, Navi 48), run on head 8065ce54d.

Result: the ; mcpu: header from my earlier report is now present, and the fixture assembles. The compute suite now runs to completion: 107/112 passed, 4 skipped, 1 failed (cs_dot4_neg).

Cause of the failure: the translator refuses neg_lo/neg_hi on v_dot4_i32_i8 on purpose. tools/rdna2spirv.py lines 11551-11552:

if any(m.startswith(("neg_lo", "neg_hi")) and "1" in m.split(":", 1)[-1] for m in mods):
    raise Unsupported(op + " neg")

The comment just above it says "A set bit is refused". The build log shows the same thing: v_dot4_i32_i8 neg, then "Translation did not produce validated SPIR-V for: cs_dot4_neg". So the fixture tests exactly the case the translator rejects, and it cannot pass until neg is implemented or the fixture is changed.

Verified:

  • llvm-mc -mcpu=gfx1036 assembles the fixture (rc=0).
  • The translator reaches the neg check and stops there.

Not verified: whether the neg semantics in the comment (bit 15 / bit 31 flips) are correct. Checking that needs the hardware oracle or the test that pins it (tests/semantic/test_dot4_i8_neg.py), which I did not run.

Environment: AMD Radeon RX 9070 XT (RADV GFX1201), Linux. Command: VK_LOADER_LAYERS_DISABLE="~implicit~" python3 -I scripts/run_gpu_tests.py --build <build> --filter cs_.

AI-assisted (Claude). Reviewed and posted by the author.

@justrealyme

Copy link
Copy Markdown

Tested 8065ce5 with #7293 (24aa3a4) merged on top (clean merge) on NVIDIA GeForce RTX 5070 Ti (Blackwell), driver 617.42, Windows 11 build 26300, Vulkan SDK 1.4.363.0, conda-forge llvm-mc 23.1.6, CPython 3.12.9: pass, the first NVIDIA Blackwell result here.

  • build.py <out> cs_dot4_neg: 1 translated, 1 passes spirv-val.
  • vk_compute_test cs_dot4_neg.spv 1 dump: 0 mismatches, out[0..7] = 0x40 0xFFFFFF40 0x240 0x140 0xFFFFFD40 0x440 0x7FFFFFFF 0x80000040, the exact words of DOT4_NEG in check.py.
  • scripts/run_gpu_tests.py --filter cs_fma: the whole fixture set assembles (no llvm-mc failure on cs_dot4_neg) and cs_fma_fused passes, 1/1.

(The earlier head 91368c3 still crashed run_gpu_tests.py with llvm-mc failed on cs_dot4_neg here; this head fixes it.)

Synthetic test only, no game files. AI-assisted (Claude Code).

@Raxstreams

Copy link
Copy Markdown

@kett1m, the independent GPU runs on #8259 flagged that our fixtures cover much of the same signed-byte dot rule. Your clamp saturation check and #8259's combined addend-sign check each catch something distinct. Could we land one fixture with both checks and run it through both GPU runners?

I suggest adding your clamp check to #8259 with credit. Its existing fixture runs through both runners using the +dot1-insts header. If you'd prefer #8239 as the landing PR, I can help carry over the combined addend-sign check and register it in the one-command runner. Both options retain the #7293 dependency. Thanks for the fixture and the cross-GPU testing. AI-assisted (Codex).

@NiHuShu

NiHuShu commented Nov 23, 2026

Copy link
Copy Markdown

AI-assisted comparison with #8259. CachyOS x86-64, CPython 3.14.10, LLVM 23.1.5, GeForce RTX 4080 / NVIDIA 620.70.06, 32-wide, validation on. Exact fixture heads 8065ce54d3c1637fb84aacb1b9aa433d6a56d0d8 and 098231c21b1adfc3f475c9043e9cd336ba496b74. For a like-for-like comparison, both disposable trees used the same prerequisite translator from #7293 24aa3a4286af3cd72856a69aa2e12e3a055ebf53 and the same Vulkan binary. All inputs were synthetic.

python -I runtime/test/shaders/build.py /work <fixture> followed by vk_compute_test <spv> 1 dump, comparing all eight readback words to each fixture’s own check.py oracle. Each local translator change was applied separately. The table gives mismatching word indices, starting at 0.

Translator #8239 cs_dot4_neg #8259 cs_dot4_i8_neg
Prerequisite unchanged / restored all 8 exact both times all 8 exact both times
Ignore signed-dot saturation 6 all exact
Omit the addend’s neg_hi-only clear all exact 5
Toggle the addend sign when both modifiers are set all exact 7

All ten modules passed spirv-val, all ten Vulkan dispatches exited 0, zero skips. The two fixtures catch different wrong outputs.

I also ran python -I scripts/run_gpu_tests.py --build /build --work /work --filter <fixture> --require-pass. This PR alone exited 1 on the missing prerequisite. With #7293’s translator it translated and validated but exited 2 because cs_dot4_neg has no runnable GPU test row. The alternative’s unmodified head exited 0, 1/1 pass. The eight-word comparisons above used real dispatches in all cases.

@kett1m

kett1m commented Nov 23, 2026

Copy link
Copy Markdown
Author

Note for whoever merges: #8259 (SHADER-1258) adds a second fixture for the same instruction, opened shortly after this one. Its head does not touch build.py, so build.py cannot assemble its cs_dot4_i8_neg.asm for gfx1013 and its check.py row cannot run; this PR has the ; mcpu: header support in all four readers. Either is fine with me: if #8259 is preferred, take the three reader changes from here or from #7237 and close this.

@kett1m

kett1m commented Nov 23, 2026

Copy link
Copy Markdown
Author

Closing in favour of #8259. Raxstreams proposed one fixture with both checks, and their header (; mattr: ... +dot1-insts) assembles v_dot4_i32_i8 on gfx1013 with machinery build.py already has, so my ; mcpu: support was unnecessary for this fixture. I asked them to carry the clamp saturation case (0x7f7f7f7f * 0x7f7f7f7f + 0x7fffffff -> 0x7fffffff) into #8259 with credit.

@kett1m kett1m closed this Nov 23, 2026
Raxstreams pushed a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
Clamp case adapted from kett1m in ItsNotRexed#8239. Local candidate for fixture consolidation.
@Raxstreams

Copy link
Copy Markdown

@kett1m The consolidated fixture is up on #8259 at 919a7b500, with credit and the validation results in the PR description. It keeps both the saturation and combined addend-sign checks in the eight-word readback, and both runner paths pass. Thanks for coordinating. AI-assisted (Codex).

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.

9 participants