Skip to content

tests/semantic: run u16 clamp, interp_p1/p2 and cmp_class through the translator; drop fake dot2_f16 - #4123

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
SweatierKey:test/clear-semantic-debt-four
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
SweatierKey:test/clear-semantic-debt-four

Conversation

@SweatierKey

Copy link
Copy Markdown
Contributor

Claimed in #4084 (claim).

Clears the four remaining unclaimed DEBT entries in tests/test_semantic_translator_use.py (leaving test_valu_cvt_int_f64.py and test_valu_ldexp_f64.py for #3325 and #3543):

What changed

  • tests/semantic/test_alu_u16_clamp.py: replaced the 59-line Python-only stub with translator-driven tests exercising v_add_nc_u16_e64, v_sub_nc_u16_e64, v_add_u16_e64, v_sub_u16_e64, v_subrev_u16_e64 (clamp vs wrap, op_sel high/low-half preservation), packed v_pk_add_u16 / v_pk_sub_u16 clamp vs wrap, and the negative control (v_mul_lo_u16_e64 ... clamp raises Unsupported, matching docs/design.md).
  • tests/semantic/test_interp_p1_p2_f32.py: replaced the 1,485-line private oracle with translator-driven fragment shaders covering v_interp_p1_f32 + v_interp_p2_f32 across all four channels and multiple attributes (attr0..attr2), v_interp_mov_f32 p0 (Flat decoration), and inactive-lane preservation via support.varyings / support.mrt0_words.
  • tests/semantic/test_valu_cmp_class.py: replaced the 1,373-line private oracle with translator-driven tests covering all 10 IEEE 754 class bits for both v_cmp_class_f32 and v_cmp_class_f64, composite/high-bit masks, VOP3 abs/neg modifiers, and 32-lane v_cmpx_class_f32_e32 / v_cmpx_class_f64_e32 EXEC updates.
  • tests/semantic/test_valu_dot2_f16.py: deleted (1,695-line private oracle for v_dot2_f16_f16 / v_dot2acc_f16_f16, neither of which is a valid GFX10 / gfx1013 opcode — both rejected by llvm-mc -mcpu=gfx1013).
  • tests/test_semantic_translator_use.py: removed all four entries from DEBT.

Tested

Linux (WSL2), Python 3.13.5, spirv-as + spirv-val --target-env vulkan1.2 on PATH, CPU only, no game files:

  • python3 -I tests/semantic/test_alu_u16_clamp.py -v: 6/6 OK (all emitted SPIR-V validated by spirv-val)
  • python3 -I tests/semantic/test_interp_p1_p2_f32.py -v: 3/3 OK (all emitted SPIR-V validated by spirv-val)
  • python3 -I tests/semantic/test_valu_cmp_class.py -v: 5/5 OK (all 20 single-bit class probes + composite/mod/cmpx shaders validated by spirv-val)
  • python3 -I tests/test_semantic_translator_use.py -v: 3/3 OK
  • tests/test_docs_repo_paths.py (2/2), tests/test_docs_links.py (6/6), tests/test_text_write_line_endings.py (3/3), tests/test_text_encoding.py (2/2): all OK.

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

Ran this at cb796d31 on Windows 11:

  • test_alu_u16_clamp.py 6 tests OK; test_interp_p1_p2_f32.py 3 OK; test_valu_cmp_class.py 5 OK; test_valu_dot2_f16.py is removed; test_semantic_translator_use.py 3 OK with those four entries gone from DEBT.
  • The remaining two debt entries are indeed test_valu_cvt_int_f64.py and test_valu_ldexp_f64.py, matching the note.

The four replacements translate the synthetic listings and run the interpreter rather than modelling the answer; the dot2 file had no translator path and is dropped. No blocking issue.

@tupacfan04

Copy link
Copy Markdown
Contributor

Verified at the head on Windows 11 / Python 3.13.0: all three files call support.translate_lines (test_alu_u16_clamp.py:46, test_interp_p1_p2_f32.py:54, test_valu_cmp_class.py:80) with no private oracle left; mutation controls fail as required (u16 clamp 3, interp 2, cmp_class 1). Runs: u16 6/6, interp 3/3, cmp_class 5/5, guard 3/3, compileall clean, merge clean with main and #4127.

The deleted test_valu_dot2_f16.py (1,695 lines / 66 tests) was a duplicate non-translator oracle, and its rejection remains covered by test_alu_dot2_f16.py:922-947.

Coverage notes, both acceptable since these were oracle-only cases rather than previous translator coverage: the modifier tests no longer include the sNaN/zero/denormal extremes (test_valu_cmp_class.py:164-188 vs the old :1221-1235), and the interp source/p1 modifiers are not re-expressed.

Separately, tests/semantic/test_mutations.py fails 2/3 here (anchor at :120, label :70), but identically on main aa2988cc - pre-existing and unrelated.

Approve. AI-assisted review, no game files, no GPU.

@kapitche

Copy link
Copy Markdown
Contributor

Tested cb796d3 merged with main 3faac55 on Linux (WSL2), Python 3.12.16: pass.
Ran the three rewritten files (test_alu_u16_clamp 6, test_interp_p1_p2_f32 3, test_valu_cmp_class 5, all OK), tests/test_semantic_translator_use.py (3 OK) and the neighbouring test_alu_dot2_f16_unsupported.py (2 OK). spirv-val was not on PATH in this environment.
Negative control: with main's versions of the three test files and the deleted test_valu_dot2_f16.py restored under the PR's translator-use guard, test_every_semantic_test_reaches_the_translator FAILS for all four ("imports no rdna2spirv"), so the DEBT removal is enforced. With main's DEBT list and the PR's new test files the guard still passes, i.e. stale DEBT entries are not flagged.
The dot2_f16 deletion loses no translator coverage: the translator has no v_dot2_f16 rule and test_alu_dot2_f16_unsupported.py remains.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 3339f037 merged onto main 561b65a8 on Windows 11, CPython 3.14.3, CPU only: pass.

  • python -I -m unittest discover -s tests/semantic -p test_interp_p1_p2_f32.py: 3 tests OK.
  • python -I -m unittest discover -s tests/semantic -p test_valu_cmp_class.py: 5 tests OK.
  • python -I tests/test_semantic_translator_use.py: 3 tests OK.
  • py_compile on the 3 changed Python files: OK; git diff --check: clean.

No game files. AI-assisted (Claude Code).

@kapitche

kapitche commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 3339f03 merged with main 561b65a on Linux (WSL2), CPython 3.12.16, CPU only: pass.

  • Linux (spirv-as/spirv-val were not on PATH there, so the tests' SPIR-V validation step was skipped): test_interp_p1_p2_f32.py: 3/3; test_valu_cmp_class.py: 5/5; tests/test_semantic_translator_use.py: 3/3. test_valu_dot2_f16.py is deleted; main already has test_alu_dot2_f16_unsupported.py (2/2).
  • Negative control (cmp_class only): with the neg sign-bit XOR in cmp_class turned into a no-op in tools/rdna2spirv.py, the new test_valu_cmp_class.py fails (failures=1); main's 47-test private-oracle version of that file passes the same mutation. I did not mutate the interp_p1/p2 path.
  • Native Windows, CPython 3.13.1, with spirv-as/spirv-val on PATH (validation active): test_valu_cmp_class.py 5/5 and test_interp_p1_p2_f32.py 3/3 pass.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review

Reviewed test coverage in PR #4123: tests/semantic: run u16 clamp, interp_p1/p2 and cmp_class through the translator; drop fake dot2_f16.

Scope: tests/semantic/test_interp_p1_p2_f32.py, tests/semantic/test_valu_cmp_class.py, tests/semantic/test_valu_dot2_f16.py, +1 more
Diff: +350 / -4532 across 4 file(s).

The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.

Reviewed by shayderrr via automated batch review.

@shayderrr

Copy link
Copy Markdown
Collaborator

Thanks @SweatierKey - I went through tests/semantic: run u16 clamp, interp_p1/p2 and cmp_class through the translator; drop ... and the diff around tests/semantic/test_interp_p1_p2_f32.py. The change is tight, the rationale matches the code, and there's nothing here that needs another pass from my side. Approved and squash-merging it into main now. Nice work.

@shayderrr
shayderrr merged commit b0b3cef into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
sh1shu1 added a commit to sh1shu1/Leonida that referenced this pull request Nov 23, 2026
Six DEBT files of tests/test_semantic_translator_use.py modelled binary64 instructions in Python and never called
tools/rdna2spirv.py, so they pinned nothing. The translator has no lowering for five of them, so
test_valu_mul_f64, test_valu_minmax_f64, test_valu_fma_f64, test_valu_fract_f64 and test_valu_trig_f64 (v_sin_f64 /
v_cos_f64 are not RDNA2 opcodes either) now pin the Unsupported refusal; when a lowering lands, each file is the
place for its cases.

test_valu_cvt_f32_f64.py checks the translated SPIR-V along its SSA chain, since the interpreter has no OpFConvert
yet: the one OpFConvert %float reads a %double bitcast from the pair loaded from the named registers (low word
first), a literal dword lands in bits 63:32, the VOP3 modifiers reach the double as FAbs then FNegate, and
v_cvt_f64_f32 is pinned as refused. The six DEBT entries go. (The int-to-float and dot2 files of the first draft
were converted or removed on main meanwhile, by ItsNotRexed#6315 and ItsNotRexed#4123.)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
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.

6 participants