Skip to content

feat(format): transpose-kernel-v1 6-gate PARTIAL discharge#1386

Closed
noahgift wants to merge 2 commits into
mainfrom
feat/tp-001-006-partial-discharge
Closed

feat(format): transpose-kernel-v1 6-gate PARTIAL discharge#1386
noahgift wants to merge 2 commits into
mainfrom
feat/tp-001-006-partial-discharge

Conversation

@noahgift
Copy link
Copy Markdown
Contributor

@noahgift noahgift commented May 2, 2026

Summary

  • Binds FALSIFY-TP-001..006 from transpose-kernel-v1 at PARTIAL_ALGORITHM_LEVEL via 6 verdict functions + reference transpose_rowmajor.
  • 28 unit tests including 6-pair dim sweep + 4-shape correctness sweep.
  • Algorithm-level coverage advances by 6 gates; runtime ship % unchanged.

Gates bound

Gate ID Rule
TP-001 transpose(A)[j][i] == A[i][j] elementwise (bit-exact)
TP-002 transpose(transpose(A)) == A bitwise
TP-003 Non-8-aligned dimensions correct (7×13, 17×3, 1×N, N×1)
TP-004 AVX2 output bit-exact equal to scalar (zero tolerance)
TP-005 transpose(I) == I for square identity
TP-006 2048×128 attention shape matches naive reference

Reference helper

transpose_rowmajor(src, rows, cols) -> Option<Vec<f32>> — pure-Rust row-major transpose, returns None on size mismatch.

Five Whys

See commit message — captures why bit-exact for transpose (memory-layout op, no float arithmetic) and why 2048×128 is hardcoded for TP-006 (production-relevant attention dim).

Test plan

  • cargo test -p aprender-core --lib tp_001_006 — 28 passed
  • PMAT pre-commit gates green
  • CI green

🤖 Generated with Claude Code

Binds FALSIFY-TP-001..006 from transpose-kernel-v1 at PARTIAL_ALGORITHM_LEVEL
via 6 verdict functions plus a reference `transpose_rowmajor` helper.

- TP-001: transpose(A)[j][i] == A[i][j] elementwise
- TP-002: transpose(transpose(A)) == A bitwise
- TP-003: non-8-aligned dimensions transpose correctly (7×13, 17×3, 1×N, N×1)
- TP-004: AVX2 vs scalar bit-exact (zero tolerance)
- TP-005: transpose(I) == I for identity matrices
- TP-006: 2048×128 attention shape matches naive reference

## Five Whys

1. Why does transpose-kernel-v1 list 6 falsification IDs without
   algorithm-level discharge? PMAT lints flagged FALSIFY-TP-001..006
   as unbound at PARTIAL_ALGORITHM_LEVEL.
2. Why does that block ship? Coverage % cannot move while peripheral
   transpose kernel invariants have no algorithm-level verdict module.
3. Why bind both verdicts AND a reference `transpose_rowmajor`? The
   involution gate (TP-002) needs a deterministic transpose to walk
   through twice; the non-aligned gate (TP-003) builds its own test
   matrix and self-transposes. Pinning the reference in-module makes
   the algorithm-level decision rule self-contained.
4. Why bit-exact (`to_bits()`) for TP-001/002/004 vs float-tolerant?
   Transpose is a memory-layout op — there's no float arithmetic to
   round. Any bit-level drift between input and transposed output is
   a pure index/permute bug. Float-tolerant compare would miss
   exactly the regression class the gate exists to catch.
5. Why an explicit 2048×128 hardcoded check for TP-006 (not a
   parametric range)? The contract calls out that specific shape as
   the attention-projection real-world dim. A future kernel that
   accidentally only handles square shapes would pass a parametric
   square sweep but fail the 2048×128 case. The hardcode locks in
   the actual production-relevant dim.

Adds 28 unit tests including a 6-pair dim sweep on TP-002 and a
4-shape correctness sweep on TP-003. Realistic-healthy walks the
canonical 2048×128 / 8×8 identity / non-aligned 7×13 mixed scenario;
pre-fix walks 6 simultaneous regressions (corrupted element, size
mismatch, zero-dim, AVX2 ULP drift, zero-N identity, attention drift).

No runtime % shift; algorithm-level coverage advances by 6 gates.
@noahgift noahgift enabled auto-merge (squash) May 11, 2026 15:31
@noahgift noahgift force-pushed the feat/tp-001-006-partial-discharge branch from eb38b38 to d6da4a7 Compare May 11, 2026 15:31
@noahgift
Copy link
Copy Markdown
Contributor Author

Superseded by #1637 (135-PR squash). The commit content is included verbatim in that PR's diff. Closing now to release runner slots; this PR would have auto-closed when #1637 merges.

@noahgift noahgift closed this May 12, 2026
auto-merge was automatically disabled May 12, 2026 09:21

Pull request was closed

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.

1 participant