Direct DXIL: XCL_DXIL_DIFF=1 differential kernel runs (both backends) #1924

Open
mastrr9 wants to merge 1 commit from upstream-pr/1934 into main
mastrr9 commented 2026-11-24 23:43:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mastrr9 on 2026-11-24T23:43:44Z.


XCL_DXIL_DIFF=1 runs the recompiler's kernel tests through both HLSL + DXC and the direct DXIL translator and fails on any difference. XCL_DXIL_DIFF_TABLE=<path> also records each paired program, for a per-opcode parity table. This is the proof the direct DXIL spec asks for before phase 7 (default-on). With the variable unset the tests run as before.

Draft: the head commit has not been built or tested yet.

What is in it

  • gpu/recomp/diff_kernel.rs: pairing, comparison and mismatch report, with tests
  • gpu/recomp/diff_table.rs: the per-program log and per-opcode summary, with tests
  • gpu/recomp/runner.rs, mod.rs: early returns taken only when the mode is on or a container was paired
  • gpu/recomp/tests.rs: pairs the tests that compile their own HLSL
  • docs/specs/2026-11-24-direct-dxil.md: 9 lines describing the switch (can be dropped if you prefer the spec untouched)

Tested
These runs are from before the final rebase, on a combined branch (376f968, based on main 689f2db; it holds this change, the other half of the differential mode, and six direct-translator parity fixes), not on this PR's head commit.

  • Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, cargo test debug build. Driver, CPU and Rust versions were not recorded.
  • cargo test -p xcl --lib recomp::diff_kernel -- --nocapture --test-threads=1: passed.
  • XCL_DXIL_DIFF=1 (with XCL_DXIL_DIFF_TABLE, XCL_DIRECT_DXIL unset), cargo test -p xcl --lib recomp:: -- --test-threads=1: 285 tests ran, 279 passed, 6 reported HLSL / direct mismatches. Not all of the 285 run both backends (some only translate). The combined tree had direct-translator fixes that this PR does not, so this PR alone may report differently.
  • Kernel-side mismatches: gpu_compute_tg_size_counts_a_partial_last_wave (HLSL 2, direct 1) and two 1–5 ULP floating-point differences in BVH ray intersection. Three more were wave64 VS / PS draws, found by the graphics half (separate PR).
  • Per-opcode table from that sweep: 71 rows, 69 matched, 2 mismatched.

Regression run
Not run: there are no xcl-smoke blocks for this change.

Not tested

  • The head commit (rebased onto main f5136a6) has not been built or tested: it was rebased on macOS, with no Rust toolchain.
  • cargo test --workspace was not run for this change on its own.
  • AMD and Intel GPUs; release build.
  • The early-exited-wave barrier program of gpu_safe_s_barrier_multi_warp_and_early_endpgm is deliberately not paired (see #1793).

AI use

  • Code and tests: written by Claude Opus 5.5 in an agent session (Duet) with no Windows or GPU.
  • RTX 5080 test runs above: a Claude Sonnet 5.5 agent.
  • Overlap check, rebase and this description: Claude Code, Claude Sonnet 5.5.
<!-- greyfinch-sync:ivall/xcl:issue:5482267835 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1934). Originally posted by [mastrr9](https://github.com/mastrr9) on 2026-11-24T23:43:44Z. --- `XCL_DXIL_DIFF=1` runs the recompiler's kernel tests through both HLSL + DXC and the direct DXIL translator and fails on any difference. `XCL_DXIL_DIFF_TABLE=<path>` also records each paired program, for a per-opcode parity table. This is the proof the direct DXIL spec asks for before phase 7 (default-on). With the variable unset the tests run as before. Draft: the head commit has not been built or tested yet. **What is in it** - `gpu/recomp/diff_kernel.rs`: pairing, comparison and mismatch report, with tests - `gpu/recomp/diff_table.rs`: the per-program log and per-opcode summary, with tests - `gpu/recomp/runner.rs`, `mod.rs`: early returns taken only when the mode is on or a container was paired - `gpu/recomp/tests.rs`: pairs the tests that compile their own HLSL - `docs/specs/2026-11-24-direct-dxil.md`: 9 lines describing the switch (can be dropped if you prefer the spec untouched) **Tested** These runs are from before the final rebase, on a **combined branch** ([`376f968`](https://github.com/mastrr9/xcl/commit/376f968), based on main `689f2db`; it holds this change, the other half of the differential mode, and six direct-translator parity fixes), **not on this PR's head commit**. - Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, `cargo test` debug build. Driver, CPU and Rust versions were not recorded. - `cargo test -p xcl --lib recomp::diff_kernel -- --nocapture --test-threads=1`: passed. - `XCL_DXIL_DIFF=1` (with `XCL_DXIL_DIFF_TABLE`, `XCL_DIRECT_DXIL` unset), `cargo test -p xcl --lib recomp:: -- --test-threads=1`: 285 tests ran, 279 passed, 6 reported HLSL / direct mismatches. Not all of the 285 run both backends (some only translate). The combined tree had direct-translator fixes that this PR does not, so this PR alone may report differently. - Kernel-side mismatches: `gpu_compute_tg_size_counts_a_partial_last_wave` (HLSL `2`, direct `1`) and two 1–5 ULP floating-point differences in BVH ray intersection. Three more were wave64 VS / PS draws, found by the graphics half (separate PR). - Per-opcode table from that sweep: 71 rows, 69 matched, 2 mismatched. **Regression run** Not run: there are no `xcl-smoke` blocks for this change. **Not tested** - The head commit (rebased onto main `f5136a6`) has not been built or tested: it was rebased on macOS, with no Rust toolchain. - `cargo test --workspace` was not run for this change on its own. - AMD and Intel GPUs; release build. - The early-exited-wave barrier program of `gpu_safe_s_barrier_multi_warp_and_early_endpgm` is deliberately not paired (see #1793). **AI use** - Code and tests: written by Claude Opus 5.5 in an agent session (Duet) with no Windows or GPU. - RTX 5080 test runs above: a Claude Sonnet 5.5 agent. - Overlap check, rebase and this description: Claude Code, Claude Sonnet 5.5.
upipibi commented 2026-11-25 00:09:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:46:48Z.


Built and ran, since the description says the head wasn't yet: RTX 3070 8 GB (32-lane waves, split wave64), driver 616.56, Windows 11, debug, d2758cb merged onto main 20cf130 (clean).

  • diff_kernel / diff_table unit tests: 13 passed.
  • XCL_DXIL_DIFF=1 cargo test -p xcl --lib -- gpu::recomp::tests --test-threads=4: 119 passed, 4 differ, 17 ignored. The mode does what it says and found these:
Test Difference Reading
gpu_compute_tg_size_counts_a_partial_last_wave 96 words: HLSL 2, direct 1 a direct-DXIL bug: dxil/kernel.rs sets TG_SIZE's wave count to total / lanes; the test (and the HLSL path) want total.div_ceil(lanes) (96 threads in wave64 are 2 waves). The test compiles only HLSL, so it never saw this
gpu_format_stores_atomics_global_lds 97 VGPRs, e.g. lane 1 v16 HLSL 0x64 vs direct 0xa3, v26 0x1 vs 0x44 not traced yet; the test's own checks pass on both
gpu_built_bvh_nodes_match_the_cpu_node_test, gpu_triangle_pair_and_box16_nodes 2–3 values, 1–2 ulp (0xc0dd6761 vs …63) float contraction / rounding between the backends; both within the tests' own tolerance

I'll open a small PR for the TG_SIZE one. The ulp cases might want a tolerance option in the comparison, so a known-inexact op doesn't hide a real difference in the same test.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:ivall/xcl:comment:7147785307 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1934#issuecomment-7147785307). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T23:46:48Z. --- Built and ran, since the description says the head wasn't yet: RTX 3070 8 GB (32-lane waves, split wave64), driver 616.56, Windows 11, debug, `d2758cb` merged onto `main` `20cf130` (clean). - `diff_kernel` / `diff_table` unit tests: 13 passed. - `XCL_DXIL_DIFF=1 cargo test -p xcl --lib -- gpu::recomp::tests --test-threads=4`: 119 passed, **4 differ**, 17 ignored. The mode does what it says and found these: | Test | Difference | Reading | |---|---|---| | `gpu_compute_tg_size_counts_a_partial_last_wave` | 96 words: HLSL 2, direct 1 | **a direct-DXIL bug**: `dxil/kernel.rs` sets TG_SIZE's wave count to `total / lanes`; the test (and the HLSL path) want `total.div_ceil(lanes)` (96 threads in wave64 are 2 waves). The test compiles only HLSL, so it never saw this | | `gpu_format_stores_atomics_global_lds` | 97 VGPRs, e.g. lane 1 v16 HLSL `0x64` vs direct `0xa3`, v26 `0x1` vs `0x44` | not traced yet; the test's own checks pass on both | | `gpu_built_bvh_nodes_match_the_cpu_node_test`, `gpu_triangle_pair_and_box16_nodes` | 2–3 values, 1–2 ulp (`0xc0dd6761` vs `…63`) | float contraction / rounding between the backends; both within the tests' own tolerance | I'll open a small PR for the TG_SIZE one. The ulp cases might want a tolerance option in the comparison, so a known-inexact op doesn't hide a real difference in the same test. AI-assisted (Claude Code). Synthetic tests only.
DavidM1911 commented 2026-11-25 03:05:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:41:06Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7151043712 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1934#issuecomment-7151043712). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T02:41:06Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
upipibi commented 2026-11-25 07:05:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T06:52:53Z.


Second run with XCL_DXIL_DIFF=1: RTX 3070, driver 616.56, debug. I merged d2758cb with main 568e7db; one hunk in tests.rs conflicts, and I kept main's direct_or(...) line, which also pairs in this mode. gpu_ tests, --test-threads=1: 130 passed, 5 differ.

Test Difference Reading
gpu_compute_tg_size_counts_a_partial_last_wave none now fixed by #1950
gpu_format_stores_atomics_global_lds, gpu_atomic_fcmpswap_x2 returned values of atomics (e.g. buffer_atomic_umax GLC old value: HLSL 0, 0x64, 0x65, …, direct 0xa3 on every lane; ds_add_rtn_u32 old values in another order) false positives. The lane order of one atomic across a wave is unspecified: direct's umax values are what you get when lane 63 goes first. The test's own checks accept any order. With XCL_DIRECT_DXIL=1 the test passes 5 of 5 runs, and in diff mode it differed in 4 runs and matched in 1.
gpu_f64_math_random lanes 14 and 22, v_rsq_f64 high dword: HLSL 0x7ff00000, direct 0x7ff80000 (low dword equal) a NaN payload: HLSL returns the input signalling NaN unchanged, and direct quiets it (closer to RDNA's IEEE mode). The test treats every NaN as equal. Reproduces in 3 of 3 runs.
gpu_built_bvh_nodes_match_the_cpu_node_test, gpu_triangle_pair_and_box16_nodes 1–2 ulp as before
gpu_image_get_resinfo_1d_array 64 values the known direct failure on main

For the comparison, it might help to compare the destinations of returning atomics as multisets, or let a test mark them as unordered. Compare NaNs by class or by payload, as a test chooses. Otherwise the noise hides a real difference in the same test.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:ivall/xcl:comment:7155255692 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1934#issuecomment-7155255692). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T06:52:53Z. --- Second run with `XCL_DXIL_DIFF=1`: RTX 3070, driver 616.56, debug. I merged `d2758cb` with `main` `568e7db`; one hunk in `tests.rs` conflicts, and I kept `main`'s `direct_or(...)` line, which also pairs in this mode. `gpu_` tests, `--test-threads=1`: 130 passed, 5 differ. | Test | Difference | Reading | |---|---|---| | `gpu_compute_tg_size_counts_a_partial_last_wave` | none now | fixed by #1950 | | `gpu_format_stores_atomics_global_lds`, `gpu_atomic_fcmpswap_x2` | returned values of atomics (e.g. `buffer_atomic_umax` GLC old value: HLSL `0, 0x64, 0x65, …`, direct `0xa3` on every lane; `ds_add_rtn_u32` old values in another order) | **false positives.** The lane order of one atomic across a wave is unspecified: direct's umax values are what you get when lane 63 goes first. The test's own checks accept any order. With `XCL_DIRECT_DXIL=1` the test passes 5 of 5 runs, and in diff mode it differed in 4 runs and matched in 1. | | `gpu_f64_math_random` | lanes 14 and 22, `v_rsq_f64` high dword: HLSL `0x7ff00000`, direct `0x7ff80000` (low dword equal) | a NaN payload: HLSL returns the input signalling NaN unchanged, and direct quiets it (closer to RDNA's IEEE mode). The test treats every NaN as equal. Reproduces in 3 of 3 runs. | | `gpu_built_bvh_nodes_match_the_cpu_node_test`, `gpu_triangle_pair_and_box16_nodes` | 1–2 ulp | as before | | `gpu_image_get_resinfo_1d_array` | 64 values | the known direct failure on `main` | For the comparison, it might help to compare the destinations of returning atomics as multisets, or let a test mark them as unordered. Compare NaNs by class or by payload, as a test chooses. Otherwise the noise hides a real difference in the same test. AI-assisted (Claude Code). Synthetic tests only.
DavidM1911 commented 2026-11-26 01:05:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:42:48Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7179039358 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1934#issuecomment-7179039358). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T00:42:48Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
github-actions[bot] commented 2026-11-30 08:40:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:40:29Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273201434 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1934#issuecomment-7273201434). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:40:29Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:07:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:07:05Z.


Triage (#1607) – head ddc4f5a

No open or merged PR adds an XCL_DXIL_DIFF mode. #1935 (same author) is the graphics half (diff_graphics.rs, VS / PS / mesh draws). This PR is the kernel / compute half (diff_kernel.rs, diff_table.rs). They touch different code paths and are not duplicates. The per-opcode parity PRs (#2084, #2087, #2143, #2276 …) add fixed tests, not a mode.
Notes: the head commit was never built (rebased without a toolchain, per the description). It is +758 lines, above the ~400 target. The docs/specs/ edit should go into the PR description instead (CONTRIBUTING.md). enabled() and translator_failed() exist in both this PR and #1935: once both land they could share one copy.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7303665177 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1934#issuecomment-7303665177). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:07:05Z. --- **Triage (#1607)** – head ddc4f5a No open or merged PR adds an `XCL_DXIL_DIFF` mode. #1935 (same author) is the graphics half (`diff_graphics.rs`, VS / PS / mesh draws). This PR is the kernel / compute half (`diff_kernel.rs`, `diff_table.rs`). They touch different code paths and are not duplicates. The per-opcode parity PRs (#2084, #2087, #2143, #2276 …) add fixed tests, not a mode. Notes: the head commit was never built (rebased without a toolchain, per the description). It is +758 lines, above the ~400 target. The `docs/specs/` edit should go into the PR description instead (CONTRIBUTING.md). `enabled()` and `translator_failed()` exist in both this PR and #1935: once both land they could share one copy. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1934:upstream-pr/1934'
git switch 'upstream-pr/1934'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1934'
git switch 'upstream-pr/1934'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1934'
git switch 'upstream-pr/1934'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1934'
git switch 'main'
git merge --squash 'upstream-pr/1934'
git switch 'main'
git merge --ff-only 'upstream-pr/1934'
git switch 'main'
git merge 'upstream-pr/1934'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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
xcl-dev/xcl!1924
No description provided.