Tests: f32 and f16 transcendentals on the GPU against f64 references #638
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/643"
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?
Imported from ivall/xcl. Originally posted by acaracargo on 2026-11-24T02:49:23Z.
Adds GPU tests for
v_rcp,v_rsq,v_sqrt,v_log,v_exp,v_sinandv_cos, in both f32 and f16, against f64 references.Special results such as zeros, infinities, NaN and overflow are checked exactly. Other results are checked within the following tolerances:
The worst measured f32 errors were 0 for rcp, 8.4e-8 for rsq, 7.4e-8 for sqrt, 1.2e-7 for log, 1.1e-7 for exp, 6.8e-5 for sin and 9.6e-5 for cos. The f16 error was about 1.6 ulp at most.
The sin / cos results also show that converting turns to radians before range reduction increases the error with larger arguments. This is worth investigating separately rather than changing the translation in a test-only PR.
#530 covers the f64 forms of rcp and rsq, which these tests do not touch.
What is in it
crates/xcl/src/gpu/recomp/tests.rs:gpu_transcendental_f32andgpu_transcendental_f16.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug.cargo test --workspace -- --test-threads=4on232ee73: 686 passed, 0 failed, 41 ignored (main9ce2070: 684 / 0 / 41).gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).log2()withlog(), replacingexp2()withexp()and removing the 2pi factor from the f16 cosine translation all cause the tests to fail (checked locally, reverted).Regression run
Not tested
rsq(-0)because console behavior is unverified.AI use
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T03:18:22Z.
Test run of
232ee73f36c7b8fa0c4e9fe30c96e29a4b3063f0on AMD RDNA4 (native wave64). I merged it onto currentmain63cdc25locally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 694 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 654 passed, 0 failed, 21 ignoredSKIPPED;gpu_transcendental_f32andgpu_transcendental_f16pass.Review:
v_sin/v_costake their input in turns (turn(x, f64::sin)), as the hardware does, and inputs past |x| > 256 are left out where the hardware's own reduction differs; the special values are compared exactly and the rest within a relative tolerance (absolute for sin / cos). This is the first AMD run.Not tested: no retail title (not needed for a test-only change), release build; the PR's head on its old base was not run, only its merge onto
main.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by NAbobo101 on 2026-11-24T03:21:11Z.
Test run of
232ee73f36c7b8fa0c4e9fe30c96e29a4b3063f0on NVIDIA Blackwell with an older DXC than the PR's run (1.8 instead of 1.9), tested as is (it also merges cleanly onto currentmaindd2ae9a).Tested
x86_64-pc-windows-msvc; DXC 1.8.2502.11 (Windows SDK 10.0.26100); debug.cargo test --workspace --no-fail-fast -- --test-threads=4: 686 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.gpu_transcendental_f32andgpu_transcendental_f16pass, and three more runs of both (--nocapture) printed the same worst errors each time:Not tested
AI use
Imported from ivall/xcl. Originally posted by lordon1a on 2026-11-24T03:38:09Z.
Independent GPU test report on
232ee73:Tested
616.64, wave32, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200),rustc 1.100.0(x86_64-pc-windows-gnullvm), debug build, DXC1.9.2609.5(01b62ad4)cargo test -p xcl --lib gpu_transcendental_ -- --nocapture0.97s(gpu_transcendental_f32max err: rcp0.0, rsq8.43e-8, sqrt7.45e-8, log1.19e-7, exp1.09e-7, sin6.77e-5, cos9.57e-5;gpu_transcendental_f16max err: rcp8.24e-4, rsq4.29e-4, sqrt4.88e-4, log6.51e-4, exp6.93e-4, sin/cos4.88e-4)Not tested
AI use
232ee73in a detached worktree, audited the diff, ran the GPU test, and posted this report.Imported from ivall/xcl. Originally posted by acaracargo on 2026-11-24T03:47:36Z.
@lordon1a Eline sağlık.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T05:53:39Z.
For when this lands: #818 (fix for #796) reduces
v_sin/v_cosin turns before scaling. With this PR'sgpu_transcendental_f32/_f16applied locally, both pass onmainand with #818 (RTX 3070, driver 616.56). The worst sin/cos errors drop from 6.8e-5 / 9.6e-5 (f32) to 1.2e-7 / 6.0e-8, and f16 sin from 4.9e-4 to 2.6e-4. So after #818 the f32 sin/cos tolerance could tighten well below 2^-10, and the skip of inputs above 256 turns could go: the RDNA2 ISA's own examples includesin(-MaxFloat) = 0andcos(-MaxFloat) = 1.AI-assisted (Claude Code).
upstream-sync referenced this pull request2026-11-24 19:06:45 +00:00
upstream-sync referenced this pull request2026-11-24 22:05:13 +00:00
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:42:30Z.
Tested
PR #643 was open at
232ee73f36c7b8fa0c4e9fe30c96e29a4b3063f0before and after the run. The checkout was clean and detached at that commit. The PR discussion and issue #42 contained no equivalent Arc result at either check.STOR-WINLAB, native Windows 11 Enterprise Evaluation 25H2 x64 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust/Cargo 1.100.0
x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5, debug test profile with debuginfo disabled.cargo test --locked -p xcl --lib --no-run --message-format=jsonfinished in 39.90 s outside the Arc lock, with two build jobs, incremental compilation disabled, dev/test debuginfo set to 0, andTEMP/TMPunderL:/XclTooling/pr643/temp.With
XCL_ADAPTER=A770,XCL_DIRECT_DXIL=0, andXCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64, the lock wrapper ran the two prebuilt fixtures.$fixtureBinarycame from Cargo's artifact output.2 passed, 0 failed, 0 ignored, 0 capability skips. Both fixtures reached their final assertions after GPU dispatch and readback. From the fixture loops, f32 evaluated 175 result comparisons (0.60 s) and f16 evaluated 159 (0.21 s) across reciprocal, reciprocal square root, square root, log2, exp2, sine and cosine. They exercised signed-zero inputs, infinities, NaN and turn-based angles where the fixtures include those cases. Both used split logical wave64 on 32-lane Arc hardware, as selected by the checked-in runner.
The Cargo build, both native fixture processes, and the Arc wrapper each returned
0. The wrapper logged release of the GPU lock.Not tested
Native wave64, standalone logical wave32, direct DXIL,
rsq(-0), f16 results filtered by the fixture's overflow guard, angles outside the fixture's domain, console parity, other fixtures, the workspace suite, and retail smoke runs.AI use
T3 Code / Codex (
gpt-6.2-sol) ran the verification and wrote this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts againstpr643/{f32,f16}.stdout.logand published.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T12:31:37Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:42:42Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by relativespace2K on 2026-11-30T03:06:54Z.
merge-check
base:
53e85fb1head:
232ee73f36merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2790 passed, 6 failed, 49 ignored; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in
--test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base53e85fb1alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR; both new GPU tests passed here and neither is among the SKIPPED lines, so they really ran on the RX 6800 XT. 13 SKIPPED lines, all environmental: no D3D12 debug layer / d3d12SDKLayers.dll, no heap windows, no GPU_UPLOAD, per-lane f16/f32 forms refused.review: no blocking finding; one file, every line read. Both tests compare the GPU against f64 references computed in the test, exactly for the special values (zeros, infinities, NaN, negatives) and within a stated tolerance otherwise, and both leave out the cases where the console's answer is genuinely unsettled, each with a comment saying why:
rsq(-0), sin/cos beyond the ISA's ±256 turns, and the f16 conversion that rounds toward zero and gives 65504 instead of an infinity (#111). The sin/cos references lower the argument in revolutions (the console's convention) and the tolerance carries a note on how the error grows with the turn count, which matches the failure mode a reviewer would look for. One note, not blocking:TOL[5]/TOL[6]are2^-10(9.77e-4) while the comment cites D3D's own 8e-4 limit for sin/cos, so the test is a little looser than the spec it names; tightening it to 8e-4 would make the test catch an error D3D itself would reject. No duplicate: #1576, #1639 and #638 cover other op families.performance: none: tests only.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T03:33:56Z.
merge-check
base:
cfb9753a8chead:
232ee73f36merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2836 passed, 0 failed, 51 ignored; SKIPPED: 24 lines (22
no wave64, 2no heap windows), the same as on the base; failing: none. Base alone on this PC: 2834 passed, 0 failed, 51 ignored. The two new tests are not among the skipped ones:gpu::recomp::tests::gpu_transcendental_f32andgpu_transcendental_f16ran on this card and passed in the suite and in 4 separate runs with--nocapture.review: whole diff read (+130/-0, tests only,
gpu/recomp/tests.rs). A second vendor for the numbers: on this NVIDIA card the worst f32 errors were rcp 0, rsq 8.4e-8, sqrt 7.4e-8, log 1.19e-7, exp 1.09e-7 relative, against the test's 4.77e-7 (4 ulp), and sin 6.8e-5, cos 9.6e-5 absolute against 9.77e-4. The f16 worst errors were 4.3e-4 to 8.2e-4 relative for rcp, rsq, sqrt, log and exp, and 4.9e-4 absolute for sin and cos, the same in every run. One note, not a blocker: the 4 ulp bound for log and exp is tighter than what D3D promises for those functions, so the f32 test can fail on a driver that is within the spec; here the margin is about four times. No test of these instructions existed on main, the names do not collide, and each test is one dispatch.performance: none, tests only.
scripts/smoke.ps1, 60 s of a retail title, release, as an extra: 1664 frames and 16062 MB peak commit against 1678 and 1677 frames, 15737 and 16476 MB on the base. No device removal, no crash.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Fable 5.2 ran the build, suite and tests and wrote this; Claude Opus 5.5 read the diff first)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:52:06Z.
Triage (#1607) – head
232ee73#1169 (opened later) also tests the f32 / f16 rcp, rsq, sqrt, log and exp ops on the GPU, but on exact powers of two, with VOP3 abs/neg/clamp/op_sel and no sin/cos. This PR checks accuracy and special values against f64, including sin/cos in revolutions. The two overlap without being the same test. #1672 / #1639 also touch some of these ops.
No problems found in the diff. The sin/cos absolute tolerance (2^-10 at up to ~256 turns) was measured on one NVIDIA GPU only.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.