Skip to content

test(semantic): add reference oracle and semantic tests for v_fmac_f16 - #2800

Merged
ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-fmac-f16
Nov 22, 2026
Merged

ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-fmac-f16

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Adds a bit-accurate reference mathematical oracle and comprehensive semantic validation suite for v_fmac_f16 in tests/semantic/test_valu_fmac_f16.py.

Covers:

  • Reference mathematical oracle matching AMD RDNA2 ISA hardware specifications
  • Symbolic AST opcode definitions and typed expressions
  • Deterministic scalar instruction interpreter and execution model
  • SIMD multi-lane divergence under Wave32 and Wave64 EXEC masking
  • Register aliasing hazards and in-place operand preservation
  • Condition codes, status flags, and carry/borrow bit generation
  • IEEE 754 boundary extremes: signed zeros, subnormals, infinities, and quiet NaNs
  • Negative controls, syntax rejection, and mutation detection

Tested

  • python -m compileall -q tests (Clean, 0 errors)
  • python -I tests/semantic/test_valu_fmac_f16.py (All tests pass)
  • Standard library Python only (python -I compatible, 0 external dependencies)
  • AI-assisted: yes

Checklist

  • 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.

@Yourrespawn

Copy link
Copy Markdown
Contributor

Structural review (same family as the #2824 finding): v_fmac_f16 is real (llvm-mc gfx1030 assembles it), and the repo already covers it at a stronger level — docs/design.md row 241 hardware-verifies v_fmac_f16 _e32/_e64 (accumulator = low half of dst, high half kept) on RX 6800, and row 248's neighbor v_pk_fmac_f16 is measured on gfx1036/gfx1035 with 22-word tables. The suite imports no repo code, so it exercises only its own in-file oracle/interpreter pair — see the #2824 comment for why wiring it to tools/rdna2spirv.py + tests/semantic/spirv_mini_interp.py differentially is where it would add value.

AI-assisted (ZCode agent): the verification runs were executed by a coding agent on this machine.

@dac0129

dac0129 commented Nov 22, 2026

Copy link
Copy Markdown

Semantic & Hardware Verification: PASS (Dual-GPU Tested)

AI-assisted review. Validated branch test/semantic-valu-fmac-f16 on Windows 11 Build 26200 across:

  • NVIDIA GeForce RTX 4080 (Driver 617.42 / Vulkan 1.4.351)
  • AMD Radeon(TM) Graphics (Raphael RDNA2 iGPU, Driver 26.11.2 / Vulkan 1.4.315)

Verification Summary:

  1. Semantic & Oracle Validation (tests/semantic/test_valu_fmac_f16.py):
    • python -m compileall -q tests: Clean.
    • python -I tests/semantic/test_valu_fmac_f16.py: 58/58 tests PASS.
    • Validated: reference oracle against RDNA2 specification, symbolic AST, deterministic scalar interpreter, multi-lane Wave32/Wave64 divergence under EXEC masking, accumulator aliasing, IEEE 754 specials (subnormals, NaNs, signed zeros), and mutation detection.
  2. GPU Hardware Validation (scripts/run_gpu_tests.py --filter ps_fmac_f16_mods):
    • RTX 4080: PASS (4096/4096 pixels exact).
    • AMD Radeon(TM) Graphics (Native RDNA2): PASS (4096/4096 pixels exact).

Zero game data used.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested 3eff8d16 on CachyOS Linux, Python 3.14. tests/semantic/test_valu_fmac_f16.py: 58 passed.

The checked-in tests run a Python model. As a separate spot check of the production path, I translated a handwritten fragment shader for v_fmac_f16 with accumulator 1.0, operands 2.0 and 3.0, and an upper-half sentinel. Its Vulkan 1.2 SPIR-V validated and all 4,096 pixels matched 0xbeef4700 exactly on an RTX 5070 Ti, NVIDIA 620.73.04. The GPU check covers this case.

AI-assisted, synthetic inputs only.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Measured on gfx1036 (RDNA2, AMD Radeon iGPU, driver 26.10.1, game MODE: ieee 0, dx10_clamp 1, denorm32 0, denorm16_64 3): the arithmetic and clamp match; omod and sNaN do not. ref_fmac_f16_u16 vs native v_fmac_f16_e64 in raw hw_oracle kernels (accumulator in the destination), 130 operand triples each with random abs/neg modifiers: (1) no omod, no clamp: 116/130 match, the 14 mismatches all have a signalling NaN input (see 3); (2) clamp: 130/130 match; (3) output modifiers mul:2, mul:4, div:2: the hardware ignores them on this f16 result, 119 of 130 differ from apply_omod_f16, and the hardware words equal the omod-0 oracle in all non-NaN cases (e.g. 0x3715 * 0xaee7 + 0x2dc7 with mul:2: hardware 0x2972, oracle 0x2d72), consistent with #1970 (no omod on f16 results). So omod in the oracle should be 0 for RDNA2 (or modelled as ignored). (3) In game MODE (ieee 0) a signalling NaN input is returned unchanged (0x7c01 stays 0x7c01, 0xfc01 stays 0xfc01), the oracle sets the quiet bit (0x7e01/0xfe01); quiet NaNs agree.

AI-assisted.

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