GPU tests: what translated 16-bit float math costs against the host's (34x on an RTX 5070 Ti; for #2384) #2806
No reviewers
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!2806
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2806"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 21:05 UTC · original
0xkn0wh3r3:bench/f16-math→main· +1021 −0 · 4 files · 7 commits · openStacked on #2804, whose benchmark helpers this shares. Only the last commit is new. It's tests only: nothing outside tests changes.
#2384 asks whether translated 16-bit float math is worth doing natively. Nobody had measured what the translator's software rounding costs per operation. This measures it.
What
The translator does a console f16 operation in f32 and rounds each result to f16 with an integer sequence (
Lower::narrow16, round to nearest even), widening each source withf16tof32. A packed instruction such asv_pk_fma_f16does that for both halves.crates/victory-gpu/src/f16_bench.rsruns a dependent chain of packed FMAs in three ways:narrow16: as translated, with the rounding sequence ported to HLSL;f32tof16: the same, with the host's conversion instead of the sequence. This is not correct as a translation: on some GPUs the host's conversion rounds toward zero.half2: the host's native 16-bit math (-enable-16bit-types, SM 6.2+). This is what a native path on hosts withNative16BitShaderOpsSupportedwould emit.Results
RTX 5070 Ti, driver 621.24: 262,144 threads × 1,024 packed FMAs, median of 5.
narrow16narrow16f32tof16half2So each translated f16 operation costs about 34 native ones, in any program that is ALU-bound on f16 math.
How much of a world frame that is depends on how much f16 math the hot shaders do. Measuring that needs the title's shaders, which are not here.
One caveat for a native path is rounding. The probes on #2384 found that an RTX 4070 Ti's native half FMA rounds once, as RDNA2's
v_fma_f16does. The current widen, fuse in f32, then round path rounds twice, so it can differ in rare cases. WARP's native FMA differs from both.Tests
narrow16_rounds_fused_results_to_nearest_evenchecks thenarrow16shader against a CPU reference. The cases are:mad, so either rounded result is accepted. A NaN result may lose its payload in the host's f32 math, so any NaN is accepted for one.#[ignore]d:dxcompiler.dll, as #2804 does, and need it and a GPU, or do nothing.cargo clippy -p victory-gpu --all-targets -- -D warningsis clean, with and without--features diagnostics.Not done
@fuzeofficlal on GitHub · 2026-11-25 21:24 UTC · original
Reviewed and benchmarked
19b53ab3on Windows 11 + NVIDIA GeForce RTX 5090 (Blackwell) (+ WARP).Review & correctness
steps = 1024from runtimecbuffer, loop-carriedx = fma2(x, b, c)dependency, non-degenerate normal/subnormal inputs, copies kept outside timed dispatch).narrow16_rounds_fused_results_to_nearest_evenpassed on both RTX 5090 and WARP;cargo clippy --locked -p victory-gpu --all-targets(default &diagnostics): 0 warnings;cargo xtask policy: 186 files ok (stacked cleanly on#2804).RTX 5090
--releaseresults (f16_bench --ignored --nocapture)4,096 groups × 64 threads × 1,024 packed FMAs each, median of 5:
G f16 FMAs/s)narrow16narrow160.583 ms921.41.0×f32tof160.051 ms10,512.011.4×half20.019 ms28,976.231.4×@xndbogdan on GitHub · 2026-11-25 21:53 UTC · original · edited 2026-11-25 21:55 UTC
Results on AMD hardware, for comparison with the NVIDIA runs above.
Setup: AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029, Intel Xeon E5-2670 v3 (times are GPU timestamps, so the CPU is not in them), Windows 11 IoT Enterprise LTSC 26100, Windows SDK 10.0.26100
dxc.exe,19b53ab,--release. No game data.narrow16_rounds_fused_results_to_nearest_even: passed.f16_bench(4,096 groups × 64 threads × 1,024 packed FMAs, median of 5):narrow16narrow16f32tof16half2So the software rounding's cost holds on AMD too: 26× here, against 34× on the RTX 5070 Ti and 31× on the RTX 5090. This is one run.
AI-assisted (Claude Code). The tests and benchmark ran on the machine above.
@steven-seagull27 on GitHub · 2026-11-26 01:52 UTC · original
On an RTX 5080 the native
half2path was 33.7× faster at 1,024 packed FMAs per thread. At one packed FMA per thread the dispatch times were 3.74 µs fornarrow16and 3.55 µs forhalf2.I ran
5dfeaf69in release mode on Windows 26300.10075, driver 621.40, SDK 10.0.26100.0. I checked the actual D3D12 device LUID against DXGI. Five fresh processes ran the PR's benchmark with unchanged HLSL, inputs and timing loop. Each process took its median of five GPU timestamps after warm-up, at 4,096 × 64 threads. The values below are medians across the five processes.narrow16narrow16f32tof16half2For a shorter-chain comparison, I changed only the runtime
stepsconstant between dispatches, held thread count and buffer traffic fixed, and rotated variant order across nine timed samples per variant after warm-up. Medians from that run:narrow16µsf32tof16µshalf2µshalf2speedupThe long chain reproduces the reported arithmetic gain. The shorter dispatches show how strongly the speedup depends on the amount of arithmetic between loads and stores in this kernel. I did not measure a game frame.
The PR's rounding test also passed on both the RTX 5080 and WARP. I posted an all-normal FMA regression pair and a 16,384-input precision comparison in #2384. Tested locally with Codex assistance.
@Marvisak on GitHub · 2026-11-26 02:18 UTC · original · edited 2026-11-26 07:22 UTC
Automated triage for the maintainers.
Thanks for confirming. Nothing has changed since the last review (same head): the PR still carries #2804, and whether about 1,000 lines of benchmark code belong in the tree needs the maintainer's decision. Rebasing onto
mainonce #2804 is settled, as you suggest, would make it reviewable on its own.CI: passing.
Generated by Claude Code
@liandraraiane on GitHub · 2026-11-26 02:48 UTC · original
RTX 3060 (driver 610.88, Windows 11 26200, dxc 10.0.26100.0), on
19b53ab(before the in-process compile commit), 7 runs, ms per dispatch: narrow16 5.086 (5.059–5.283), f32tof16 0.670 (0.668–0.671, 7.6x), half2 0.136 (0.136–0.137, 37.4x).narrow16_rounds_fused_results_to_nearest_evenpasses on hardware.AI use: Claude Code ran the benchmarks on this machine and drafted this comment.
@0xkn0wh3r3 on GitHub · 2026-11-26 06:42 UTC · original
Agreed on both points. The f16 benchmark uses #2804's helpers (
marks_bench::{compile_hlsl, dxc, heap, buffer, Gpu}), which is why it's stacked on that PR. Once #2804 is decided, I'll rebase this onto main so the diff is onlyf16_bench.rs. If #2804 closes, I'll keep just the helpers it needs. Whether ~1,000 lines of benchmark code belong in the tree is your call; the measurements are already on #2384, so this can close without losing them.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.