Skip to content

tests: GPU readback for the binary64 vector compares, v_cmp_*_f64 and v_cmpx_*_f64 (GPU-CMP-F64) - #1012

Merged
aslan2142 merged 2 commits into
ProjectLeonida:mainfrom
milk4sale:gpu-test/cmp-f64
Nov 24, 2026
Merged

aslan2142 merged 2 commits into
ProjectLeonida:mainfrom
milk4sale:gpu-test/cmp-f64

Conversation

@milk4sale

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: GPU-CMP-F64 (#14 (comment))

What and why

The v_cmp_*_f64, v_cmpx_*_f64 row of docs/design.md is CPU-checked and measured on native gfx1100, and said Not GPU-verified: no fixture in runtime/test/shaders used a binary64 compare, so the SPIR-V those 32 ops translate to (an ordering built from 32-bit integer ops, no Float64) had not run on a driver.

This adds cs_w32_cmp_f64, a memory-fed fixture in the style of cs_w32_shift64 (#590):

  • check.py seeds 256 operand pairs through VKC_HEAP_INIT: the product of 16 values (±inf, ±max, the 1-ULP neighbours of ±1, the smallest subnormals, ±0, the smallest normal, a NaN whose payload is only in the low dword, a negative quiet NaN). Each of 128 threads loads two pairs at run time, so neither the translator nor the driver can fold a compare.
  • Per pair a thread stores a v_cmp_ word (through VCC) and a v_cmpx_ word (through EXEC): bits 0..15 are the 16 predicates in opcode order, bit 16 is tru run with the odd threads turned off (an inactive lane gets VCC 0 from v_cmp_ and stays off through v_cmpx_), bits 17 and 18 are lt and nge with VOP3 abs/neg.
  • The expected words come from Python floats (cmp_f64_words). Both GPU runners compare all 1536 heap words, the 1024 unchanged input words included.
  • tests/test_gpu_cmp_f64.py needs no GPU: it checks the oracle against an independent restatement of the 16 predicates, a few words worked out by hand, that the assembly gives every predicate the oracle's bit, and the readback and runner verdicts against a fake harness. tests/test_shader_checks.py counts and fakes the new case.
  • docs/testing.md describes the fixture and the contract row names it.

No translator or runtime change. The SGPR-pair and constant operand forms are not in the fixture; they stay CPU-checked by tests/semantic/test_cmp_f64.py.

Tested

At this head (50407827c on main 82a2aabcc), test programs rebuilt at this head, llvm-mc 23.1.4, SPIRV-Tools v2026.4:

  • python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_cmp_f64 --require-pass on the RTX 4070 Ti: PASS natively and with LEONIDA_W64_EMULATE=1 ("1536 words exact").
  • The same on llvmpipe (subgroup 8..8): PASS. The runner asks for 32-wide subgroups, the device says "not available", and the words are exact, so no step of the fixture depends on the subgroup width.
  • python -I tests/test_gpu_cmp_f64.py (9 tests), tests/test_shader_checks.py (87), tests/test_run_gpu_tests.py (64), tests/test_gpu_shift64.py, tests/test_docs_design_rows.py, tests/test_docs_links.py, tests/test_docs_repo_paths.py, tests/test_text_write_line_endings.py, tests/test_regen_fixtures.py: OK. python -m compileall -q make_game.py tools tests and scripts/check_no_game_data.py on the changed files: OK.

Before the rebase (the same change on main 42d705c85):

  • Negative controls on the RTX 4070 Ti, one translator rule broken at a time and the fixture rebuilt; each failed at the word the oracle predicts: no -0 canonicalization (word 206), a NaN test that ignores the low dword (28), an ordering key without the low dword (70), the raw result written to an inactive lane's VCC (2), v_cmpx_ replacing EXEC instead of narrowing it (3), abs ignored (0), nlt lowered as the negation of le (0).
  • Full run_gpu_tests.py on the RTX 4070 Ti: 260 shaders, 260 translated, 260 pass spirv-val; native 200/251 passed, 49 skipped, 2 failed; LEONIDA_W64_EMULATE=1 232/251 passed, 17 skipped, 2 failed. The two failures are cs_imgload_tfe and cs_imgload_d16_tfe, already recorded for this GPU in gpu-test-results/RTX4070Ti.txt.
  • Every standalone standard-library test file (490): all pass except tests/test_tool_stdout_encoding.py, which fails the same way without this change (tools/native_pso_hashes.py; native_pso_hashes: stdout gets the errors=replace guard (NATIVE-PSO-HASHES-HELP) #883 and native_pso_hashes: guard stdout like every other tool #948 are open for it).

Not run: llvm-mc 19, which the linux-gpu-tools job assembles with (not installed here); the translator suite (nothing under tools/ or tests/semantic/ changes); Windows; AMD hardware. The 4070 Ti run checks the translated SPIR-V on a driver against IEEE-754. What ties the predicates to RDNA2 is the row's native gfx1100 measurement, which this does not repeat.

GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS, kernel 7.3.3); Mesa llvmpipe 26.2.6 (LLVM 23.1.4), same machine

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No new rule; the existing row now names the fixture.)

🤖 Generated with Claude Code

… v_cmpx_*_f64 (GPU-CMP-F64)

The v_cmp_*_f64 / v_cmpx_*_f64 row of docs/design.md was CPU-checked and measured on native gfx1100, and no
fixture in runtime/test/shaders used a binary64 compare, so the SPIR-V those 32 ops translate to had not run on a
driver.

cs_w32_cmp_f64 is memory-fed, like cs_w32_shift64: check.py seeds 256 operand pairs, the product of 16 values
(+-inf, +-max, the 1-ULP neighbours of +-1, the smallest subnormals, +-0, the smallest normal, a NaN whose payload
is only in the low dword, a negative quiet NaN), and each of 128 threads loads two of them at run time. Per pair it
stores a v_cmp_ word (through VCC) and a v_cmpx_ word (through EXEC): one bit per predicate in opcode order, a bit
for tru run with the odd threads turned off (an inactive lane gets VCC 0 and stays off through v_cmpx_), and two
bits for lt and nge with VOP3 abs/neg. The expected words come from Python floats. Both GPU runners compare all
1536 heap words, the unchanged inputs included.

tests/test_gpu_cmp_f64.py checks, without a GPU, the oracle against an independent restatement of the 16
predicates, a few words worked out by hand, that the assembly gives every predicate the oracle's bit, and the
readback and runner verdicts. docs/testing.md describes the fixture and the row names it.

No translator or runtime change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@KernelSmoker KernelSmoker 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.

Verified on exact head 5040782. The focused CPU suites pass: f64 compare oracle 9/9, shader checks 87/87, GPU runner 64/64, design contract rows 5/5, docs links 16/16. Changed-file no-game-data and git diff --check pass. The independent runtime GPU execution reported in the PR is on an RTX 4070 Ti and llvmpipe; I did not independently reproduce a GPU run here. The host RTX 3090 is present, but no fixture harness is built locally and only 72 MB disk space was free, so an honest 3090 run was not feasible. No game data used.

@veqzo

veqzo commented Nov 24, 2026

Copy link
Copy Markdown

Tested PR head 50407827cd2cb73313c585cdf3d3d40ed7918bae on Windows with an NVIDIA GeForce GTX 1080 and driver 582.78.

  • cs_w32_cmp_f64: PASS, 1,536 words matched.
  • The same test with LEONIDA_W64_EMULATE=1: PASS, 1,536 words matched.
  • The generated SPIR-V passed spirv-val in both runs.
  • tests/test_gpu_cmp_f64.py: 9 tests passed.

Tools: LLVM 23.1.6 and SPIR-V Tools 2026.4. The GPU test programs were built from the same PR revision.

AI-assisted testing.

@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

AMD run (the "AMD hardware" gap): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11. Head 50407827c, scripts/run_gpu_tests.py --filter cs_w32_cmp_f64 with the test programs of a current main build.

  • cs_w32_cmp_f64: PASS, 1536 words exact (256 operand pairs and unchanged inputs), native (subgroup 64) and with LEONIDA_W64_EMULATE=1.

@milk4sale

Copy link
Copy Markdown
Contributor Author

The two red checks on this pull request come from the base it was tested against, not from the change. The run tested head 50407827c merged into main at 82a2aabcc, which was itself red on both jobs:

In the same llvmpipe run this pull request's own fixture passed: cs_w32_cmp_f64 1536 words exact, and the job ended at 171/253 passed, 80 skipped, with only those two failures.

I have not pushed to re-run CI: the Runtime queue is several hours behind, and #1034 and #1047 are stacked on this branch. (Comment written with AI assistance from the job logs.)

Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@aslan2142
aslan2142 merged commit 6558d53 into ProjectLeonida:main Nov 24, 2026
4 of 5 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator

Merged. Checked locally on main 28a32e190 + d366ee248:

  • Claim: valid. GPU-CMP-F64 was posted at 16:25 UTC, before this PR, and is unedited.
  • The expected values hold up: cmp_f64_words agrees with a separate model that orders by integer keys, with 0 mismatches in 512 result words. By hand: −0 against +0 is eq, the smallest subnormal is gt +0, and both NaNs are unordered on every predicate.
  • GPU, with main's translator: cs_w32_cmp_f64 passes with all 1,536 words exact on llvmpipe (Mesa 26.3.1) and on an RDNA2 iGPU (RADV). The neighbouring cs_w32_ cases: 13 passed and 8 skipped for subgroup width on llvmpipe, 21 of 21 on the iGPU.
  • On the merge: the semantic suite passes (474 files, 6,194 tests, 0 files failed); test_gpu_cmp_f64, test_run_gpu_tests, test_shader_checks pass; the 13 docs and writer tests pass; check_no_game_data.py is clean on the 7 changed files.
  • CI had not finished on this head, so the merge rests on the runs above and on the reports here (a GTX 1080 and an RX 9070 XT, both passing).

#1039's cs_w32_vcmp_f64 covers the same row; as that PR says itself, it can drop the row now. #1034, #1047 and #1063 build on this one and follow.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
… with ProjectLeonida#1012 merged

Takes the updated head of ProjectLeonida#1034's branch, which holds main 6558d53 (ProjectLeonida#1012, GPU-CMP-F64, is merged there). Git merged
it without conflicts (git merge-tree, exit 0), and the tree is the one a direct merge of main gives. GitHub had
reported a conflict since ProjectLeonida#1012 merged, with the branch and main on two merge bases (68d1331 and 5040782). Merging
ProjectLeonida#1034's head instead of main leaves this branch with one merge base with main when ProjectLeonida#1034 merges.

The merged tree was tested before the push: every standalone test file under tests/ passes except
tests/test_ci_registration.py, which fails on main 6558d53 alone (ProjectLeonida#1365 fixes it).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
…ProjectLeonida#1012 merged

Takes the updated head of ProjectLeonida#1034's branch, which holds main 6558d53 (ProjectLeonida#1012, GPU-CMP-F64, is merged there). Git merged
it without conflicts (git merge-tree, exit 0), and the tree is the one a direct merge of main gives. GitHub had
reported a conflict since ProjectLeonida#1012 merged, with the branch and main on two merge bases (68d1331 and 5040782). Merging
ProjectLeonida#1034's head instead of main leaves this branch with one merge base with main when ProjectLeonida#1034 merges.

The merged tree was tested before the push: every standalone test file under tests/ passes except
tests/test_ci_registration.py, which fails on main 6558d53 alone (ProjectLeonida#1365 fixes it).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
aslan2142 pushed a commit that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 6558d53, which now holds #1012 (GPU-CMP-F64), the pull request this one was
stacked on. Git merged it without conflicts (git merge-tree, exit 0). GitHub had reported a conflict since #1012
merged, with the branch and main on two merge bases (68d1331 and 5040782); main is an ancestor of this commit.

The merged tree was tested before the push: every standalone test file under tests/ passes except
tests/test_ci_registration.py, which fails on main 6558d53 alone (#1365 fixes it).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

5 participants