Repository navigation
Conversation
|
Tested on an Apple M3 (macOS 26.5.1), this branch at
So the fix works for MoltenVK, but on KosmicKrisp the f16 multiply-add was only exact while it was a compile-time constant: computed at run time it reads one ulp off, which looks like KosmicKrisp splitting the f16 |
|
Tested
So NVIDIA never hit the word 7 zero that MoltenVK did, and the run-time f16 operands don't change anything here. AI-assisted testing (non-developer tester). |
lixonik
left a comment
There was a problem hiding this comment.
Independent CPU check at aebef89d: the three fixture tests passed. With the same test file copied to the merge base 3de22a19, only the runtime-operand check failed, on the original three literal-fed registers.
The f16 operands also let us quantify the one-ULP result Tauwni reported on KosmicKrisp. The exact product is 14988, halfway between binary16 values 14984 (0x7351) and 14992 (0x7352). The addend is -2^-22. A single rounding gives 0x7351; rounding the product first to nearest-even gives 0x7352, and rounding the following sum keeps it there. That matches the reported value under separate rounding.
AI-assisted, CPU-only verification. No independent driver trace or Mac run.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Clean-Room & Technical Verification
- Mergeability: 3-way merge against upstream
main(bcaa13dad) is 100% clean with zero merge conflicts. - Clean-Room Compliance: 100% clean-room. Hand-written assembly fixture adjustments only; zero retail code, game data, or keys (
check_no_game_data.pyclean). - Technical Rigor & Hardware Reality:
- In
runtime/test/shaders/cs_fma_fused.asm, replaces hardcoded literals for thev_fma_f16test case with dynamic run-time registers derived froms4XOR literals. - Fixes MoltenVK 1.4.2 compile-time constant folding bugs on macOS/Metal (Apple Silicon M5/M5 Pro) where compile-time f16 evaluations produced erroneous
0x0000/0x3c00instead of the expected0x7351round-to-odd result. - Adds regression test
tests/semantic/test_fma_fused_fixture.pyvalidating that every multiply-add in the fixture consumes run-time registers rather than folding literals, while verifying correct word generation inspirv_mini_interp. - Accurately updates documentation in
docs/testing.md.
- In
LGTM! Approved.
… time Tauwni measured it in the review of ProjectLeonida#1724 (Apple M3, Mesa 26.3.1, 20 of 20 runs): with run-time operands the f16 multiply-add comes out as if the product were rounded first, one step from 0x7351. With literal operands the constant was folded exactly, so the fixture passed there before. MoltenVK 1.4.2 and llvmpipe give 0x7351 on the same machine. A Known problems row and a line in the fixture's header; no instruction changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@Tauwni thank you for the three-driver run. I have no KosmicKrisp here, so yours is the only measurement of it, and @lixonik's arithmetic matches the fixture's header, which gives I kept the run-time operands. With literals the word checks a compiler's constant folder on either driver, and the one-step difference on KosmicKrisp holds for any run-time Thanks also to @potatoe0100 for the RTX 4060 run. AI-assisted. |
|
Tested this PR's diff at
So on AMD the run-time round-to-odd sequence gives |
|
Apple check — and this one changes a result on KosmicKrisp, so it may need a decision. 2x2: fixture × driver
So on this machine the change does exactly what it says for MoltenVK — the old fixture's constant-folded operand gave Two readings, and I cannot tell them apart from a Mac:
What is certain: merging this as-is turns a passing KosmicKrisp run red on an Apple M3, so it should not land without either a known-problems row or a word verified on hardware. I can run the same 2x2 on a second Mac configuration if that helps narrow it (another M-series machine, or KosmicKrisp built from a newer Mesa). AI-assisted. No game data: the fixture is hand-written and every number above is test output. |
|
Correction to my comment above: the head The part that is still open is the runner, not the docs: and there is no per-driver allowance in the diff (the four changed files are Is that intended (KK red, documented, no allowance), or should the runner accept the measured KK word the way AI-assisted. |
…(GPU-APPLE-M6) Native 192/264 passed, 69 skipped, 3 failed; LEONIDA_W64_EMULATE=1 225/264 passed, 36 skipped, 3 failed; ctest 96/96. The failures are known: cs_fma_fused (#1724), ps_imgatomic (#543) and cs_imgatomic_ext (#1518). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP
|
Following up on the KosmicKrisp word 7 ( Apple M3, macOS 26.5.1. KosmicKrisp and llvmpipe are Mesa 26.3.1 through the loader, MoltenVK is 1.4.2. Scratch fixtures took their operands from
So once the intermediates are dead, KosmicKrisp folds the TwoSum algebraically: So this supports reading 1 in @EvgHaze's comment: the fixture's The ; group: 1,1,1
; rsrc2: 0x8090
v_mov_b32_e32 v0, s4 ; VKC_SGPRS=0x3f800800
v_mov_b32_e32 v20, 0
v_xor_b32_e32 v1, 0x3f808804, v0 ; z = 0x8004
v_cvt_f32_f16_e32 v1, v1
v_xor_b32_e32 v3, 0x3f8064e1, v0 ; x = 0x6ce1
v_cvt_f32_f16_e32 v3, v3
v_xor_b32_e32 v4, 0x3f804a00, v0 ; y = 0x4200
v_cvt_f32_f16_e32 v4, v4
v_mul_f32_e32 v5, v3, v4 ; p
v_add_f32_e32 v6, v5, v1 ; s
v_sub_f32_e32 v7, v6, v5 ; bb
v_sub_f32_e32 v8, v6, v7 ; sb
v_sub_f32_e32 v9, v5, v8 ; da
v_sub_f32_e32 v10, v1, v7 ; db
v_add_f32_e32 v11, v9, v10 ; err: 0xb4800000, KosmicKrisp 0x00000000
buffer_store_dword v11, v20, s[0:3], 0 offen
s_endpgmNo change to this PR from me. This is only meant to settle which word is the reference. AI-assisted (Claude Code). No game data. |
…ones (TEST-FMA-FUSED-F16-RUNTIME) The fixture reads the operands of its f32 multiply-adds from s4..s7 so that a driver has to compute them at run time. The three operands of its v_fma_f16 were literals, which made the whole f16 multiply-add a compile-time constant. MoltenVK 1.4.2 gives the wrong constant: word 7 read 0x0000 on an Apple M5 (0x3c00 in the docs' row) where 0x7351 is expected, the cs_fma_fused failure listed in docs/testing.md and in the macOS job's EXPECTED_FAILURES. The same translation with any one of the three operands taken at run time gives 0x7351. The triple is now the s4 word XOR a literal each, so the test checks the translator's round-to-odd sequence as the GPU runs it. The translator is not changed. tests/semantic/test_fma_fused_fixture.py runs the fixture in the interpreter against the eight words of its header and checks that no multiply-add in it reads a register only literals fed. The Known problems row says what is left: an f16 multiply-add with only constant operands. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… time Tauwni measured it in the review of ProjectLeonida#1724 (Apple M3, Mesa 26.3.1, 20 of 20 runs): with run-time operands the f16 multiply-add comes out as if the product were rounded first, one step from 0x7351. With literal operands the constant was folded exactly, so the fixture passed there before. MoltenVK 1.4.2 and llvmpipe give 0x7351 on the same machine. A Known problems row and a line in the fixture's header; no instruction changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
0003d3d to
ebb0b0b
Compare
With its f16 operands taken at run time the test passes on the macos-26 runner (Apple Paravirtual device, MoltenVK 1.4.2): the job's last run on this branch printed "cs_fma_fused passed: drop it from the expected failures". The Known problems row says where it passes now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@EvgHaze thanks for the 2x2 on both drivers and for the correction, and @Tauwni for narrowing it down. Intended: red on KosmicKrisp, documented, no allowance. That is how the Tauwni's probe puts the cause in the driver: stored step by step the Rebased onto @adrianmjim thanks for the RX 7900 XT run. AI-assisted. |
|
A correction to my comment above about where the fold happens. It is not in NIR. I rebuilt the same kernel in a standalone Metal program (macOS 26.5.1, M3), and Apple's compiler ignores that pragma in a AI-assisted (Claude Code). |
Claimed in the coordination issue as: TEST-FMA-FUSED-F16-RUNTIME (claim)
Depends on: #860
It does not build on #860; the two conflict. Both edit neighbouring Known problems rows of
docs/testing.md, so whichever merges second needs a rebase that keeps both rows.What and why
cs_fma_fusedfails on a Mac with MoltenVK 1.4.2 in word 7, thev_fma_f16:docs/testing.mdhas a Known problems row for it and the macOS job lists it inEXPECTED_FAILURES. On an Apple M5 the word reads0x0000, want0x7351.The translation is not what is wrong. The fixture reads the operands of its f32 multiply-adds from
s4..s7"so a driver cannot fold the multiply-adds at compile time", but the three operands of the f16 one were literals, so that whole multiply-add was a compile-time constant, and MoltenVK 1.4.2 gets that constant wrong. Measured on the M5 with the fixture otherwise unchanged:main)0x00000x73510x73510x7351runtime/test/shaders/cs_fma_fused.asm: the f16 triple is thes4word XOR a literal each (0x3f800800 ^ 0x3f8064e1 = 0x6ce1, and so on), so it is the same triple at run time, and the header says why.tests/semantic/test_fma_fused_fixture.py: the translated fixture gives the eight words of its header in the interpreter, and every register one of its multiply-adds reads comes froms4..s7, so a literal operand cannot come back unnoticed.docs/testing.md: the Known problems row now says what is left, an f16 multiply-add whose three operands are all constants, and that the fixture no longer has one.tests/semantic/README.mdlists the new test.The translator,
check.pyandrun_gpu_tests.pyare not changed: the expected words are the same..github/workflows/runtime.ymlstill listscs_fma_fusedin the macOS job'sEXPECTED_FAILURES. I left it: that runner's Metal device is not an M5, and an expected failure that passes only gets a notice there. If this pull request's macOS run shows that notice, the entry can go.Tested
Apple M5, MoltenVK 1.4.2, llvm-mc 23.1.6, SPIRV-Tools v2026.4. Before is
main626d1281a, after is this branch on3de22a190(the fixture, the translator and the two runners are the same at both), with the test programs built from626d1281a.run_gpu_tests.py --filter cs_fma_fused, 5 runsword 7 (f16): got 0x00000000, want 0x000073518/8 fused exact (GLSL Fma)LEONIDA_FMA=exact, 5 runsLEONIDA_W64_EMULATE=1build.py <out> cs_fma_fused, thencheck.pyword 7 (f16): got 0x00000000, want 0x00007351okrun_gpu_tests.py, all testscs_fma_fused,cs_imgatomic_extcs_imgatomic_ext,ps_imgatomiccs_fma_fused(fail to pass) andps_imgatomic(pass to fail). The second is the intermittent GPU test: ps_imgatomic loses atomic updates intermittently on MoltenVK 1.4.2 (Apple M5 Pro); KosmicKrisp passes #543, not this change: its module is byte-identical in both runs, and run alone six times it passes five and fails one in each tree.cs_imgatomic_extis red onmainand claimed by someone else (GPU-IMG-ATOMIC-EXT-VOLUME-TAG).273 shaders: 272 translated, 272 pass spirv-valin both, and 1 of the 275 modules in the work folder changes:cs_fma_fused.LEONIDA_FMA=exactpassed before is the same effect, not a fix: it changes only how the f32 multiply-adds around the f16 one are translated; the f16 one does not useFmain either mode (Gen.fma_f16_odd).tests/semantic/test_fma_fused_fixture.py: 3 tests pass; againstmain's fixture the run-time check fails (['v15', 'v16', 'v17'] != []). With one operand word changed by one bit the eight-word check fails, so it does compare.python3 -I scripts/run_semantic_tests.py tests/semantic: 487 files, 6,279 tests, 0 failed before; 488 files, 6,282 tests, 0 failed after.tests/test_translate.pyoncs_dpp_cmp.asm, tests: the pytest helper takes a text-only sample's lines as its listing, as run_gpu_tests.py does (TEST-TRANSLATE-TEXT-ONLY) #1375's subject;cs_fma_fused.asmassembles and validates there as before).main; none is touched here (tests: the mod-pack alias test compares resolved names, as same_report_path does (TEST-MOD-PACK-ALIAS-MACOS) #1412, Fix two repository checks that fail on main #1561 and ci: the Runtime workflow starts on tools/conformance/** (CI-RUNTIME-PATHS-CONFORMANCE) #1657 are open for them).tests/test_docs_*.pypass;python3 -I scripts/check_no_game_data.pyis clean on the new test and the fixture.Not tested: any GPU other than the M5, and the macOS runner's device. On a driver that evaluated the constant correctly the only change is that the f16 word is computed at run time.
GPUs tested: Apple M5 (8-core GPU), MoltenVK 1.4.2, macOS 27.2.1 (26B131)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code