Skip to content

spec(nn): make attention.t27 compile and pass with 0 vacuous tests (Closes #10094) - #10095

Merged
gHashTag merged 1 commit into
masterfrom
spec/nn-attention-compiles-10094
Oct 17, 2026
Merged

gHashTag merged 1 commit into
masterfrom
spec/nn-attention-compiles-10094

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Closes #10094. Part of epic #10024 (cell 23, ML specs that compile).

What changed

specs/nn/attention.t27 never compiled: use math::constants is not resolved by t27c, so constants::PHI_CUBED_INV was an undeclared identifier. The module is now self-contained (use base::types only).

  • phi, phi^-3 = 1/phi^3 and the sacred scale 81^(-phi^-3) are local constants. Tests check them against independent identities: phi^2 = phi + 1, phi^2 + phi^-2 = 3, phi^-3 = sqrt(5) - 2, exp(-gamma ln 81).
  • Buffers are slices the caller owns, so every step (matmul, RoPE, cache, scores, softmax, weighted values, kernel) is tested on its own.
  • Math fix: the causal mask used to set masked scores to 0.0 before the softmax, so future positions still got positive weight (exp(0 - max) > 0). The mask is now a very negative score and future weights are exactly 0.0.
  • The QK-gain ablation module is folded in. get_qk_gain and effective_score_scale had empty bodies and are implemented. The gain is applied to Q and K, so the score scales by gain^2 (tested).
  • Out-of-range positions (RoPE, cache, kernel) are bounded and tested.

Dropped from the old spec, and why

  • The bidirectional and sparse attention types and six phase constants: nothing read them.
  • run_attention_with_gain (a BPB training measurement) and attention_forward: they exist nowhere and cannot be checked by the compiler.
  • The bench blocks: they named buffers and calls that do not exist.
  • Tests that asserted a constant against itself (always true).
  • The gf16 type for the gains (f64 now).
  • Non-ASCII characters in comments (L3).

Measured on the Railway lab (t27c, test-report)

Measure Value
tests 35
pass 35
FAIL 0
BLOCKED 0
vacuous (0 runtime asserts) 0 of 35
invariants 9, proved at comptime
rate 100.0%

First lab run had 4 vacuous constant tests (pure comptime expressions, 0 runtime asserts); they now read the constants through functions and execute.

Mutation check

Each mutant was made on a copy on the lab; the real spec was untouched.

Mutant Result
mask score 0.0 - 1.0e30 to 0.0 (the old behaviour), mask invariant also relaxed 3 FAIL (mask zero weight, mask distribution, kernel does not read the future); with the invariant kept, compile fails
causal j > position to j < position 4 FAIL
softmax s - max to s + max 1 FAIL (shift invariance and stability)
RoPE x0*c - x1*s to x0*c + x1*s 1 FAIL (norm and inverse)
score gain qk_gain * qk_gain to qk_gain 1 FAIL (gain squared)

5 of 5 mutants killed.

Seals

.trinity/seals/SacredAttention.json and nn_SacredAttention.json re-saved on the lab (spec hash matches the committed file: sha256 c40795145b...).

Only .t27 and seal data are touched. Not merged.

🤖 Generated with Claude Code

…loses #10094)

The module read constants::PHI_CUBED_INV from math::constants, which t27c
does not resolve. It is now self-contained (use base::types only): phi,
phi^-3 = 1/phi^3 and the sacred scale 81^(-phi^-3) are local constants,
checked by tests against phi^2 = phi + 1, phi^2 + phi^-2 = 3, sqrt(5) - 2
and exp(-gamma ln 81).

Math fix: the causal mask set masked scores to 0.0 before the softmax, so
future positions still got positive weight. The mask is now a very negative
score and future weights are exactly 0.0.

The QK-gain ablation module is folded in, with the two empty-bodied
functions implemented and the gain applied to Q and K (score x gain^2).
Dropped: unused attention types and phase constants, the bench blocks, the
BPB training run, and tests that asserted constants against themselves.

35 tests, 35 pass, 0 fail, 0 vacuous; 9 invariants. Five mutants (mask,
causal comparison, softmax shift, RoPE sign, QK gain) each fail >= 1 test.
Seals re-saved on the lab.

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

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-17 19:05:59 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 48
PRs with All Checks Green 2
READY 0
FAILING 48
PENDING 0
NO CHECKS YET 0

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=e769ef021713 != 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 enabled auto-merge (squash) October 17, 2026 19:36
@gHashTag
gHashTag merged commit 12f5af8 into master Oct 17, 2026
25 of 29 checks passed
gHashTag added a commit that referenced this pull request Oct 18, 2026
…loses #10163) (#10164)

* spec(igla): own_model cell 23 verified -- 17 of 17 ML specs compile (Closes #10163)

nn/attention 35/35 on the Railway lab after #10095; the other ML specs
still pass on the same checkout. Tally 1 published, 16 verified, 5 drafts,
5 gaps; the board event follows.

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

* spec(igla): own_model -- re-take the DELIVER cells' evidence for review (Refs #10163)

nn/ternary_ste 26/26, nn/hslm_backward 15/15, nn/hslm_data 39/39,
ml/arena_heap 10/10, ml/file_io_contract 12/12 on the lab; HF and board
endpoints re-read. REVIEWED stays false until a later PR names the review.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag added a commit that referenced this pull request Oct 18, 2026
…n, t27mcp duplicate helpers (Closes #10171) (#10172)

* fix(ci): master green again -- 8 stale corpus-ledger rows, census re-pin after pr-budget.yml (Closes #10171)

Corpus ratchet: #10101 (seven igla/coder specs) and #10095 (nn/attention)
now pass every phase; their rows are dropped and the cap follows 81 -> 73.
Re-pinned: bench_proxy 738 -> 696, prm 521 -> 520, benchmark 315 -> 319
(bdd-block-fallback only: #10101 lengthened then-conditions in BDD blocks
the parser already skips).

Census: #10087 added pr-budget.yml. workflow files 66 -> 67, jobs 87 -> 88,
run steps 313 -> 314, bash steps 292 -> 293, path-not-quiet 198 -> 200.
Re-pinned with tri census pin --bless.

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

* spec(t27mcp): examples.t27 uses check_hints' find/has instead of a second copy (Refs #10171)

#10157 landed examples.t27 with byte-identical find(), has() and NO_POS
from check_hints.t27, so duplicate-bodies on master reports two new
groups. examples.t27 now imports t27mcp::check_hints. gen-c still emits
both definitions in the one C file the wasm build compiles; 8/8 tests,
0 vacuous.

Co-Authored-By: Claude Opus 5.5 <noreply@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec(nn): make specs/nn/attention.t27 compile and pass with 0 vacuous tests (cell 23 of #10024)

1 participant