Skip to content

t27b: @abs, @max, @min and std.math.pi lower; dqn and string_dualities pass (Closes #7394) - #7411

Closed
gHashTag wants to merge 2 commits into
masterfrom
claude/t27b-lane4-abs-max-pi
Closed

gHashTag wants to merge 2 commits into
masterfrom
claude/t27b-lane4-abs-max-pi

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 7, 2026

Copy link
Copy Markdown
Owner

What

t27b lowers four Zig builtins that gen-zig prints exactly as written:

  • @abs(x) of an f64 / f32. It reuses the bare abs(x) lowering. An integer operand is still refused, because Zig's @abs of an iN is a uN.
  • @max(a, b) / @min(a, b):
    • Two floats of one type, with a literal operand taking the float's type. A NaN operand gives the other operand, and equal operands (-0.0 vs +0.0) give the first, matching Zig 0.16 Debug.
    • Two integers of one type.
    • Each operand is evaluated once.
  • std.math.pi and std.math.e: Zig's comptime_float digits, held as binary128 and rounded once where a typed float is needed.

The conformance spec came first: specs/tri/t27b/conformance/builtin_abs_max_min_pi.t27 passes 12/12 under t27c test-report, with 0 vacuous tests. Its names are unique in the corpus (amp_ / AMP_ / T27bConformanceBuiltinAbsMaxMinPi).

Ledger

spec before after
specs/ml/rl/dqn.t27 blocked ExprCall(@max) pass
specs/port/trinity/src/tri/string_dualities.t27 blocked ExprFieldAccess pass
specs/tri/t27b/conformance/builtin_abs_max_min_pi.t27 (new) pass

Counts: pass 533 -> 536, not_pass 25 -> 23, max_not_pass 25 -> 23. The file has 821 entries and no duplicate paths.

Corpus (Railway lab t27b-lab, aarch64 under qemu, t27b corpus specs --jobs 16 --timeout-ms 60000)

before after
pass 824 827
blocked 538 535
fail 18 18
mismatch 0 0
jit_interp_mismatch 0 0
crash 0 0

Per-file diff: three specs move to pass (dqn, string_dualities, the conformance spec). Six others change only their blocker list:

  • gelu_activation, constants, weber_tuning, probability: @abs / @min now lower, and their next blocker is reported.
  • runtime/instance and sync/schema: @min of an int and a literal is honestly refused (type mismatch), because Zig narrows that result type.

Foreign code

This PR edits cli/t27b/src/lower.rs and cli/t27b/src/lower_float.rs. They are listed at the top of tools/policy/foreign-exceptions.txt, and the PR carries owner-approved-foreign under the owner's standing rule.

Closes #7394
Part of #6063

🤖 Generated with Claude Code

gHashTag and others added 2 commits October 7, 2026 15:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ities pass (Closes #7394)

Ledger: dqn.t27 and string_dualities.t27 move blocked -> pass, and the new
conformance spec builtin_abs_max_min_pi.t27 is a pass row. Corpus on the lab:
pass 824 -> 827, blocked 538 -> 535, jit_interp_mismatch 0.

Part of #6063

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-07 09:43:23 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 41
PRs with All Checks Green 9
READY 1
FAILING 41
PENDING 0
NO CHECKS YET 0

These columns do not partition: 1 + 41 + 0 + 0 = 42, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=1aa228450491 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag

gHashTag commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

Foreign-line budget (owner rule #7371, merged in #7399): this PR is over it, so it is now a draft with auto-merge off.

Master's check_budget() run on git diff --numstat --no-renames origin/master...claude/t27b-lane4-abs-max-pi:

file added cap
cli/t27b/src/lower_float.rs 128 40 per file
cli/t27b/src/lower.rs 5 40 per file
whole PR 133 80 per PR

The owner-approved-foreign label does not lift this cap, and splitting the work into smaller PRs to get under it would dodge the rule, so I am not doing that. The lowering of @abs / @max / @min / std.math.pi has to move into .t27 and come out of gen-rust, with only thin glue left by hand. The conformance spec specs/tri/t27b/conformance/builtin_abs_max_min_pi.t27 and the ledger rows (dqn, string_dualities) stay valid for that rework.

Part of #6063.

This was referenced Oct 7, 2026
@gHashTag

gHashTag commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner Author

Superseded by #7614. It lowers the same builtins (@abs, @max, @min, std.math.pi / std.math.e) with the same IR, but the decisions now live in specs/tri/t27b/builtin_plan.t27, generated with t27c gen-rust and mounted with #[path]. The hand-written glue is 77 added lines, under the #7371 cap of 40 per file and 80 per PR; this draft had 133. #7614 keeps this PR's conformance spec specs/tri/t27b/conformance/builtin_abs_max_min_pi.t27 with one exception. amp_equal_operands_give_the_first failed in the reference on arm64, because Zig 0.16 leaves the sign of @max / @min of -0.0 and +0.0 to the target. x86_64 gives the first operand; aarch64 gives +0 for max and -0 for min. The test now checks only that equal operands give an equal value. On the t27b lab, #7614 moves dqn, string_dualities, residual_connection, huber_loss, mse_loss and rmsprop to pass, with no new mismatch.

@gHashTag gHashTag closed this Oct 7, 2026
gHashTag added a commit that referenced this pull request Oct 7, 2026
 #7394) (#7614)

* t27b: @abs, @max, @min and std.math.pi / e lower from a t27 plan (Closes #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>

* t27b ledger: six specs move to pass, the two new specs are listed (Closes #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>

* t27b: builtin_plan.t27 tests compare strings with std.mem.eql (Closes #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>

* t27b: no conformance test pins the sign of @max / @min of -0.0 and +0.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>

---------

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

owner-approved-foreign Owner-approved exception to the only-t27 rule: hand-written foreign code allowed in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27b lane 4: @abs, @max, @min and std.math.pi / std.math.e

1 participant