v_med3_f32 with NaN returns wrong side on NVIDIA (NVIDIA-specific test failure) #726
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#726
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Tanju42 on GitHub · 2026-11-24 08:27 UTC · original
Title:
v_med3_f32(1.0, 2.0, NaN) returns 2.0 on NVIDIA; the RDNA2 result is 1.0Running the test suite on an NVIDIA RTX 5060 Laptop (driver 591.74, Windows 11
26300) with the default hardware device, the whole suite is green except:
The lowering models the RDNA2
v_med3_f32NaN rule (with a NaN among thethree, the result is the smaller of the two numbers). The DXIL path evidently
maps it to an intrinsic/host expression whose NaN propagation picks the other
side on NVIDIA hardware; AMD (RX 6700 XT, where the suite is reported green)
matches the console behavior. All other NaN VALU tests in the same module
(
v_med3_f16...passes on NVIDIA already) are fine, so only the f32 loweringneeds the NaN-safe form.
Repro:
cargo test -p victory-shader --lib -- --test-threads=1Environment: any NVIDIA D3D12 adapter with SM 6.6; the failure is stable in
serial and parallel runs. The same run under
VICTORY_WARP=1is fully green,which fits a hardware-intrinsic difference rather than a code bug.
No game files involved — synthetic tests only.
@NuraadGit on GitHub · 2026-11-24 08:35 UTC · original
Data point: on an RTX 2080 (Turing), driver 616.56, Windows 11 26200, both tests pass on
main58fed37. I applied #719's one-line test fix locally so the crate's tests compile.Your failing run was on driver 591.74, which is much older, on Blackwell. This one may depend on the driver (or the architecture) rather than on NVIDIA as a whole. A rerun on a current driver on the same laptop would tell which.
AI-assisted (Claude Code); run on the user's machine.
@Nii-SanHP on GitHub · 2026-11-24 08:38 UTC · original
Data point: RTX 5070 Ti (Blackwell, desktop), driver 621.24, Windows 11 26200,
main58fed37with #719's one-line fix applied locally.Full workspace: 307 passed, 0 failed. Blackwell itself passes on a current driver, which supports the failure being the older driver (591.74) rather than the architecture.
AI-assisted (Claude Code); run on the user's machine. No game data used.
@fromthemoonx on GitHub · 2026-11-24 08:39 UTC · original
Another data point, from Ampere: RTX 3060 12 GB (desktop), driver 610.88, Windows 11 Pro 26300, Rust 1.98.1
x86_64-pc-windows-msvc,main58fed37with #719's one-line fix applied locally (lowers(&words, 0)) so the tests compile.cargo test --locked -p victory-shader v_med3 -- --test-threads=1, 10 runs: bothv_med3_f16_matches_rdna2_with_nanandv_med3_f32_matches_rdna2_with_nanpassed every time, on the hardware adapter and WARPcargo test --locked --workspacewith the fix: 307 passed, 0 failed, 5 ignoredSo it now passes on Turing (616.56) and Ampere (610.88) and fails on the Blackwell laptop (591.74). That fits the driver (or Blackwell) rather than NVIDIA in general, as @NuraadGit suggests.
No game data used. AI-assisted (Claude Code).
@DrDarkDK on GitHub · 2026-11-24 09:01 UTC · original
Ada data point: RTX 4070 Ti (desktop), NVIDIA driver 621.01, Windows 11 build 26300.9974, Rust 1.98.1 (
x86_64-pc-windows-msvc). Testedfa001a6(58fed37plus the one-line test compilation fix from #719).Both tests passed on the hardware adapter and WARP in one run, with no adapter skips. I verified that the default D3D12 adapter was the RTX 4070 Ti.
No game data used. AI-assisted test setup and reporting.
@geiyiliyabumo on GitHub · 2026-11-24 09:15 UTC · original
AMD RDNA4 data point on
main(8e79c80, where#719is already fixed):PCI\VEN_1002&DEV_7590), AMD Windows driver32.0.32029.2010(Adrenalin26.11.2)26100, Rust1.98.1(x86_64-pc-windows-msvc)cargo test -p victory-shader --locked -- v_med3_f --nocaptureFull
cargo test --workspace --lockedon the same machine also passed (311 passed; 0 failed; 6 ignored).AI-assisted; synthetic tests only, no game files.
@terxx465 on GitHub · 2026-11-24 09:44 UTC · original
Data point: RTX 5060 Ti 16 GB (Blackwell, desktop), driver 621.24, Windows 11 Pro 26300, i5-14400F (no iGPU, so the hardware adapter is the RTX), Rust 1.98.1 (
x86_64-pc-windows-msvc), DXC from Windows SDK 10.0.26100. Testedmainat8e79c80, no local changes.Full workspace: 311 passed, 0 failed, 6 ignored.
All 13
valu_testspass on the hardware adapter and WARP. The 4diff_testsskip here (no console compiler/no console or PC compiler), so they are not covered by this run.This matches the RTX 5070 Ti result on the same driver: on a current driver, Blackwell passes
v_med3_f32.AI-assisted test run and reporting; synthetic tests only, no game files.
@EduBertozzi on GitHub · 2026-11-24 10:07 UTC · original
Pascal data point: GTX 1060 6 GB, driver 582.66, Windows 10 Education 22H2 (19045), i7-10700K, Rust 1.98.1. SM 6.6 comes from the Agility SDK 1.620.2 runtime, via #486 on my branch.
Both tests ran on the hardware adapter, and on WARP 1.0.22 (Microsoft.Direct3D.WARP) with its
d3d10warp.dllplaced beside the test binary. That adds Pascal to the passing reports here (Turing, Ampere, Ada, desktop Blackwell, RDNA4). So far only the RTX 5060 Laptop on driver 591.74 fails.AI-assisted (Claude Code); runs on my machine.
@ayanbarosan on GitHub · 2026-11-24 13:09 UTC · original
On an Optimus laptop, the failure follows the Intel iGPU, not the NVIDIA GPU. Same machine (i5-11400H, RTX 3050 Laptop, Windows 11 build 26300),
mainatffe310ewith no changes,v_med3tests run 10 times on each adapter:v_med3_f32_matches_rdna2_with_nanhardware: v_med3_f32(1.0, 2.0, NaN) = 2 (0x40000000), want 1v_med3_f16passes on both, as in the original report. To run on the RTX, I changedHost::newincrates/victory-shader/src/emit/host.rslocally to take the adapter fromIDXGIFactory6::EnumAdapterByGpuPreference(0, HIGH_PERFORMANCE). I also printed the device's adapter (fromGetAdapterLuid) in both modes, so each row names the GPU that actually ran.Host::newcallsD3D12CreateDevice(NULL), which takes DXGI adapter 0, and on Optimus laptops that is usually the integrated GPU. So the two laptop failures reported as NVIDIA (the RTX 5060 Laptop here and the RTX 3050 Ti Laptop in #745) may have run on the iGPU. Every desktop NVIDIA result so far passes. The old-driver explanation doesn't fit #745 either: that failure was on 32.0.16.2114 (621.14), newer than most of the passing desktop drivers. Printing the adapter name in the test output would show this in every report.The fix from #745 (
c796377onraphael-riesner:shader/med3-nan-bits) passes 10/10 on both adapters here. Anyone with this failure can try that branch.No game data used. AI-assisted (Claude Code).
@Sunkiller-qc on GitHub · 2026-11-24 13:21 UTC · original
There's an open PR for this from before this issue: #110 (lordon1a, opened 00:36 UTC). It replaces
fcmp unoinLower::med3()with DXIL'sIsNaN(dx.op.isSpecialFloat.f32, opcode 8), because the driver compiler foldsfcmp uno x, xto false under fast-math. The symptom is the same:v_med3_f32(1.0, 2.0, NaN)returns 2.0 instead of 1.0. It was found on Intel Iris Xe, which matches ayanbarosan's Intel UHD result on #745. #154 extends the same fix to the other unordered and ordered compares.So there are two fixes now, #110 and the bit-compare branch on #745. If someone with a failing card (the 5060 Laptop here, or the 3050 Ti Laptop on #745) could run
v_med3_f32_matches_rdna2_with_nanon #110, that would settle which one to take.@ayanbarosan on GitHub · 2026-11-24 18:22 UTC · original
I ran
v_med3_f32_matches_rdna2_with_nanon #110, on a GPU where it fails. That is the Intel UHD Graphics of the Optimus laptop from my comment above (Tiger Lake, driver 31.0.101.5333, Windows 11 build 26300). For the RTX column, a local change made the test host take the high-performance adapter. A local print of the device's adapter confirmed which GPU each column ran on.v_med3_f32_matches_rdna2_with_nanfc0c4ddhardware: v_med3_f32(1.0, 2.0, NaN) = 2 (0x40000000), want 1d53fa58c796377from #745, onmainatffe310e(my comment above)v_med3_f16passes in every row.cargo test -p victory-shader --locked --libond53fa58: 69 passed, 0 failed, including the newmed3_f32_emits_dxil_isnan_instead_of_fcmp_uno.Both fixes work on this GPU. They rely on different things: #110 on the driver keeping
dx.op.isSpecialFloat(IsNaN), andc796377on integer compares of the bits, which a driver's no-NaN assumption can't fold.Heads-up for #110: it no longer merges cleanly with
mainatffe310e.lower.rsconflicts in two test-only spots: the fields ofLowered, wheremainaddednonuniform_handlesandwave_ops, and the helperlowers, whichmainchanged to takersrc2.The adapter name in the test output, suggested above, is now #1138.
No game data used. AI-assisted (Claude Code).
@DeerSilver on GitHub · 2026-11-24 18:52 UTC · original
Data point from the same GPU as the report: NVIDIA GeForce RTX 5060 Laptop GPU (
10de:2d59), driver 621.24, Windows 11 26300,mainffe310e. Bothv_med3_f32_matches_rdna2_with_nanandv_med3_f16_matches_rdna2_with_nanpass 5 of 5. To be sure the RTX ran them, I added a local, uncommitted switch toemit::host::Host::newthat creates the device on a given DXGI adapter and prints its name.The same laptop's Intel UHD (
8086:a788, driver 32.0.101.7088) fails exactly as reported here, 5 of 5:hardware: v_med3_f32(1.0, 2.0, NaN) = 2 (0x40000000), want 1. On this laptop DXGI lists the RTX first, but on a hybrid laptop where the iGPU is adapter 0, the test's default device is the iGPU (as N7z notes on #971). So this failure may be the iGPU's, or the 591.74 driver's. Either way, #745'sc796377fixes it on the Intel UHD and keeps it passing on the RTX (results on #745).No game files: the test suite only. AI-assisted (Claude Code).
@nicolasveilleux on GitHub · 2026-11-24 23:54 UTC · original
I could not reproduce the
v_med3_f32NaN failure on a desktop RTX 2070 SUPER (8 GB, NVIDIA driver 610.60), Windows 11 Pro build 26300, Rust 1.98.1 MSVC, on unmodified upstreammainat70564ae.cargo test --locked --offline -p victory-shader --lib emit::valu_tests::v_med3_f32_matches_rdna2_with_nan -- --exact --nocapturepassed with the default D3D12 adapter and again withVICTORY_WARP=1. The workspace build passed. The full suite reported 471 passed, 5 failed, and 7 ignored, matching the five failures listed in #1744. No game files or local code changes were used. This is a hardware data point for #726, not a test of the patch in #1610.AI-assisted; the results above come from runs on the stated hardware.
@Marvisak on GitHub · 2026-11-25 01:47 UTC · original · edited 2026-11-26 00:50 UTC
Automated triage for the maintainers.
Confirmed on current
main(63bcca4).Lower::med3incrates/victory-shader/src/emit/lower.rsstill picks the NaN case with twofcmp unocompares (pred::UNOona, band onthird, third). Some driver compilers fold these to false, and then the plain median comes back.The thread narrows the failing devices down. An Intel UHD iGPU fails 10/10 and 5/5 on two hybrid laptops, while the RTX on the same machines passes. Every desktop NVIDIA, AMD and WARP result passes, including the newest ones (RTX 3070 Ti on
13f91ca, RTX 4070 on842b0cb). So the "NVIDIA" in the title most likely comes from the test host using an iGPU adapter on a laptop. Those passing results don't fix the bug: the compare still folds on the iGPUs, so this stays open.Where the fixes stand:
c796377) and #110 (DXILIsNaN) were both closed without merging. Neither is inmain.v_med3_f32/f16test for NaN on the bits, and makes the test host pick the high-performance adapter. It needs a rebase.fcmp unoand adds more of it. So it would not help if the folding is the cause.The cause is tracked here and in #745 (fix branch). #971 (Intel Arc) is likely the same compare folding.
Generated by Claude Code
@artor410 on GitHub · 2026-11-25 21:53 UTC · original
Comparison on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main
13f91ca. Synthetic tests only.v_med3_f32_matches_rdna2_with_nanpasses on main on this card, so #726 (RTX 5060 Laptop, driver 591.74) does not reproduce here. It may depend on the driver.fcmp uno, more of itdx.op.isSpecialFloat(IsNaN)Main fails the same 3 tests: two stride tests and
gathers_at_a_level_match_the_hardware. On this cardheap_direct_texture_reads_mark_their_heap_indexcrashes the process on main and was skipped.No verdict from this hardware: neither PR changes a result here.
On the cause, #110 reports a driver folding
fcmp uno x, xunder fast-math. #2010 keeps that compare and adds more of it, so it would not help if that is the cause.Forks:
570a941) detect NaN on the integer bits:abs(bits) > 0x7F800000viais_nan_f32. That depends on neitherfcmp unonor IsNaN folding.a5837b8).A form already used in an NVIDIA fork that reaches the world looks like the safer choice. Neither open PR uses it.
(Claude Code, Claude Opus 5.5.)
@pawrenity on GitHub · 2026-11-25 23:51 UTC · original
Does not reproduce on an NVIDIA GeForce RTX 4070, Windows 11,
main842b0cb.emit::valu_tests::v_med3_f32_matches_rdna2_with_nanpasses in the full suite and 2 of 2 runs alone, and also passes on this machine's AMD iGPU. This agrees with FIND-24 in #1633 (RTX 4060), so this issue and TEST-MED3-NAN can probably be closed.AI-assisted (Claude Code).
@zzm1234560621-prog on GitHub · 2026-11-26 11:13 UTC · original
Independent Xe-LPG data point on the cause, and on #1483's lowering.
Machine: Windows 11 Pro for Workstations (26200), Core Ultra 9 185H, Intel(R) Arc(TM) Graphics (Xe-LPG integrated), driver 32.0.101.6127, Rust 1.98.1 MSVC, MSVC 14.51.
On
mainffe310e— the failure reproduces on hardware, and only there:VICTORY_WARP=1on the same test: passes. WARP agrees with RDNA2, so the emitted DXIL is right and it is the driver.v_med3_f16_matches_rdna2_with_nanon hardware: passes.2.0, is exactly the plain-median arm under NaN-skipping min/max — consistent with the triage's "thefcmp unocompares fold to false, and the plain median comes back".On #1483's head
0daabcc(same tree asffe310eexceptcrates/victory-shader/src/emit/{lower,valu_tests,bitcode,mod,sampler,host}.rsreplaced with that branch's files, nothing else):hardware adapter: Intel(R) Arc(TM) Graphicsis printed for every case, so these ran on the iGPU, not on WARP.So the bit-compare form (
magnitude > infinity, integer compare) fixes Xe-LPG as well as the UHD iGPUs already in this thread. That is one more iGPU family where thefcmp unoform fails and the integer form does not, and it is the first Arc result on this issue as far as I can see.What this does and does not say
fcmp uno.ffe310eand the triage on it already says it needs a rebase, and itsvictory-gpu/src/host.rshunk overlaps #967.#110's fast-math explanation fits, but I have not looked at this driver's DXIL pass.Repro detail, in case someone wants to redo it: take a pristine
ffe310etree, overwrite only those six files with the branch's versions at0daabcc, thencargo test -p victory-shader --lib v_med3 -- --nocapture. No game files, no console, ~2 minutes on this machine.Tested with AI assistance (Claude).
@zzm1234560621-prog on GitHub · 2026-11-26 12:05 UTC · original
Update, and it narrows this rather than confirming it: on current
main(63bcca4) this machine passesv_med3_f32_matches_rdna2_with_nan.mainffe310e, same machine, same driver:hardware: v_med3_f32(1.0, 2.0, NaN) = 2 (0x40000000), want 1(the run in my comment above).main63bcca4, unmodified tree:emit::valu_tests::v_med3_f32_matches_rdna2_with_nan ... ok, also run alone, 2 of 2.med3still picks the NaN case withfcmp uno(lower.rs:2442-2444) — the bit-compare form was not what changed. What changed between those heads insidemed3isftzplusmax_min_flushed(lower.rs:2436-2441), i.e. the min/max the median is built from. So on this Xe-LPG driver theunocompares do not fold; the failure belongs to the UHD iGPUs in this thread, and "confirmed on current main" is true for those machines, not for Xe-LPG in general.I have not bisected
ffe310e..63bcca4for the commit that flips it — offer stands if it would help, it is one test over a day of merges.Separately, the same run gives an Intel baseline this issue list did not have: 7 of 295
victory-shadertests fail on this adapter, and three of them are one ULP in the BVH hit distance. Reported in #3196 so it does not clutter this thread.No game files. AI-assisted (Claude).