Skip to content

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

Backlog

Description

@KainanP

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 DXIL: lower unclamped v_dot8_u32_u4 using Dot4AddU8Packed #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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions