Skip to content

Model M driver probe: distinct values per lane and element - #14

Merged
phantoslayer21 merged 1 commit into
mainfrom
fix/model-m-probe-lanes
Nov 13, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
fix/model-m-probe-lanes

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

What changed and why

At device creation on a borrowed (game) device, Model M runs native_driver_probe to check the driver's matrix
instructions. The probe multiplied an all-ones A by an all-twos B and added C = the lane number, then checked
32 + lane for every result. Because A and B were uniform, and C and D share one layout, it gave the same result for
any element layout of A, B or the accumulator: a driver or translation layer that lays the fragments out differently
would still pass.

Now:

  • clean/runtime/wmma_probe.h (new, header only): the probe's operands, buffer layout and expected results. A and B
    are 16 x 16 tables of small nonzero integers (exact in FP16 and FP8 E4M3) whose 256 products A x B are all distinct;
    C = (32 v + lane) / 512 is distinct per element. Every value and partial sum is exact in FP32, so the result does not
    depend on the order of the hardware's additions. The host writes A, B and C in the fragment layout of
    clean/FORMATS.md and computes the expected FP16 and FP8 results on the CPU.
  • native_driver_probe (clean/dx12/kernels/native_game_helpers.hlsl) reads A, B and C from its buffer instead of
    using constants; same two matrix calls, same output layout.
  • device_d3d12.cpp: uploads the filled buffer and checks every result with wmma_probe::first_mismatch. The error
    text is unchanged ("probe mismatch at float N"), and WG_TEST_DRIVER_PROBE_FAIL=1 still reports float 7.
  • Cost at create: still one launch of one wave; the upload grows from 2 KiB to 4.5 KiB, the readback stays at 2 KiB.

Tests

  • clean/runtime/tests/test_wmma_probe.cpp (CPU, any host, any C++17 compiler; BUILDING.md section 6). A model of
    the matrix instruction reads the probe's buffer with a given fragment layout, computes D = A x B + C and writes D back
    in that layout. Results with MSVC and with clang++ (no warnings with /W4 or -Wall -Wextra):
    • with the layout of clean/FORMATS.md both the new and the old probe pass;
    • 17 named wrong layouts (A, B or C/D halves swapped; neighbouring lanes swapped; elements reversed; FP16 halves or
      bytes of each dword swapped; A, B or C/D transposed; A and B swapped; accumulator rows 2v + h): the new probe
      fails every one, the old probe passes every one;
    • every lane-pair swap (496) and every element-pair swap (28) of A, of B and of C/D, 1,572 layouts: the new probe
      fails all of them, the old probe passes all of them;
    • a K order that A and B share changes no product; the new probe passes it (it cannot be seen, and it does not matter).
  • clean/dx12/tests/native_probe_test.cpp (GPU): creates a D3D12 device and queue on the RX 9070 / 9060 adapter and
    calls make_d3d12_device_on, which runs the probe. On an RX 9070 XT (Windows) with the rebuilt probe kernel: PASS,
    so all 512 results matched the CPU's values. With WG_TEST_DRIVER_PROBE_FAIL=1: create fails with
    "probe mismatch at float 7", as before.

Not tested: Proton / vkd3d-proton (the reporter's setup), RX 9060 boards.

Reported by @j0nsh1n in #10.
Refs #10.

native_driver_probe multiplied an all-ones A by an all-twos B and added
C = the lane number in every element, then checked 32 + lane. Because A
and B were uniform and C and D share one layout, any element layout of
A, B or the accumulator gave the same result, so a driver or translation
layer that lays the WMMA fragments out differently still passed.

The probe now reads A, B and C from its buffer. The host fills them in
the fragment layout of clean/FORMATS.md (clean/runtime/wmma_probe.h):
A and B are small nonzero integers whose 256 products A x B are all
distinct, C = (32 v + lane) / 512 is distinct per element, every value
is exact in FP32, and the expected FP16 and FP8 results are computed on
the CPU in the same header. A different lane, element or half order of
A, B or the accumulator, A and B swapped or transposed, or the other
accumulator row table now changes at least one checked value. The cost
at create stays one launch of one wave (4.5 KiB upload, 2 KiB readback).
WG_TEST_DRIVER_PROBE_FAIL=1 still reports a mismatch at float 7.

clean/runtime/tests/test_wmma_probe.cpp checks this on any host: a model
of the instruction runs the probe's buffer under 17 named wrong layouts
and every lane-pair and element-pair swap of A, B and C/D (1,572 more);
the new probe fails each one and the old probe passes each one.
clean/dx12/tests/native_probe_test.cpp runs the probe on the GPU through
make_d3d12_device_on.

Reported by @j0nsh1n in #10.
Refs #10.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 13, 2026 15:31
@phantoslayer21
phantoslayer21 force-pushed the fix/model-m-probe-lanes branch from 7a4d410 to 6aef466 Compare November 13, 2026 15:31
@phantoslayer21
phantoslayer21 merged commit be2d35b into main Nov 13, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the fix/model-m-probe-lanes branch November 13, 2026 15:52
phantoslayer21 added a commit that referenced this pull request Nov 13, 2026
- Version defaults 0.6.0 -> 0.6.1: the front end and WrongGPU.asi (src/version.h),
  the launcher (WRONGGPU_VERSION), WrongGPU-RR.asi (release_version of the 2.7,
  2.8 and 2.14 binding tables) and the RR runtime's reported version.
- One version source for a release build: CMake -DWG_VERSION=x.y.z for the front
  end and WrongGPU.asi (writes wg_version_override.h), build.py
  --release-version x.y.z for the RR plugin. Without them the defaults are used.
- clean/installer/RELEASE-NOTES.md for 0.6.1: the fixes since 0.6.0 (#7, #8, #9,
  #14 and the launcher issues), thanks to j0nsh1n for the reports, and the 0.6.0
  notes carried over without performance figures (no 0.6.1 measurement backs
  them).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
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.

1 participant