Test CvtPkrtzF16F32SubnormalRoundsTowardZero fails on NVIDIA RTX 3090 since #1520 (passes on AMD iGPU) #1575

Closed
opened 2026-11-26 10:00:07 +00:00 by github-bot · 5 comments
Owner

@⁠KelvinSilvaDev on GitHub · 2026-10-16 23:39 UTC · original

Hi! I'm a user, not a graphics developer. My professional background is in web development, so I may be missing some context. I'm trying to help the project by running its tests on my PC.

Since #1520, one test fails on my NVIDIA RTX 3090. The same test passes on the AMD integrated GPU of the same PC.

Failing test

ShaderRecompilerComputeTests: CvtPkrtzF16F32SubnormalRoundsTowardZero failed at readback: expected [0x80010001] actual [0x80020002]

How to reproduce

cmake --build _Build/windows --target shader_recompiler_compute_tests
_Build\windows\shader_recompiler_compute_tests.exe

My setup

  • Windows 11, clang-cl 19.1.5 (VS 2022 Build Tools), Release, main @ 5dec5231
  • NVIDIA GeForce RTX 3090, driver 617.14: fails
  • AMD Radeon(TM) Graphics (Ryzen integrated), AMD proprietary driver 25.10.30.02: passes. That run was done by hiding the NVIDIA driver (VK_LOADER_DRIVERS_DISABLE=*nv*).

What I checked

This was done on my PC, with the AI assistant's help:

  • With #1520 reverted locally, the whole shader_recompiler_compute_tests suite passes on the RTX 3090. With #1520 back, the failure returns.
  • I also ran a bigger test for this instruction (1548 input values, compared with an exact result computed on the CPU). The AI assistant wrote it. On main, on the RTX 3090, 869 of the 1548 results are one step too high, in almost every range of values. On the AMD GPU there are no errors. I don't know why.

About me and the AI

I can't explain the graphics details myself. An AI assistant (Claude) helped me run the tests, read the results, and write a possible fix and the bigger test. The numbers above come from runs on my PC. I'm not opening a pull request, because I can't judge whether the fix is the right approach. If it's useful, I can share the fix and the test, or run more tests on my two GPUs.

I ran the failing test myself.

**@⁠KelvinSilvaDev** on GitHub · 2026-10-16 23:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1575) Hi! I'm a user, not a graphics developer. My professional background is in web development, so I may be missing some context. I'm trying to help the project by running its tests on my PC. Since #1520, one test fails on my NVIDIA RTX 3090. The same test passes on the AMD integrated GPU of the same PC. **Failing test** ShaderRecompilerComputeTests: CvtPkrtzF16F32SubnormalRoundsTowardZero failed at readback: expected [0x80010001] actual [0x80020002] **How to reproduce** cmake --build _Build/windows --target shader_recompiler_compute_tests _Build\windows\shader_recompiler_compute_tests.exe **My setup** - Windows 11, clang-cl 19.1.5 (VS 2022 Build Tools), Release, `main` @ `5dec5231` - NVIDIA GeForce RTX 3090, driver 617.14: fails - AMD Radeon(TM) Graphics (Ryzen integrated), AMD proprietary driver 25.10.30.02: passes. That run was done by hiding the NVIDIA driver (`VK_LOADER_DRIVERS_DISABLE=*nv*`). **What I checked** This was done on my PC, with the AI assistant's help: - With #1520 reverted locally, the whole `shader_recompiler_compute_tests` suite passes on the RTX 3090. With #1520 back, the failure returns. - I also ran a bigger test for this instruction (1548 input values, compared with an exact result computed on the CPU). The AI assistant wrote it. On `main`, on the RTX 3090, 869 of the 1548 results are one step too high, in almost every range of values. On the AMD GPU there are no errors. I don't know why. **About me and the AI** I can't explain the graphics details myself. An AI assistant (Claude) helped me run the tests, read the results, and write a possible fix and the bigger test. The numbers above come from runs on my PC. I'm not opening a pull request, because I can't judge whether the fix is the right approach. If it's useful, I can share the fix and the test, or run more tests on my two GPUs. I ran the failing test myself.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:00:07 +00:00
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 02:03 UTC · original

This may explain why the test passes on AMD. The AMD driver compiles packHalf2x16 to a round-toward-zero pack (v_cvt_pkrtz_f16_f32 on the Ryzen iGPU, v_cvt_pk_rtz_f16_f32 on the RX 9070 XT), so the correction step in EmitPackFloat2x16Rtz never has to fire. A small compute shader on both my AMD GPUs (RX 9070 XT and Ryzen 7600X iGPU, driver 26.8.1) gives:

input packHalf2x16 nearest-even
0x33c00000 (1.5 * 2^-24) 0x0001 0x0002
0x3e22f983 (1/(2*pi)) 0x3117 0x3118
0x3f801001 0x3c00 0x3c01
0x477ff000 (65520) 0x7bff 0x7c00

unpackHalf2x16 of each result returns that truncated half, not x.

So the AMD pass does not test the correction. On a GPU whose packHalf2x16 rounds to nearest, the correction has to work for every input that rounds up. 869 of 1548 results one step too high suggests the correction is not taking the unit off on the RTX 3090. That would happen, for example, if unpackHalf2x16(packHalf2x16(x)) comes back as x there instead of the rounded half. I have no NVIDIA GPU, so that part is a guess.

@⁠KelvinSilvaDev, if you'd like to check it: a compute shader that stores packHalf2x16(vec2(x, 0.0)) and floatBitsToUint(unpackHalf2x16(packHalf2x16(vec2(x, 0.0))).x) for x = uintBitsToFloat(0x33c00000u) should give 0x00000002 and 0x34000000 on a round-to-nearest GPU. 0x33c00000 in the second word would mean the round trip is skipped.

Written with Claude Code (AI): it wrote and ran the shader on my PC and checked the ISA; I read this comment before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-17 02:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1575#issuecomment-6228274080) This may explain why the test passes on AMD. The AMD driver compiles `packHalf2x16` to a round-toward-zero pack (`v_cvt_pkrtz_f16_f32` on the Ryzen iGPU, `v_cvt_pk_rtz_f16_f32` on the RX 9070 XT), so the correction step in `EmitPackFloat2x16Rtz` never has to fire. A small compute shader on both my AMD GPUs (RX 9070 XT and Ryzen 7600X iGPU, driver 26.8.1) gives: | input | `packHalf2x16` | nearest-even | |---|---|---| | `0x33c00000` (1.5 * 2^-24) | `0x0001` | `0x0002` | | `0x3e22f983` (1/(2*pi)) | `0x3117` | `0x3118` | | `0x3f801001` | `0x3c00` | `0x3c01` | | `0x477ff000` (65520) | `0x7bff` | `0x7c00` | `unpackHalf2x16` of each result returns that truncated half, not `x`. So the AMD pass does not test the correction. On a GPU whose `packHalf2x16` rounds to nearest, the correction has to work for every input that rounds up. 869 of 1548 results one step too high suggests the correction is not taking the unit off on the RTX 3090. That would happen, for example, if `unpackHalf2x16(packHalf2x16(x))` comes back as `x` there instead of the rounded half. I have no NVIDIA GPU, so that part is a guess. @⁠KelvinSilvaDev, if you'd like to check it: a compute shader that stores `packHalf2x16(vec2(x, 0.0))` and `floatBitsToUint(unpackHalf2x16(packHalf2x16(vec2(x, 0.0))).x)` for x = `uintBitsToFloat(0x33c00000u)` should give `0x00000002` and `0x34000000` on a round-to-nearest GPU. `0x33c00000` in the second word would mean the round trip is skipped. Written with Claude Code (AI): it wrote and ran the shader on my PC and checked the ISA; I read this comment before posting it.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 02:07 UTC · original

I hope this helps

**@⁠Nawid3333** on GitHub · 2026-10-17 02:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1575#issuecomment-6228315698) I hope this helps
Author
Owner

@⁠Nmzik on GitHub · 2026-10-17 10:24 UTC · original

@⁠KelvinSilvaDev recheck with latest main

**@⁠Nmzik** on GitHub · 2026-10-17 10:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1575#issuecomment-6232780993) @⁠KelvinSilvaDev recheck with latest main
Author
Owner

@⁠ZrDaniel07 on GitHub · 2026-10-22 03:18 UTC · original

Data point on a newer NVIDIA GPU, current main: the test passes.

  • main @ 8502d8a, Windows 11, clang-cl 19.1.5, Release
  • NVIDIA GeForce RTX 5090 (Blackwell), driver 617.42
  • shader_recompiler_compute_tests.exe: all cases passed, including
    CvtPkrtzF16F32SubnormalRoundsTowardZero ok, CvtPkrtzF16F32RuntimeEdges ok, CvtPkrtzF16F32SdwaAndOutputModifiers ok

Not tested on a 3090, so I can't say whether it was fixed by a change on main or behaves differently on Blackwell.

AI use: Claude Code helped me build and run the test; I checked the output.

**@⁠ZrDaniel07** on GitHub · 2026-10-22 03:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1575#issuecomment-6331828057) Data point on a newer NVIDIA GPU, current `main`: the test passes. - `main` @ 8502d8a, Windows 11, clang-cl 19.1.5, Release - NVIDIA GeForce RTX 5090 (Blackwell), driver 617.42 - `shader_recompiler_compute_tests.exe`: `all cases passed`, including `CvtPkrtzF16F32SubnormalRoundsTowardZero ok`, `CvtPkrtzF16F32RuntimeEdges ok`, `CvtPkrtzF16F32SdwaAndOutputModifiers ok` Not tested on a 3090, so I can't say whether it was fixed by a change on main or behaves differently on Blackwell. AI use: Claude Code helped me build and run the test; I checked the output.
Author
Owner

@⁠KelvinSilvaDev on GitHub · 2026-10-22 16:22 UTC · original

Rechecked on latest main (d7c18966), same PC as before:

  • RTX 3090 (driver 617.14): shader_recompiler_compute_tests prints all cases passed, including the three CvtPkrtzF16F32* cases.
  • AMD Radeon iGPU (driver 25.10.30.02, NVIDIA hidden with VK_LOADER_DRIVERS_DISABLE=*nv*): --cvt-pkrtz-only passes all three. The full suite still stops earlier on this GPU, at the unrelated ImageTransitionState ... lost an aspect check.

The AI assistant also copied the logic of the new EmitF32ToF16RtzBits into a small CPU program and compared it with a separate round-toward-zero reference for all 2^32 inputs: no differences, and NaN stays NaN. I didn't run the round-trip shader from Nawid3333's comment, since main no longer uses PackHalf2x16 here.

So it's fixed for me. Thanks @⁠Nmzik, and thanks @⁠Nawid3333 and @⁠ZrDaniel07 for the extra data. Closing this.

AI use: Claude Code built and ran these tests on my PC and wrote the CPU check. I read the results before posting.

**@⁠KelvinSilvaDev** on GitHub · 2026-10-22 16:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1575#issuecomment-6345707532) Rechecked on latest `main` (`d7c18966`), same PC as before: - RTX 3090 (driver 617.14): `shader_recompiler_compute_tests` prints `all cases passed`, including the three `CvtPkrtzF16F32*` cases. - AMD Radeon iGPU (driver 25.10.30.02, NVIDIA hidden with `VK_LOADER_DRIVERS_DISABLE=*nv*`): `--cvt-pkrtz-only` passes all three. The full suite still stops earlier on this GPU, at the unrelated `ImageTransitionState ... lost an aspect` check. The AI assistant also copied the logic of the new `EmitF32ToF16RtzBits` into a small CPU program and compared it with a separate round-toward-zero reference for all 2^32 inputs: no differences, and NaN stays NaN. I didn't run the round-trip shader from Nawid3333's comment, since `main` no longer uses `PackHalf2x16` here. So it's fixed for me. Thanks @⁠Nmzik, and thanks @⁠Nawid3333 and @⁠ZrDaniel07 for the extra data. Closing this. AI use: Claude Code built and ran these tests on my PC and wrote the CPU check. I read the results before posting.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/KytyPS5--KytyPS5#1575
No description provided.