Skip to content

docs/design.md: hardware v_sqrt_f64 is not correctly rounded (PROC-216) - #4292

Closed
traeb0n wants to merge 1 commit into
ItsNotRexed:mainfrom
traeb0n:proc-216-sqrt-f64
Closed

traeb0n wants to merge 1 commit into
ItsNotRexed:mainfrom
traeb0n:proc-216-sqrt-f64

Conversation

@traeb0n

@traeb0n traeb0n commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

PROC-216. Docs only.

This adds @fiestorra's measurement (finding) to the v_rcp_f64, v_rsq_f64, v_sqrt_f64 row of docs/design.md:

  • On a gfx1036 iGPU, tools/hw_oracle raw kernels show v_sqrt_f64 is off from the exact root by 2^26 ulps. Only about 26 of the 53 significand bits are right.
  • So the translator's GLSL.std.450 Sqrt is the more accurate lowering. An f64 root that differs from RDNA2 hardware in the low bits is not a translator bug.
  • v_rcp_f64/v_rsq_f64 were exact, but only powers of two were tried.
  • None of the three opcodes occurs in the 26,503 listings.

I didn't rerun the hardware measurement or the corpus count: I have no AMD GPU and no game files. I did decode the four quoted bit patterns: 2.0000000298, 3.0000000298, 0.5000000075 and 1.4142135531, against binary64 sqrt(2) = 0x3ff6a09e667f3bcd. They match the finding.

Tested ded9521 with Python 3.11 on Windows 11: pytest tests/test_design_contract_rows.py tests/test_docs_*.py tests/test_f64_transcendentals.py: 26 passed.

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code

Record @fiestorra's tools/hw_oracle measurement on a gfx1036 iGPU in the
v_rcp_f64/v_rsq_f64/v_sqrt_f64 row: the instruction's result has only about
26 of 53 significand bits right (sqrt(4.0) = 0x4000000004000000), so the
translator's GLSL.std.450 Sqrt is the more accurate lowering, and a low-bit
difference from RDNA2 hardware is not a translator bug. The rcp/rsq samples
were only powers of two. None of the three opcodes occurs in the 26,503
listings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kam471

Kam471 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Duplicate note: #4293 (\c280d96e) adds the same PROC-216 v_sqrt_f64 measurement to the same row; it has the claim at 2026-11-23T00:34:20Z and the fuller attribution. This PR opened 17 seconds earlier but has no claim link, so the coordinator's first-claimant rule points to #4293. Both pass the docs checks (6 links + 2 design rows).

@SweatierKey

Copy link
Copy Markdown
Contributor

Independent docs read & hygiene check at ded95210 on Linux (WSL2, Python 3.13.5, no game files): pass.

AI-assisted review.

@sds-228 sds-228 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.

Code review of ded9521: no issues found. The added hardware note is consistent with the cited synthetic test and the corpus-count caveat, and it does not change the translator contract. Raw bytes are valid UTF-8. Docs suites: 20 tests OK; f64 suite: 2 tests OK; compileall and diff check clean.

AI-assisted (OpenCode).

@traeb0n

traeb0n commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #4293: @etcetera-yt claimed PROC-216 15 seconds before I did (00:34:20 vs 00:34:35), so theirs has priority. Thanks @Kam471, @SweatierKey and @sds-228 for the reads. One check that may help #4293: I decoded the four quoted bit patterns (2.0000000298, 3.0000000298, 0.5000000075, 1.4142135531, against binary64 sqrt(2) = 0x3ff6a09e667f3bcd). The first three are off by exactly 2^26 ulps. sqrt(2.0) is off by 0x027f3bcd ≈ 2^25.3 ulps, which matches @tylerstraub's correction. AI-assisted (Claude Code).

@traeb0n traeb0n closed this Nov 23, 2026
@traeb0n
traeb0n deleted the proc-216-sqrt-f64 branch November 23, 2026 01:04
@kapitche

Copy link
Copy Markdown
Contributor

Read ded95210 against main 03b09a08: 1 issue (docs/design.md, the v_rcp_f64/v_rsq_f64/v_sqrt_f64 row). Merge is clean and tests/test_docs_*.py pass.

  • The words check out: 0x4000000004000000 = 2.0000000298, 0x4008000004000000 = 3.0000000298, 0x3fe0000004000000 = 0.5000000075, 0x3ff6a09e64000000 = 1.4142135531 against 0x3ff6a09e667f3bcd. tests/test_f64_transcendentals.py exists.
  • Issue: "so Sqrt is closer to the exact root than the instruction it replaces" is a claim about the lowered shader on a driver, and the row cites only the native instruction's output; no Sqrt result is given. Either cite one or reword to say only that the hardware instruction is not correctly rounded.
  • The same measurement is also in docs/design.md: v_sqrt_f64 on RDNA2 is not correctly rounded (PROC-216) #4293 (flagged as a duplicate there). The corpus claim (no f64 rcp/rsq/sqrt in the 26,503 listings) needs the game files and was not re-checked.

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