Shaders: round FP16 transcendentals to nearest in either mode #3617

Open
github-bot wants to merge 1 commit from github-bot/gh-3617 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 22:23 UTC · original
andrewpozdnakov7-jpg:codex2/fp16-transcendental-rounding → main · +53 −2 · 2 files · 1 commits · open

RDNA2 rounds seven FP16 transcendental instructions to nearest even under both values of the tested rounding field. The published RX 6700 XT sweep ran all input encodings with the original and round-to-zero settings, and the harness validated the MODE bits on the device. Sweep results · MODE check

Use nearest-even narrowing for v_rcp_f16, v_sqrt_f16, v_rsq_f16, v_log_f16, v_exp_f16, v_sin_f16, and v_cos_f16. Ordinary FP16 conversions continue to use the requested rounding mode.

On Windows with app-local WARP 1.0.22 and D3D12 Agility 1.620.2, the synthetic regression reports 7 mismatches out of 28 readbacks on 63bcca4, all with FP_ROUND=3. The patch passes all 28. For example, v_rcp_f16(17) changes from 0x2b87 to 0x2b88 in that mode. The existing conversion control passes all 38 inputs under both modes. Inputs are synthetic.

Coordination claim: #1633

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 22:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3617) `andrewpozdnakov7-jpg:codex2/fp16-transcendental-rounding` → `main` · +53 −2 · 2 files · 1 commits · open RDNA2 rounds seven FP16 transcendental instructions to nearest even under both values of the tested rounding field. The published RX 6700 XT sweep ran all input encodings with the original and round-to-zero settings, and the harness validated the MODE bits on the device. [Sweep results](https://github.com/ubiquitarianism/leonida/blob/a73a57e1339be072baf5522351c8ec7f1482b56b/docs/shader_validation.md#L1360-L1425) · [MODE check](https://github.com/ubiquitarianism/leonida/blob/a73a57e1339be072baf5522351c8ec7f1482b56b/tools/f16_trans_sweep.py#L220-L241) Use nearest-even narrowing for `v_rcp_f16`, `v_sqrt_f16`, `v_rsq_f16`, `v_log_f16`, `v_exp_f16`, `v_sin_f16`, and `v_cos_f16`. Ordinary FP16 conversions continue to use the requested rounding mode. On Windows with app-local WARP 1.0.22 and D3D12 Agility 1.620.2, the synthetic regression reports 7 mismatches out of 28 readbacks on `63bcca4`, all with `FP_ROUND=3`. The patch passes all 28. For example, `v_rcp_f16(17)` changes from `0x2b87` to `0x2b88` in that mode. The existing conversion control passes all 38 inputs under both modes. Inputs are synthetic. Coordination claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 AI-assisted with OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 22:26:37 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 22:25 UTC · original

Verified 8bfad4c against 63bcca4 on Windows with app-local WARP 1.0.22 and D3D12 Agility 1.620.2. The same synthetic fixture went from 7 wrong outputs in 28 readbacks to 28 correct. The 38-input FP32-to-FP16 control still distinguishes the two rounding settings. Both strict shader Clippy configurations and the repository asset policy passed. Windows CI for this head

I also ran both regressions on 4ccc63e with #3609. It passes the seven-op fixture and the exp midpoint test, including 16 readbacks across the plain, abs, neg, and clamp variants. The two changes can be reviewed separately, with the combined branch available for an integration test.

Please keep the Git author on a cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if the work is folded into another commit.

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 22:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3617#issuecomment-7229316566) Verified `8bfad4c` against `63bcca4` on Windows with app-local WARP 1.0.22 and D3D12 Agility 1.620.2. The same synthetic fixture went from 7 wrong outputs in 28 readbacks to 28 correct. The 38-input FP32-to-FP16 control still distinguishes the two rounding settings. Both strict shader Clippy configurations and the repository asset policy passed. [Windows CI for this head](https://github.com/Marvisak/VIctory/actions/runs/46076350312/job/140764856572) I also ran both regressions on [`4ccc63e` with #3609](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/4ccc63e54222acc47718686f6994bddb22c8e476). It passes the seven-op fixture and the exp midpoint test, including 16 readbacks across the plain, abs, neg, and clamp variants. The two changes can be reviewed separately, with the combined branch available for an integration test. Please keep the Git author on a cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if the work is folded into another commit. AI-assisted with OpenAI Codex.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3617/head:github-bot/gh-3617'
git switch 'github-bot/gh-3617'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3617'
git switch 'github-bot/gh-3617'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3617'
git switch 'github-bot/gh-3617'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3617'
git switch 'main'
git merge --squash 'github-bot/gh-3617'
git switch 'main'
git merge --ff-only 'github-bot/gh-3617'
git switch 'main'
git merge 'github-bot/gh-3617'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!3617
No description provided.