anyxboxx-rdna2-ref refuses the half-precision (f16) VOP1/VOP2/VOP3/VOPC instructions that the Python model runs #482

Open
opened 2026-11-27 03:58:12 +00:00 by github-bot · 0 comments
Owner

@⁠Luke-Ervin on GitHub · 2026-11-27 03:54 UTC · original

Problem

The Python reference interpreter runs the scalar half-precision vector instructions added since #218 (emu/rdna2_exec_f16.py, emu/rdna2_exec_cmpf16.py, including #246, #247 and the f16 transcendentals). The Rust port, crates/anyxboxx-rdna2-ref, has none of them: they are only in its mnemonic table, so it refuses every one with error untranslated.

On main at b62053f, trying each of these names in each encoding the mnemonic table gives it (VOP1, VOP2, VOP3, VOPC), with plain register operands, wave32:

  • 62 names: 28 operations (v_add_f16, v_sub_f16, v_subrev_f16, v_mul_f16, v_fma_f16, v_fmac_f16, v_fmamk_f16, v_fmaak_f16, v_min_f16, v_max_f16, v_ldexp_f16, v_ceil_f16, v_floor_f16, v_trunc_f16, v_rndne_f16, v_fract_f16, v_frexp_mant_f16, v_frexp_exp_i16_f16, v_cvt_f16_f32, v_cvt_f32_f16, v_cvt_pkrtz_f16_f32, v_rcp_f16, v_sqrt_f16, v_rsq_f16, v_log_f16, v_exp_f16, v_sin_f16, v_cos_f16) and the 34 f16 compares (v_cmp_*_f16, v_cmpx_*_f16, v_cmp_class_f16, v_cmpx_class_f16).
  • 123 encodings tried: in 121 the Python runs the instruction and the Rust refuses it.

Minimal reproduction (input to target/release/anyxboxx-rdna2-ref, then the same words through emu.rdna2_exec):

lanes 32
scc 0
primitive 0
program 640200F2 BF810000      v_add_f16 v1, 1.0, v0       Rust: error untranslated   Python: runs
program 7E02AAF4 BF810000      v_sqrt_f16 v1, 2.0          Rust: error untranslated   Python: runs
program 7D9400F2 BF810000      v_cmp_eq_f16 vcc, 1.0, v0   Rust: error untranslated   Python: runs

Why nothing caught it:

  • tests/test_rdna2_ref_parity.py generates its random programs from the Python tables it imports (VECTOR, VECTOR_COMPARE, the packed f16 tables…), and the scalar f16 tables are not among them, so these instructions are never compared.
  • docs/rust-full-status.md still says "No RDNA 2 instruction family of the interpreter is Python-only any more", from a sweep run on 2026-11-25, before most of the f16 work was merged.

#303 ports the HLSL recompiler (a new crate, anyxboxx-rdna2-hlsl) and does not touch anyxboxx-rdna2-ref, so the two do not overlap.

Proposal

Port them to anyxboxx-rdna2-ref, checked against the Python model the same way as the earlier families (parity tests with fixed and seeded programs, refusals included), and correct the status doc. To keep each review small, in three pull requests:

  1. Arithmetic, FMA, min/max, ldexp, rounding (ceil/floor/trunc/rndne/fract/frexp) and the conversions, with their VOP3 modifiers and the same refusals as the Python (SDWA/DPP, unsupported op_sel / omod).
  2. The 34 compares (VOPC and VOP3, v_cmpx writing EXEC, v_cmp_class_f16).
  3. rcp, sqrt, rsq, log, exp, sin, cos, compared with the Python on all 65,536 inputs of each, since their last bit depends on the host's float functions.

Each one adds the new names to the parity generator, so later f16 changes on the Python side get compared automatically.

Questions

  1. Is this wanted now, or is it already planned elsewhere (rust/full, phase 4 of docs/architecture-rust.md)?
  2. #275 adds 20 more f16 encodings to the Python. Should the port wait for it, or go ahead and cover those in a follow-up once #275 is merged?
  3. For the transcendentals: is "bit for bit with the Python model on every input" the right target, or do you prefer another oracle (LLVM constant folding, a measured table)?
  4. Three pull requests, or one?

Found with an AI-assisted differential sweep of the two interpreters (Claude Code); the counts and the reproduction above were checked by running both interpreters on Linux.

**@⁠Luke-Ervin** on GitHub · 2026-11-27 03:54 UTC · [original](https://github.com/LooperSalty/AnyXboxX/issues/482) ## Problem The Python reference interpreter runs the scalar half-precision vector instructions added since #218 (`emu/rdna2_exec_f16.py`, `emu/rdna2_exec_cmpf16.py`, including #246, #247 and the f16 transcendentals). The Rust port, `crates/anyxboxx-rdna2-ref`, has none of them: they are only in its mnemonic table, so it refuses every one with `error untranslated`. On `main` at `b62053f`, trying each of these names in each encoding the mnemonic table gives it (VOP1, VOP2, VOP3, VOPC), with plain register operands, wave32: - 62 names: 28 operations (`v_add_f16`, `v_sub_f16`, `v_subrev_f16`, `v_mul_f16`, `v_fma_f16`, `v_fmac_f16`, `v_fmamk_f16`, `v_fmaak_f16`, `v_min_f16`, `v_max_f16`, `v_ldexp_f16`, `v_ceil_f16`, `v_floor_f16`, `v_trunc_f16`, `v_rndne_f16`, `v_fract_f16`, `v_frexp_mant_f16`, `v_frexp_exp_i16_f16`, `v_cvt_f16_f32`, `v_cvt_f32_f16`, `v_cvt_pkrtz_f16_f32`, `v_rcp_f16`, `v_sqrt_f16`, `v_rsq_f16`, `v_log_f16`, `v_exp_f16`, `v_sin_f16`, `v_cos_f16`) and the 34 f16 compares (`v_cmp_*_f16`, `v_cmpx_*_f16`, `v_cmp_class_f16`, `v_cmpx_class_f16`). - 123 encodings tried: in 121 the Python runs the instruction and the Rust refuses it. Minimal reproduction (input to `target/release/anyxboxx-rdna2-ref`, then the same words through `emu.rdna2_exec`): ``` lanes 32 scc 0 primitive 0 program 640200F2 BF810000 v_add_f16 v1, 1.0, v0 Rust: error untranslated Python: runs program 7E02AAF4 BF810000 v_sqrt_f16 v1, 2.0 Rust: error untranslated Python: runs program 7D9400F2 BF810000 v_cmp_eq_f16 vcc, 1.0, v0 Rust: error untranslated Python: runs ``` Why nothing caught it: - `tests/test_rdna2_ref_parity.py` generates its random programs from the Python tables it imports (`VECTOR`, `VECTOR_COMPARE`, the packed f16 tables…), and the scalar f16 tables are not among them, so these instructions are never compared. - `docs/rust-full-status.md` still says "No RDNA 2 instruction family of the interpreter is Python-only any more", from a sweep run on 2026-11-25, before most of the f16 work was merged. #303 ports the HLSL recompiler (a new crate, `anyxboxx-rdna2-hlsl`) and does not touch `anyxboxx-rdna2-ref`, so the two do not overlap. ## Proposal Port them to `anyxboxx-rdna2-ref`, checked against the Python model the same way as the earlier families (parity tests with fixed and seeded programs, refusals included), and correct the status doc. To keep each review small, in three pull requests: 1. Arithmetic, FMA, min/max, ldexp, rounding (`ceil`/`floor`/`trunc`/`rndne`/`fract`/`frexp`) and the conversions, with their VOP3 modifiers and the same refusals as the Python (SDWA/DPP, unsupported `op_sel` / `omod`). 2. The 34 compares (VOPC and VOP3, `v_cmpx` writing EXEC, `v_cmp_class_f16`). 3. `rcp`, `sqrt`, `rsq`, `log`, `exp`, `sin`, `cos`, compared with the Python on all 65,536 inputs of each, since their last bit depends on the host's float functions. Each one adds the new names to the parity generator, so later f16 changes on the Python side get compared automatically. ## Questions 1. Is this wanted now, or is it already planned elsewhere (`rust/full`, phase 4 of `docs/architecture-rust.md`)? 2. #275 adds 20 more f16 encodings to the Python. Should the port wait for it, or go ahead and cover those in a follow-up once #275 is merged? 3. For the transcendentals: is "bit for bit with the Python model on every input" the right target, or do you prefer another oracle (LLVM constant folding, a measured table)? 4. Three pull requests, or one? Found with an AI-assisted differential sweep of the two interpreters (Claude Code); the counts and the reproduction above were checked by running both interpreters on Linux.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:58:12 +00:00
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/LooperSalty--AnyXboxX#482
No description provided.