Repository navigation
t27b: @abs, @max, @min and std.math.pi / e lower from a t27 plan (Closes #7394) - #7614
Merged
Merged
Conversation
#7394) What t27b decides about these calls is specs/tri/t27b/builtin_plan.t27: which operands each call takes, where the result type comes from, the select chain each call lowers to (rows over numbered slots), the operator of each row, the names a refusal reports, and Zig's digits of std.math.pi and std.math.e. `t27c gen-rust` gives gen/rust/tri/t27b/builtin_plan.rs, mounted in cli/t27b/src/lower.rs the way a64.rs and macho.rs mount theirs. The Rust glue classifies the lowered operands, evaluates each one once and turns the rows into IR selects. A bare `abs(x)` now goes through the same plan; its IR is unchanged. Hand Rust added: lower.rs 40, lower_float.rs 37 (34 deleted), 77 in all, under the #7371 cap of 40 per file and 80 per PR. Generated: 261 lines. Spec: 395 lines, 12 tests, 0 vacuous on `t27c test-report`; 10 of 10 mutants killed. The conformance spec is #7411's, 12 of 12 on the reference. Closes #7394 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oses #7394) `tri t27b ratchet` of a private t27b lab run of 0ab8f32 (the deployed lab.py lab_run), compared with the lab's own run of its base 95182e9: the only verdict moves are blocked -> pass for dqn, string_dualities, residual_connection, huber_loss, mse_loss and rmsprop, and both new specs pass. Those eight rows come from `ratchet --bless` of the branch run; every other row is master's. pass 846 -> 854, not_pass 67 -> 61, max_not_pass 67 -> 61; 1065 rows, no duplicate path. Closes #7394 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag
enabled auto-merge (squash)
October 7, 2026 21:05
…7394) The spec's own `same_text` helper had the body of `same` in specs/tri/utils/template.t27, a new duplicate group for tools/dupe_scan.py. The tests now use `std.mem.eql(u8, ...)`, which gen-zig prints as written and t27b lowers, and the helper is gone; the generated Rust loses it too (261 -> 247 lines). Resealed with t27c from master 95182e9 on the t27c lab: 12/12 pass, 0 vacuous, all hashes MATCH; 10 of 10 mutants still killed; on the t27b lab `t27b test --check` gives 12 passed and 103 runtime asserts, so the ledger row stays `pass`. Closes #7394 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
This was referenced Oct 7, 2026
Contributor
PR DashboardGenerated at: 2026-10-07 21:36:33 UTC
Summary
Seal Status
|
This was referenced Oct 7, 2026
….0 (Closes #7394) The t27b-native CI corpus (ubuntu-24.04-arm) had the reference fail amp_equal_operands_give_the_first, so the ratchet called the new conformance spec STALE. Zig 0.16 leaves that sign to the target. Measured on the t27b lab, `zig test` natively and for aarch64-linux-musl under qemu-aarch64: x86_64: max(-0,+0) = -0, max(+0,-0) = +0, min(-0,+0) = -0, min(+0,-0) = +0 aarch64: max gives +0 both ways, min gives -0 both ways The conformance test now asserts that equal operands give an equal value, which both targets do. builtin_plan.t27 says in its header that the first operand is t27b's choice (the x86_64 answer, which the t27b lab's reference gives); its run_plan test of that choice is plain compare and select and passes on both. Both specs: `t27c test-report` 12/12, 0 vacuous; `zig test` for aarch64 under qemu: all 12 pass. Resealed with t27c from master 706788b (bootstrap/src/compiler.rs unchanged since 95182e9); builtin_plan's generated Rust is byte-identical. Closes #7394 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
auto-merge was automatically disabled
October 7, 2026 21:59
Head branch was modified
Contributor
PR DashboardGenerated at: 2026-10-07 22:04:38 UTC
Summary
Seal Status
|
This was referenced Oct 8, 2026
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.
Closes #7394. Part of #6063 (t27b coverage, lane 4); written in t27 under the port epic #6198. Supersedes draft #7411, which did the same in 133 hand-written Rust lines.
What
t27b now lowers
@abs(x),@max(a, b),@min(a, b),std.math.piandstd.math.e. gen-zig prints all of them as written. A bareabs(x)with nofn absdeclared now goes through the same path. The semantics are #7411's, which were measured on the t27b lab against Zig 0.16 Debug:@absof an f64 / f32 is the magnitude. A literal folds. A typed integer is refused, because Zig's@absof aniNis auN.@max/@min:-0.0against+0.0that is t27b's choice; see "Signed zero" below.std.math.pi/std.math.eare Zig's comptime_float digits, held as binary128.What t27b decides is a t27 spec.
specs/tri/t27b/builtin_plan.t27holds:t27c gen-rustturns it intogen/rust/tri/t27b/builtin_plan.rs.cli/t27b/src/lower.rsmounts that file with#[path], the waya64.rsandmacho.rsmount theirs.What the hand-written glue does:
@absof a literal;std.math.Xshape.The spec's
run_planwalks the same rows over f64 values, so its tests check the semantics on the plan itself.Lines
cli/t27b/src/lower.rscli/t27b/src/lower_float.rsgen/rust/tri/t27b/builtin_plan.rst27c gen-rust, not hand-editedspecs/tri/t27b/builtin_plan.t27specs/tri/t27b/conformance/builtin_abs_max_min_pi.t27.trinity/seals/*.json(2)t27c seal --savedocs/reports/t27b_expectations.jsonAGENTS.mdHand-written glue is 77 added lines: 40 in
lower.rsand 37 inlower_float.rs. That is under the #7371 cap of 40 per file and 80 per PR. The 34 deleted lines are the old hand-writtenbare_abslowering.Both glue files were already in master's
tools/policy/foreign-exceptions.txt. This PR does not change that file and needs no label.Hand-written Rust in
cli/t27b/src/*.rs, measured withwc -l, goes from 14769 to 14812.cli/t27b/tests/*.rsstays at 7814.Gates (run on the t27c Railway lab)
check_budget(), master'sgen/c/policy/own_language.cwith the one-line C main fromlefthook.yml, overgit diff --numstat --no-renames origin/master...HEAD: exit 0.check_all(), with the exception list fromorigin/master:tools/policy/foreign-exceptions.txt, in both the--(pre-push) and--ciforms: exit 0..rsfile are each denied.tools/l2_regen_check.py --base 95182e95b:t27c gen-rust specs/tri/t27b/builtin_plan.t27reproduces the generated file byte for byte. gen-rust was deterministic over 3 runs.tools/check_seal_coverage.pyandtools/check_seal_currency.py: exit 0. Both new seals passt27c seal --verifywith all hashes MATCH.t27c suite --repo-root . --ratchet --corpus-only: RATCHET CLEAN, 77 / 77.tri types ratchet: CLEAN, 101 names.tri types classified: OK.tools/check_assertionless_spec_tests.py: ok.tools/check_verilog_widths.py --require: 0 new.tools/dupe_scan.py: only the five groups its base 95182e9 already reports, none from this PR.same_texttest helper duplicatedsameinspecs/tri/utils/template.t27. The tests now usestd.mem.eql(u8, ...)instead, and the helper is gone. After that change the spec was re-run (12/12, 0 vacuous), resealed, and its mutants re-run (10 of 10 killed). t27b runs the spec under--checkwith 12 passed and 103 runtime asserts.Spec checks (t27c lab, t27c built from master 95182e9, zig 0.16.0)
t27c test-report(head 7e6b26c):specs/tri/t27b/builtin_plan.t27: 12/12 pass, 0 of 12 vacuous, 103 runtime asserts.zig testforaarch64-linux-muslunder qemu-aarch64: all 12 tests each.Mutants. I tested 10 mutants of the plan spec, each on a copy of the spec, and all 10 were killed:
<;<instead of<=;@maxkeeps the NaN rows;a < b.One of them, the b-NaN row using
<, is caught only by the exact row-table test. With row 0 as written, that row cannot change a result: it is there because #7411's chain has it, and this PR keeps the IR identical.t27b lab: full corpus with the reference
Master base 95182e9. These are the lab's own scheduled run numbers: https://t27b-lab-production.up.railway.app/runs/95182e95b389cca697f0edd3fd8433dcf5fa06a9.json (
qemu-aarch64 t27b corpus specs --json --runner qemu-aarch64 --timeout-ms 60000 --jobs 24).Branch head 7e6b26c, and the earlier heads 1fee253 and 0ab8f32:
/opt/t27b-lab/lab.pylab_runin a private work dir in the same container.--jobs 12, and 3 reference workers.f437ddb3...,9463db16...and3737880c....cargo test --release -p t27b(aarch64, qemu)Per file:
specs/ml/rl/dqn.t27specs/port/trinity/src/tri/string_dualities.t27specs/ml/layers/residual_connection.t27specs/ml/loss/huber_loss.t27specs/ml/loss/mse_loss.t27specs/ml/optimizer/rmsprop.t27weber_tuning:@abs->std.*;probability:@min->@exp.builtin_plan.t27has 103 and the conformance spec has 59.The one mismatch is
specs/port/trinity/src/tri/gen_canvas.t27, on master as well. It is inherited and filed as #7550.Ledger
tri t27b ratchetcompared the branch run with the master run. The only verdict moves are the six above plus the two new UNLISTED specs.ratchet --blessof the branch run, and every other row is master's.weber_tuningblocker.Signed zero
The first t27b-native CI run of this PR, on ubuntu-24.04-arm, failed one conformance test in the reference:
amp_equal_operands_give_the_first, from #7411. The ratchet then called the new spec STALE.Zig 0.16 leaves the sign of
@max/@minof-0.0and+0.0to the target. I measured it on the t27b lab withzig test, natively and foraarch64-linux-muslunder qemu-aarch64:On x86_64 the result is always the first operand. On aarch64 it follows IEEE maxNum / minNum (
fmaxnm/fminnm).What changed:
amp_equal_operands_give_an_equal_value. It asserts== 0.0and two equal-value cases, which hold on both targets.builtin_plan.t27says in its header that this is t27b's choice. Its ownrun_plantest of that choice is plain compare-and-select, so it passes on both targets.No other corpus spec depends on the sign: the arm64 CI run disagreed with t27b on that one test only.
gen-rust gaps
char, which au8cannot be compared with or subtracted from. The spec writes its digit test with byte numbers (48, 57), asmacho.t27already does.&'static str. So the call-name andstd.mathname matches stay one-line glue matches instead of a spec function that takes the name.Generated with Claude Code