Repository navigation
Tools: every f16 input through the f16 transcendentals on the hardware oracle (FUZZ-29) - #1310
Merged
Merged
Conversation
…e oracle (FUZZ-29) tools/f16_trans_sweep.py runs all 65,536 f16 bit patterns through v_exp/log/rcp/rsq/sqrt/sin/cos_f16 natively (8 raw kernels of 1,024 threads per op), in wave32 and wave64 and five MODEs (IEEE, f16 denormal mode, f16 round toward zero), reads MODE back first, and compares each word with the exact result correctly rounded to f16 (decimal, 60 digits; sin/cos reduced in turns). It counts bit-exact, 1 ulp, >1 ulp, denormals read or written as zero, signalling NaNs kept or quieted, and the inputs where SPIR-V is undefined, and lists the words of 23 special inputs. On an RX 6700 XT (gfx1031): the five non-trigonometric ops are correctly rounded on every non-NaN input; sin/cos are exact in turns over the whole f16 range (14 and 4 results 1 ulp off, all at |x| <= 1), while the f32 product 6.2831855 * x is >1 ulp off on 16,366 sin and 2,036 cos inputs (ItsNotRexed#594). denorm_mode_16_64 = 0 flushes denormal operands and results, FP_ROUND's f16 field is ignored, IEEE only quiets signalling NaNs. The results go into docs/design.md (a new f16 transcendentals row) and docs/shader_validation.md.
Contributor
|
Tested
No game files. |
2 tasks done
1 of 2 tasks
liang-kai-shui
added a commit
to liang-kai-shui/Leonida
that referenced
this pull request
Nov 22, 2026
The Known approximations row still said v_cos_f16, v_exp_f16 and v_log_f16 were unmeasured, although the f16 transcendentals row from ItsNotRexed#1310 (FUZZ-29) records that the f16 field of FP_ROUND is ignored by all seven transcendentals. Cite that row instead; the translator already treats them the same, so no code change.
liang-kai-shui
added a commit
to liang-kai-shui/Leonida
that referenced
this pull request
Nov 22, 2026
The Known approximations row still said v_cos_f16, v_exp_f16 and v_log_f16 were unmeasured, although the f16 transcendentals row from ItsNotRexed#1310 (FUZZ-29) records that the f16 field of FP_ROUND is ignored by all seven transcendentals. Cite that row instead; the translator already treats them the same, so no code change. main currently carries this row three times after the merge round, so the sentence is fixed in each copy.
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim: FUZZ-29 in #1218 (claiming comment).
What and why
The
16-bit resultsrow ofdocs/design.mdlistedv_exp_f16/v_log_f16, and NaN and denormal operands, as unverified. f16 has only 65,536 bit patterns, so this runs every input instead of sampling.tools/f16_trans_sweep.pyruns all 65,536 inputs throughv_exp_f16,v_log_f16,v_rcp_f16,v_rsq_f16,v_sqrt_f16,v_sin_f16andv_cos_f16on the hardware oracle.s_getreg_b32before any sweep.decimal, 60 digits; sin/cos reduced in turns). That is the translator's rule (widen to f32, the GLSL.std.450 function, round to nearest even) with a perfect f32 function. Inputs where the SPIR-V is undefined are tabulated, not judged.keep16. Also the words of 23 special inputs, and--jsonfor everything.tests/test_f16_trans_sweep.pychecks:On a GPU it also checks exp2 of integers and that wave32 equals wave64.
Docs. A new
f16 transcendentalsrow indocs/design.md; the16-bit resultsrows now point to it. A section indocs/shader_validation.mdhas the method and the full result.The tool picks its store mnemonics by family, so it doesn't depend on #1265's
gfx10_spelling. On Linux it needs #1265's backend to run; I ran it with #1265 merged intomainlocally (tested there, see #1265 comment). The Windows/HIP path usesrunner.open_oracle()unchanged, but I haven't run it.Result: RX 6700 XT (gfx1031, Navi 22), Linux 7.3.5, amdgpu, libdrm 2.4.134, clang 23.1.5
wave32 and wave64 gave the same word for every input of every op in every mode. There was no GPU fault, timeout or reset in the kernel log.
keep16: IEEE 0, f16 denormals kept)v_exp_f16v_log_f16v_rcp_f16v_rsq_f16v_sqrt_f16v_sin_f16v_cos_f16maincomputes today, 16,366 sin and 2,036 cos inputs are more than 1 ulp off, up to 9,944 ulp. For example, sin of 64,640 turns gives 0.0267 instead of 0. Reducing in turns first, as Translator: reduce v_sin/v_cos in turns before scaling by 2*pi #1283 and Translator: v_sin/v_cos reduce with x - RoundEven(x), contract row and GPU test (SHADER-88 follow-up to #1283) #616 do, is the hardware's order. For f16 it must hold up to 65,504 turns. cc @dcastell1 @esteban-dcp.denorm_mode_16_64, for operands and results. With 0, a denormal operand gives the word of a zero of its sign, and denormal results become ±0 (831 for exp, 4,094 for rcp). With 3, both are kept. The f32 transcendentals flush in both modes, so f16 is different.f32_fuzz.0xfe00Gen.f16_bitsquiets every NaN, while the hardware keeps a signalling NaN with IEEE off.Tested
python -m pytest tests --ignore=tests/semantic: 3,296 passed, 33 skipped.python -m unittest discover -s tests/semantic: 1,171 OK.tests/test_f16_trans_sweep.py: 10 passed, 1 skipped without a device; 11 passed with it.Checklist
docs/design.md, with how it was confirmed. (No new rule. The f16 transcendentals row records measured hardware behaviour and what the translator does not model yet.)AI-assisted (Claude Code): it wrote the sweep, the reference and the tests, ran them on the RX 6700 XT, and wrote the docs.
🤖 Generated with Claude Code