Recompiler: a constant multiplicand reaches dot4AddPacked as an immediate (misread by RTX 5070 / Intel Xe-LP drivers elsewhere; probe for RTX 50) #2473

Open
opened 2026-11-26 05:31:33 +00:00 by github-bot · 0 comments
Owner

@⁠KainanP on GitHub · 2026-11-25 19:39 UTC · original

Both backends pass a compile-time constant multiplicand of the 8-bit dot products straight into dot4AddPacked. Two drivers have been seen to misread such an immediate in another project's translator. I could not reproduce it on the GPUs I have that run XCL, so this is a request for a run on an RTX 50-series card before anyone writes a fix.

What XCL emits (main 2898511, dxc -dumpbin of the kernels, HLSL path and XCL_DIRECT_DXIL=1):

  • v_dot4_i32_i8 v2, v0, 0x4000, v1 → dot4AddPacked.i32(i32 163, i32 %acc, i32 %a, i32 16384) (HLSL path, recomp/emit.rs)
  • v_dot4_u32_u8 v3, v0, 2, v1 → dot4AddPacked.i32(i32 164, i32 %acc, i32 %a, i32 2) (HLSL path)
  • v_dot8_u32_u4 v4, v0, 2, v1 → two dot4AddPacked(164, …, i32 2) / (…, i32 0) calls (direct DXIL, dxil/lower_wide.rs, since #2173)

What was measured elsewhere (VIctory, a different translator, same DXIL shape):

  • RTX 5070: dot4AddPacked(i32 163, i32 2147483632, i32 50526978, i32 16384) returns acc − 128, RDNA 2 gives acc − 320, as if the driver fed the low half of the immediate into both halves (0x40004000). WARP is right. Marvisak/VIctory#1896
  • Intel UHD (Xe-LP 8086:a78b, driver 31.0.101.5445), my probe there: every constant multiplicand that fits in 16 bits (inline 1, 2, 64, −2, −16; literals 0x4000, 0x7F00, 0xFF80, 0xFFFF8000) is read as its low half repeated; the same values from root constants are right. Marvisak/VIctory#2408

In XCL, on this laptop

  • RTX 4060 Laptop (driver 32.0.16.1047): the probe below gives 0 mismatches on the HLSL path and on direct DXIL, so this card is not affected.
  • The Intel UHD and WARP cannot run XCL's GPU tests (16- and 4-lane waves; the probe prints SKIPPED … no wave64), and preflight refuses 16-lane GPUs, so the Intel half does not concern XCL.

Probe: branch KainanP/xcl:probe/dot4-constant-multiplicand (one commit on main 2898511, test only): 25 constants (inline integers, literals, inline floats) as one multiplicand of v_dot4_i32_i8 (src0 and src1), v_dot4_u32_u8, v_dot4c_i32_i8 and v_dot8_u32_u4, the other operand and the accumulator from registers, checked against the RDNA 2 definition.

cargo test -p xcl --lib gpu_dot4_constant_multiplicands -- --nocapture
set XCL_DIRECT_DXIL=1 & cargo test -p xcl --lib gpu_dot4_constant_multiplicands -- --nocapture

It prints N mismatches and each wrong lane. If an RTX 50-series (or another) card shows mismatches, the fix VIctory#2408 uses would apply here: when a multiplicand is a known constant, sum its non-zero bytes times the other operand's bytes by hand and keep dot4AddPacked for register operands. If nobody sees a mismatch, this can be closed.

Not related to the world load as far as I know: a wrong dot product gives wrong values, not a stall.

AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran it on the RTX 4060, Intel UHD and WARP here, read the DXIL and wrote this issue.

**@⁠KainanP** on GitHub · 2026-11-25 19:39 UTC · [original](https://github.com/xcl-dev/xcl/issues/2473) Both backends pass a compile-time constant multiplicand of the 8-bit dot products straight into `dot4AddPacked`. Two drivers have been seen to misread such an immediate in another project's translator. I could not reproduce it on the GPUs I have that run XCL, so this is a request for a run on an RTX 50-series card before anyone writes a fix. **What XCL emits** (`main` `2898511`, `dxc -dumpbin` of the kernels, HLSL path and `XCL_DIRECT_DXIL=1`): - `v_dot4_i32_i8 v2, v0, 0x4000, v1` → `dot4AddPacked.i32(i32 163, i32 %acc, i32 %a, i32 16384)` (HLSL path, `recomp/emit.rs`) - `v_dot4_u32_u8 v3, v0, 2, v1` → `dot4AddPacked.i32(i32 164, i32 %acc, i32 %a, i32 2)` (HLSL path) - `v_dot8_u32_u4 v4, v0, 2, v1` → two `dot4AddPacked(164, …, i32 2)` / `(…, i32 0)` calls (direct DXIL, `dxil/lower_wide.rs`, since #2173) **What was measured elsewhere** (VIctory, a different translator, same DXIL shape): - RTX 5070: `dot4AddPacked(i32 163, i32 2147483632, i32 50526978, i32 16384)` returns `acc − 128`, RDNA 2 gives `acc − 320`, as if the driver fed the low half of the immediate into both halves (`0x40004000`). WARP is right. [Marvisak/VIctory#1896](https://github.com/Marvisak/VIctory/pull/1896) - Intel UHD (Xe-LP `8086:a78b`, driver 31.0.101.5445), my probe there: every constant multiplicand that fits in 16 bits (inline 1, 2, 64, −2, −16; literals `0x4000`, `0x7F00`, `0xFF80`, `0xFFFF8000`) is read as its low half repeated; the same values from root constants are right. [Marvisak/VIctory#2408](https://github.com/Marvisak/VIctory/pull/2408) **In XCL, on this laptop** - RTX 4060 Laptop (driver 32.0.16.1047): the probe below gives 0 mismatches on the HLSL path and on direct DXIL, so this card is not affected. - The Intel UHD and WARP cannot run XCL's GPU tests (16- and 4-lane waves; the probe prints `SKIPPED … no wave64`), and preflight refuses 16-lane GPUs, so the Intel half does not concern XCL. **Probe:** branch [`KainanP/xcl:probe/dot4-constant-multiplicand`](https://github.com/KainanP/xcl/tree/probe/dot4-constant-multiplicand) (one commit on `main` `2898511`, test only): 25 constants (inline integers, literals, inline floats) as one multiplicand of `v_dot4_i32_i8` (src0 and src1), `v_dot4_u32_u8`, `v_dot4c_i32_i8` and `v_dot8_u32_u4`, the other operand and the accumulator from registers, checked against the RDNA 2 definition. ``` cargo test -p xcl --lib gpu_dot4_constant_multiplicands -- --nocapture set XCL_DIRECT_DXIL=1 & cargo test -p xcl --lib gpu_dot4_constant_multiplicands -- --nocapture ``` It prints `N mismatches` and each wrong lane. If an RTX 50-series (or another) card shows mismatches, the fix VIctory#2408 uses would apply here: when a multiplicand is a known constant, sum its non-zero bytes times the other operand's bytes by hand and keep `dot4AddPacked` for register operands. If nobody sees a mismatch, this can be closed. Not related to the world load as far as I know: a wrong dot product gives wrong values, not a stall. AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran it on the RTX 4060, Intel UHD and WARP here, read the DXIL and wrote this issue.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.