Repository navigation
Conversation
Since sm_70 MUFU.SIN and COS take turns, which NVIDIA reduces exactly; 2pi x in 32 bits lost x's fraction as it grew (errors up to 7e-4 at a few thousand turns). ATurns takes the angle from x - floor(x). Op 9 is MUFU.TANH (nvdisasm), refused until now: ATanh computes 1 - 2 / (e^2x + 1), x itself below 2^-10. New MufuTurns tests in test_dmsh_ampere_alu.py (three fail on main). A GPU cross-check of 1,500 MUFU with PTX .approx tolerances: 42 mismatches and 69 refusals to 7-11 (sine of an infinity under Metal's fast math, EX2 below 2^-126). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s exactly; MUFU.TANH is translated
…, seedds#1410, seedds#1411, seedds#1412, seedds#1413, seedds#1414, seedds#1329 on top of main's translator fixes): chain c9cf9613657e Publishes Ryujinx.Graphics.Shader, Ryujinx.Common, Spv.Generator and dmsh_xlate (osx-arm64, framework-dependent, the universal launcher kept) from the merged source; the PRs' own binaries were built without this tree's translator changes (float atomic adds, F2IP, the growing raw pool table). The lock and dmsh_chain.h are written again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#1462's CAS, seedds#1487, seedds#1329, seedds#1410, seedds#1411, seedds#1412, seedds#1357): lock and chain header; conflict leftovers removed from shaders.md and test_dmsh_ampere_alu.py
|
Thanks for this! I ran it against the Jetson Orin suite from #2041, both on its own base and applied on top of current main, and nothing that matched the Orin before differs now. Sin / cos. On the branch's own base, the reduction is a clear step closer to the Orin (sin 897 → 798 lanes off out of 1,024, cos 735 → 625). Since this branch was cut, though, main got its own reduction from #1234, TANH. This overlaps #2058, which also translates MUFU.TANH:
The NaN-payload lanes are left out, since they're the same for both. For f32 the two are close, and the formula's cancellation between 2^-10 and 0.5 is where the larger misses come from. For f16 the Orin rounds tanh toward zero, which #2058 copies. What I'd suggest is that we land TANH through #2058 and keep main's sin/cos reduction, so this PR would come down to your To rerun this yourself, check out #2041's branch, set |
What and why
2pi xin 32 bits loses x's fraction as it grows (errors up to 7e-4 at a few thousand turns: an animation'ssin(time * speed)drifts with play time).ATurnstakes the angle fromx - floor(x), exact in 32 bits; an infinity gives inf - inf = NaN.MUFU op 9), so a shader using it (an activation in a neural upscaler, for instance) failed to translate.ATanhcomputes1 - 2 / (e^2x + 1), which gives +-1 at either end and keeps a NaN, andxitself below 2^-10 (PTX documentstanh.approx.f32to about 2^-11 relative error).Reference entry:
docs/reference/shaders.md, "MUFU.SIN / COS argument reduction, and MUFU.TANH".Checked
DMSH_TEST_XLATE=<translator> python3 dm/gfx/tests/test_dmsh_ampere_alu.py, newMufuTurns(3, all fail onmain). Alltest_dmsh_*.pypass.dmsh_xlateusing the production options (debugandreducedon, asdmsh_build.py), convert with spirv-cross 1.4.363.0 at MSL 2.3, run them on the GPU and compare every bit with a reference written from the oracle, PTX's documentation and Mesa NAK where it applies. MUFU is approximate on NVIDIA, so the comparison uses tolerances from PTX's.approxerror bounds, with special values compared exactly): 1,000 MUFU, 92.6 % onmain(29 sine / cosine precision mismatches, 45 TANH refusals), 99.5 % with the change. Left: the sine / cosine of an infinity (0 instead of NaN under Metal's fast math) and EX2 results below 2^-126 (flushed by the GPU).Docs
docs/reference/shaders.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)🤖 Generated with Claude Code