Repository navigation
tests/semantic: export test_alu_shift_b64 results in 16-bit halves (fixes CI on Python < 3.14) - #454
Conversation
Both raised Unsupported while v_lshlrev_b64 was translated. They share its code: the register pair as a 64-bit value shifted by S0 & 63, logically or arithmetically to the right. tests/semantic/test_alu_shift_b64.py checks all three 64-bit shifts against a plain-Python reference (amounts 0, 31-33, 63, 64 and above, sign bit set), plus an SGPR pair and an inline shift amount.
IAmNotSiob
left a comment
There was a problem hiding this comment.
The translator change looks right: same pair assembly as v_lshlrev_b64, amount masked to 6 bits, and OpShiftRightArithmetic on %ulong copies bit 63 as it should.
But tests/semantic/test_alu_shift_b64.py fails for me on the PR head (python -I -m unittest discover -s tests/semantic -p test_alu_shift_b64.py):
FAIL: test_seeded (op='v_ashrrev_i64', n='0x3e32dea5', x='0xf47412b2f2e132ea')
AssertionError: 18446744073707692181 != 18446744073703497877
That's 0xffffffffffe3a095 vs the expected 0xffffffffffa3a095. The two differ only in bit 22 of the low word, and I don't think it's the translator. The correct low word 0xffa3a095 is a signalling NaN bit pattern, and exporting it through exp mrt0 (a float output) quiets it, which sets bit 22. Reproduced without any shift: v_mov_b32 v0, 0xffa3a095 → exp comes back as 0xffe3a095. A real GPU export can do the same, so the harness can't pass arbitrary 32-bit words through exp as floats.
Suggested fix: export each word as two 16-bit halves (e.g. v_and_b32 v5, 0xffff, v0 / v_lshrrev_b32 v6, 16, v0, same for v1) and reassemble them in run_lines. No half can then be a NaN pattern. Seeded inputs will keep hitting this ~0.4% of the time otherwise, and other tests/semantic files that export raw integers may have the same latent issue.
Happy to approve once the test is fixed. AI-assisted review (Claude Code).
|
Thanks, good catch. It didn't reproduce on my machine because the float round trip there keeps the signalling-NaN payload, so it depends on the platform. I reproduced it by forcing the interpreter's bits↔float conversion to quiet sNaNs, and then exactly that seeded case fails. Fixed in a9353e8 as you suggested: I ran my other open test files (#440, #445, #448, #449, #392) under the same quieting: they pass, because their seeded words never hit an sNaN pattern. But you're right that raw-integer |
exp writes float channels, and a word with a signalling-NaN bit pattern can come back quieted (bit 22 set) depending on the platform's float round trip. The seeded v_ashrrev_i64 case 0xffffffffffa3a095 failed that way in review. Export v[0:1] as four 16-bit halves ORed into 0x40000000 (always a normal float) and reassemble them; add the reviewer's word as a fixed case.
|
Related: the root cause of this failure is TEST-67 (#509), fixed in the interpreter by #533 / #543. With one of those merged, |
IAmNotSiob
left a comment
There was a problem hiding this comment.
Re-checked the new head. test_alu_shift_b64.py passes for me on main's interpreter (the seeded v_ashrrev_i64 case included). Exporting 16-bit halves ORed into 0x40000000 means no exported word can be a NaN pattern, and the >> 16 == 0x4000 assert catches it if something ever touches the high half. Translator change unchanged from my earlier look. Approving, as promised. AI-assisted review (Claude Code).
Update:
mainalready has the translator part of this PR (056190e,v_lshrrev_b64/v_ashrrev_i64). What's left here is the test fix from the review below. It's needed becausetest_alu_shift_b64fails onmainin CI (semantic-tests, Ubuntu and Windows):Cause
The expected low word
0xffa3a095is a signalling-NaN bit pattern, and the test exported it throughexp mrt0, a float channel. On Python before 3.14,struct.pack("<f", …)quiets a signalling NaN (bit 22 set), so the interpreter changes the word. Python 3.14 keeps it, which is why it passed locally. @IAmNotSiob spotted it in review.Change (a9353e8)
tests/semantic/test_alu_shift_b64.py:v[0:1]now leaves as four 16-bit halves ORed into0x40000000, which is always a normal float, andrun_linesputs them back together.0xffffffffffa3a095is now a fixed case.Tested
python -I -m unittest discover -s tests/semantic: OK.main, that reproduces the CI failure.tests/test_mem_diff.py(thecheckjob) is fixed in mem_diff: export result words in 16-bit halves (fixes test_mem_diff on Python < 3.14 / CI) #567.AI-assisted (Claude Code): it wrote the change and the tests, and ran the checks listed above.