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

Closed
opened 2026-11-27 03:54:48 +00:00 by Luke-Ervin · 1 comment
Luke-Ervin commented 2026-11-27 03:54:48 +00:00 (Migrated from github.com)
Contributor

Imported from LooperSalty/AnyXboxX. Originally posted by Luke-Ervin on 2026-11-27T03:54:48Z.


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.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6639617679 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/issues/482). Originally posted by [Luke-Ervin](https://github.com/Luke-Ervin) on 2026-11-27T03:54:48Z. --- ## 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 commented 2026-11-27 20:46:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LooperSalty/AnyXboxX. Originally posted by Luke-Ervin on 2026-11-27T20:46:02Z.


Done by @Lewandox's #501, #502, #503 and #505, thank you! They followed the plan above (the three parts plus the #275 follow-up).

Checked on main at bebcfb1 (after #545): I ran every VOP1, VOP2, VOPC, VOP3 and VOP3P name of the mnemonic table through both interpreters, with register operands and with the inline constant 1.0, in wave32 and wave64. Every half-precision encoding now gives the same result in Python and Rust. Closing.

The same sweep found one family still Python-only, and it is not f16: the 16-bit integer VOP3 instructions of emu/rdna2_exec_int16.py, 26 encodings in all:

  • v_add_nc_u16/i16, v_sub_nc_u16/i16, v_mul_lo_u16, the b16/i16 shifts, v_min/v_max/v_min3/v_max3/v_med3 in u16 and i16, and v_mad_u16/i16;
  • v_mad_u32_u16, v_mad_i32_i16, v_cvt_pk_u16_u32, v_cvt_pk_i16_i32, v_add_nc_i32 and v_sub_nc_i32.

The Rust runs the packed VOP3P half of that file, but refuses all of these with error untranslated. Nothing in the parity generator draws them. I'm porting them to anyxboxx-rdna2-ref next, checked against the Python the same way, and will link the PR here.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7227819995 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/issues/482#issuecomment-7227819995). Originally posted by [Luke-Ervin](https://github.com/Luke-Ervin) on 2026-11-27T20:46:02Z. --- Done by @Lewandox's #501, #502, #503 and #505, thank you! They followed the plan above (the three parts plus the #275 follow-up). Checked on `main` at `bebcfb1` (after #545): I ran every VOP1, VOP2, VOPC, VOP3 and VOP3P name of the mnemonic table through both interpreters, with register operands and with the inline constant 1.0, in wave32 and wave64. Every half-precision encoding now gives the same result in Python and Rust. Closing. The same sweep found one family still Python-only, and it is not f16: the 16-bit integer VOP3 instructions of `emu/rdna2_exec_int16.py`, 26 encodings in all: - `v_add_nc_u16`/`i16`, `v_sub_nc_u16`/`i16`, `v_mul_lo_u16`, the `b16`/`i16` shifts, `v_min`/`v_max`/`v_min3`/`v_max3`/`v_med3` in `u16` and `i16`, and `v_mad_u16`/`i16`; - `v_mad_u32_u16`, `v_mad_i32_i16`, `v_cvt_pk_u16_u32`, `v_cvt_pk_i16_i32`, `v_add_nc_i32` and `v_sub_nc_i32`. The Rust runs the packed VOP3P half of that file, but refuses all of these with `error untranslated`. Nothing in the parity generator draws them. I'm porting them to `anyxboxx-rdna2-ref` next, checked against the Python the same way, and will link the PR here.
Sign in to join this conversation.
No labels
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.

Reference
LooperSalty/AnyXboxX#482
No description provided.