fix(specs): ternary_model dot27 takes u64 lanes; test checks Python values - #5975
Merged
Merged
Conversation
…alues dot27 packed 27 two-bit trits into an i32 and shifted by up to 52, so the Zig test panicked on its first assertion and the C test exited 134. The test's expected values were also wrong (they assumed tmul(1, 1) = 1) and are now taken from tools/ternary_model.py, with three new cases that use lanes up to bit 52. Closes #5972 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
specs/port/tools/ternary_model.t27portstools/ternary_model.py. Itsdot27packed 27 two-bit trit lanes into ani32and shifted it byi * 2, up to 52. Python integers are unbounded; ani32is not.dot27(a: u64, b: u64): 27 lanes need 54 bits. Each extracted lane is cast toi32beforetmul.dot27_testhad wrong expected values. They had never been checked, because the test panicked on its first line. Its comments assumedtmul(1, 1) = 1, but the spec's owntmul_testassertstmul(1, 1) == 0. The expected values now come fromtools/ternary_model.py:dot27(0, 0)dot27(5, 5)dot27(1, 2)Before / after (t27c from master)
t27c gen+zig testt27c gen-c+ clang -O0,-DT27_TEST_MAINt27c gen-c+ clang -O2,-DT27_TEST_MAINNo seal exists for this spec, and the number of
letstatements is unchanged (specs/RUST_DIALECT.jsoncounts them).Found by the t27b differential backend, which reported "shift amount out of range at line 40 (>> on i32)".
Closes #5972. Part of #5905.
🤖 Generated with Claude Code