Skip to content

rdna2spirv: the seven f16 transcendentals are measured, not assumed - #4714

Closed
liang-kai-shui wants to merge 1 commit into
ItsNotRexed:mainfrom
liang-kai-shui:fix/f16-transcendental-comments
Closed

liang-kai-shui wants to merge 1 commit into
ItsNotRexed:mainfrom
liang-kai-shui:fix/f16-transcendental-comments

Conversation

@liang-kai-shui

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #4683 (comment)

Follow-up to @Jadiac5's note on #1893 (merged). tests/test_mode_round.py:123 had already been updated to cite the exhaustive sweep; two comments in the translator still called the same rounding "unmeasured, assumed".

What and why

  • tools/rdna2spirv.py:5966 (sin/cos f16 path): # sin ignores MODE rounding on hardware (RX 6800, SHADER-35); cos is unmeasured, assumed like it
  • tools/rdna2spirv.py:7762-7763 (rcp/rsq/sqrt/sin/exp/log/cos f16): # ... exp, log (and cos below) are unmeasured, assumed like them: nearest even always.

Both contradict the measured f16 transcendentals row in docs/design.md (FUZZ-29 / #1310 sweep, plus the exhaustive 65,536-input RNE-vs-RTZ gfx1036 measurement in SHADER-132): all seven ignore the f16 FP_ROUND field, so nearest-even always is measured, not assumed. The comments now point at that row.

Comment-only: the emitted SPIR-V and the runtime contract are unchanged.

Tested

  • python -m pytest tests/test_mode_round.py -q -> 74 passed (the mode-rounding contract tests, including test_transcendental_f16_ignores_mode for all seven ops).
  • python -m compileall -q tools/rdna2spirv.py clean; git diff --check clean; one file, +3/??.
  • No game data, no hardware run needed.

AI-assisted.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md ??not applicable (comments only).

Two comments still called cos/exp/log f16 rounding "unmeasured, assumed"
after the FUZZ-29 sweep (ItsNotRexed#1310) and the exhaustive gfx1036 RNE-vs-RTZ
measurement (SHADER-132) landed in the f16 transcendentals row. Point at
that row instead; comment-only, the emitted SPIR-V is unchanged.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at 4ff0db82b on Windows 11: pytest tests/test_mode_round.py -q -> 74 passed; git diff --check clean.

The change is comment-only: the f16 sin/cos/exp/log comments no longer call the three unmeasured, since all seven f16 transcendentals are measured (the docs/design.md f16 transcendentals row already states it). No behaviour change; no blocking issue.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 4ff0db82 on Windows 11, Python 3.15.2: pass.

  • python -m pytest tests/test_mode_round.py -q: 74 passed — the mode-rounding contract holds with the corrected comments.
  • Verified the change is comment-only (3 lines touched, no emitted-code edits): the two "unmeasured, assumed" notes now point at the measured f16 transcendentals row.
  • git diff --check + python -I scripts/check_no_game_data.py: clean.

No game files. AI-assisted (Devin).

@theswiss24

Copy link
Copy Markdown

Tested 4ff0db82 (contains main 98fa503f) on two GPUs in a Dell Latitude 5501 (Linux Mint 22.3), test programs built from main 98fa503f (this PR changes no C++), llvm-mc 20.1.2, LEONIDA_W64_EMULATE=1: pass. Every test has the same result as main on each device:

GPU driver run_gpu_tests.py
NVIDIA MX150 (Pascal) 580.178.04 191/217 passed, 26 skipped, 0 failed
Intel UHD 630 (Gen9.5) Mesa ANV 25.2.8 184/217 passed, 31 skipped, 2 failed, the same 2 as main (cs_fmt_int_narrow = TEST-1000, and cs_signed_zero_nan, the known Mesa 25.2 NIR issue)

No game files.

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

@memorypressure

Copy link
Copy Markdown

Verified on Linux against main 3faac55 (re-run at check time): since the branch's bulk landed, the remaining diff is three comment lines in tools/rdna2spirv.py; they merge cleanly and the bytecode-identity claim reproduces exactly — compiled module, all 824 nested code objects and the constants are identical to main's, so zero behavioural change as stated, and no contract row or fixture is owed for a comment-only delta. The f16 transcendentals row it cites is present in docs/design.md covering all seven ops. compileall, the CI-style battery, the translator pytest group and both docs guards pass on the merged tree; the semantic suite's five failures are confined to test_loop_ballot_barrier.py, byte-identical to main and deterministic there (the known emulate-mode reds). AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 4ff0db8 on Windows Server 2022, CPython 3.13.12: pass

  • python -I -m unittest discover -s tests/semantic -p "test_mutations.py" -> OK - small rdna2spirv change keeps semantic suite green

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@liang-kai-shui

Copy link
Copy Markdown
Contributor Author

Closing as superseded by the round-44 merge: this branch was based on 3faac557, and main now has different code and comments at both places this PR touched (tools/rdna2spirv.py, the f16 transcendental comment blocks, including the clamp_f16 rename and fract/omod lines). After rebasing onto main 561b65a8 the PR has no commits left - main's comments still say cos/exp/log are unmeasured, so the "all seven are measured" wording no longer applies to the current code. Not merging an empty diff; if the measurement should still be documented, it needs a fresh PR against the current rows/tests.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants