Skip to content

Tests: legacy FMA and float min/max NaN semantics on the GPU - #719

Closed
lordon1a wants to merge 1 commit into
xcl-dev:mainfrom
lordon1a:tests/gpu-fma-legacy-and-minmax
Closed

lordon1a wants to merge 1 commit into
xcl-dev:mainfrom
lordon1a:tests/gpu-fma-legacy-and-minmax

Conversation

@lordon1a

Copy link
Copy Markdown

Adds a per-instruction GPU test (gpu_fma_legacy_and_float_min_max) covering 6 RDNA2 floating-point instructions that previously had no GPU test coverage: v_fma_legacy_f32, v_fmac_legacy_f32, v_min_f32, v_max_f32, v_min_f16, and v_max_f16. Checks legacy 0 * inf == 0 / 0 * NaN == 0 returning c, normal FMA, and IEEE-754 minNum/maxNum NaN propagation (one NaN returns the non-NaN operand, two NaNs return NaN) across 12 edge cases.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: adds gpu_fma_legacy_and_float_min_max (test-only; no runtime code changed).

Tested

  • Hardware: NVIDIA GeForce RTX 3070 Ti Laptop GPU (driver 616.64, wave32, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200), rustc 1.100.0 (x86_64-pc-windows-gnullvm), debug build, DXC 1.9.2609.5 (01b62ad4)
  • cargo test -p xcl --lib gpu_fma_legacy_and_float_min_max -- --nocapture: 1 passed, 0 failed, 0 ignored (0.64s)
  • cargo test --workspace -- --test-threads=1: 702 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests (expected on wave32-only NVIDIA hardware):
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Not tested

  • AMD / wave64, Intel GPU, MSVC toolchain, retail title (test-only diff; no runtime code modified)

AI use

  • Antigravity (Google DeepMind agent) — wrote the test, ran the local GPU and workspace test suites, and opened this PR.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 04:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@joeypercia

Copy link
Copy Markdown
Contributor

AMD / wave64 run (the Not tested item): 6e948d7 merged onto main f4ce27c (clean merge).

Tested

  • AMD Radeon iGPU (Ryzen 7 7800X3D, RDNA2, native wave64), driver 26.11.2 (32.0.21045.29003); RTX 4070 Ti (616.56, wave32); Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11; debug
  • gpu_fma_legacy_and_float_min_max: passes on the RDNA2 iGPU (native wave64) and on the RTX 4070 Ti (split form); no SKIPPED

Review note: the legacy model here is "a zero factor returns c". That differs from the hardware in one case: c = -0, where the result is +0 (the legacy product is +0, and +0 + -0 = +0; LLVM's amdgcn_fma_legacy folding calls this out). None of the cases has a zero product with c = -0, so the test is right as written, but adding one (e.g. (0, inf, -0) → +0) would cover #679. It would fail on main today, so it fits #679's fix PR better than this one.

Not tested: the full suite on this merge (test-only change); release build.

Run and report by Claude Code (Claude Opus 5.5).

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 6e948d7153ca09a4002fc83da3becf3804554efb on AMD RDNA4. I merged it onto current main f4ce27c locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 702 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 661 passed, 0 failed, 21 ignored
  • 0 SKIPPED; gpu_fma_legacy_and_float_min_max passes.

Review: The min / max references follow IEEE minNum / maxNum (one NaN gives the other operand), and the legacy FMA cases with a zero factor check that c comes back. One precision for the description: the hardware returns c + (+0), so for c = −0 the result is +0, not c; #720 fixes the translation for that case. None of this test's cases uses c = −0, so it passes with or without #720.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (6e948d7)

Hardware / environment

  • Intel Arc A770 selected with XCL_ADAPTER=A770, Windows x64 build 26200, AMD CPU (family 23, model 113). GPU driver version was not recorded.
  • Rust rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5 (01b62ad47), and Cargo's unoptimized test profile with debug info and incremental compilation disabled.
  • Tested commit 6e948d7153ca09a4002fc83da3becf3804554efb.

Commands and results

  • cargo test -p xcl --lib --no-run completed with exit code 0 before acquiring the GPU lock.
  • Inside Invoke-ArcTest.ps1, ran & $fixturePath gpu::recomp::tests::gpu_fma_legacy_and_float_min_max --exact --nocapture --test-threads=1 with RUST_TEST_NOCAPTURE=1. $fixturePath was the unit-test executable printed by the compile step.
  • The test process exited 0. The harness reported 1 passed, 0 failed, 0 ignored, with 681 tests filtered out. A case-sensitive scan of the focused log found 0 SKIPPED lines. The fixture completed in 2.04 seconds.

Observed behavior

  • The fixture dispatched a shader and compared readback for 12 input lanes across six instructions. Both legacy f32 FMA instructions returned the addend for the exercised zero-times-infinity and zero-times-NaN cases, including a NaN addend. The other cases matched the fixture's fused multiply-add expectations.
  • The f32 and f16 min/max checks returned the numeric operand when exactly one operand was NaN and returned a NaN when both operands were NaN. The fixture compared exact bits for numeric results and checked the NaN class for expected NaNs.

Not tested

The full GPU workspace suite and game smoke runs were omitted. Other GPU adapters were not tested.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr719-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 6e948d7

Main has no GPU test of v_fma_legacy_f32 / v_fmac_legacy_f32 or of v_min/v_max_f32/f16 with NaN. Some open PRs overlap in part: #1639 and #670 test the legacy FMA zero product, #739 tests f32 min/max with NaN, and #1301 tests the ordering of -0 and +0 (other cases). None covers all of this.
The expected values are right, and the cases avoid c = -0 with a zero product (#679) and +0 vs -0 in min/max, where the CPU reference is ambiguous.
Recommendation: keep open.

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

@lordon1a lordon1a closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants