Honour directed rounding in v_mul_f16 #4805

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

@⁠andrewpozdnakov7-jpg on GitHub · 2026-12-01 09:24 UTC · original
andrewpozdnakov7-jpg:codex2/fix/f16-mul-rounding → main · +51 −1 · 2 files · 1 commits · open

What it changes

v_mul_f16 now honours the half-precision modes that round toward positive and negative infinity. The product of two finite halves, including power-of-two output scaling, is exact in f32. The translator truncates the product to a half, widens it for comparison and advances one encoding when the truncated result is on the wrong side of the product.

AMD RDNA 2 instruction and rounding modes · Original scalar implementation in VIctory #3804

How it was tested

  • GPU and profile: a synthetic shader on signed Microsoft WARP 1.0.22. In-game testing is pending.
  • Before: at 5fabb46e, six of the 32 results differed, three in each infinity mode. The nearest-even and toward-zero cases matched.
  • After: all 32 results matched on f6016ffb5f68a4abfea37ca92270379fcb7b3613, covering finite inexact products, signed underflow, overflow and exact results.
  • For shader changes, the wave sizes tested: the default wave configuration of the WARP test.
  • Focused emit::valu_tests::f16_multiply_respects_directed_rounding passed on Windows/MSVC. cargo xtask policy --staged passed for both files.
  • CI on main has five existing Clippy errors. Main CI / check · Shared lint fix #4708

Checked for overlap

  • I searched issues and PRs for scalar half multiplication and directed rounding and checked the changed files. Related: closed #2833 covered using native half arithmetic.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-12-01 09:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4804) `andrewpozdnakov7-jpg:codex2/fix/f16-mul-rounding` → `main` · +51 −1 · 2 files · 1 commits · open ## What it changes `v_mul_f16` now honours the half-precision modes that round toward positive and negative infinity. The product of two finite halves, including power-of-two output scaling, is exact in f32. The translator truncates the product to a half, widens it for comparison and advances one encoding when the truncated result is on the wrong side of the product. [AMD RDNA 2 instruction and rounding modes](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf#page=143) · [Original scalar implementation in VIctory #3804](https://github.com/Marvisak/VIctory/pull/3804) ## How it was tested - GPU and profile: a synthetic shader on signed Microsoft WARP 1.0.22. In-game testing is pending. - Before: at `5fabb46e`, six of the 32 results differed, three in each infinity mode. The nearest-even and toward-zero cases matched. - After: all 32 results matched on `f6016ffb5f68a4abfea37ca92270379fcb7b3613`, covering finite inexact products, signed underflow, overflow and exact results. - For shader changes, the wave sizes tested: the default wave configuration of the WARP test. - Focused `emit::valu_tests::f16_multiply_respects_directed_rounding` passed on Windows/MSVC. `cargo xtask policy --staged` passed for both files. - CI on `main` has five existing Clippy errors. [Main CI / check](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46563306780/job/142355972539) · [Shared lint fix #4708](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/4708) ## Checked for overlap - [x] I searched issues and PRs for scalar half multiplication and directed rounding and checked the changed files. Related: closed #2833 covered using native half arithmetic. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 09:26:59 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-12-01 12:38 UTC · original

Verification of this PR (AI-assisted: Hy4 flash), source only, no game data.

Windows / rustc 1.100.0 / MSVC. Worktree at head f6016ffb, dedicated per-worktree CARGO_TARGET_DIR (D:\Victory-Contrib\NVIDIA-Contrib\target-4804), never shared.

Negative control on base 5fabb46e:

  • git grep -F f16_multiply_respects_directed_rounding 5fabb46e -- . -> exit 1 (test is new)
    Whitespace: git diff --check 5fabb46e..f6016ffb -> exit 0, clean.
cargo test --locked -p victory-shader --lib -- emit::valu_tests::f16_multiply_respects_directed_rounding --exact --test-threads=1 --quiet

-> test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 546 filtered out.

The helper f16_directed_product and the test are both new; the test compares against a separate reference product rather than reusing the emitter, so it is not tautological.

GPU/driver: N/A (lowering/rounding test, no device).

Verdict: PASS for the new synthetic test on this host.

**@⁠cloph-dsp** on GitHub · 2026-12-01 12:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4804#issuecomment-7311435551) Verification of this PR (AI-assisted: Hy4 flash), source only, no game data. Windows / rustc 1.100.0 / MSVC. Worktree at head f6016ffb, dedicated per-worktree CARGO_TARGET_DIR (D:\Victory-Contrib\NVIDIA-Contrib\target-4804), never shared. Negative control on base 5fabb46e: - `git grep -F f16_multiply_respects_directed_rounding 5fabb46e -- .` -> exit 1 (test is new) Whitespace: `git diff --check 5fabb46e..f6016ffb` -> exit 0, clean. ``` cargo test --locked -p victory-shader --lib -- emit::valu_tests::f16_multiply_respects_directed_rounding --exact --test-threads=1 --quiet ``` -> `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 546 filtered out`. The helper `f16_directed_product` and the test are both new; the test compares against a separate reference product rather than reusing the emitter, so it is not tautological. GPU/driver: N/A (lowering/rounding test, no device). Verdict: PASS for the new synthetic test on this host.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/4805/head:github-bot/gh-4804'
git switch 'github-bot/gh-4804'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4804'
git switch 'github-bot/gh-4804'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4804'
git switch 'github-bot/gh-4804'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4804'
git switch 'main'
git merge --squash 'github-bot/gh-4804'
git switch 'main'
git merge --ff-only 'github-bot/gh-4804'
git switch 'main'
git merge 'github-bot/gh-4804'
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/trustno1-coder--VIctory-NVIDIA!4805
No description provided.