Skip to content

docs(p3-prd): apr-vs-gguf-forward-parity-v1 — drift-prevention contract codifying §28 binding criterion#1086

Merged
noahgift merged 1 commit into
mainfrom
feat/p3-prd-apr-vs-gguf-forward-parity-contract
Apr 27, 2026
Merged

docs(p3-prd): apr-vs-gguf-forward-parity-v1 — drift-prevention contract codifying §28 binding criterion#1086
noahgift merged 1 commit into
mainfrom
feat/p3-prd-apr-vs-gguf-forward-parity-contract

Conversation

@noahgift

Copy link
Copy Markdown
Contributor

Summary

PR D of the SHIP-TWO-001 §28.8 falsifiable PR sequence. Authors a provable contract that defines the per-layer ffn_swigl parity binding criterion as durable spec. Status PROPOSED until PR E (the actual fix) lands.

What this contract codifies

3 equations:

Equation Formula Status today
per_layer_ffn_swigl_parity r_i = APR.std / GGUF.std ∈ [0.5, 2.0] for all 28 layers FAILS at layer 3 (r₃ = 18.23×)
divergence_starts_at_gate_matmul gate-matmul ratio = 1.36× → silu amplifies 4.59× → multiply amplifies 3.97× → 18.23× confirmed by §28 evidence
fix_must_match_gguf_kernel_path replace f32_matmul with fused_q4k_q8k_parallel_matvec_into for Q4K weights not yet implemented

6 falsification tests including:

  • FALSIFY-APR-GGUF-PARITY-001: per-layer ffn_swigl ratio bounds (28 layers)
  • -002: layer 3 specifically (the load-bearing case)
  • -003: gate matmul precision is causal — Toyota Way enforcement preventing a route-around fix that clamps silu_g*u
  • -004: pv validate
  • -005: F32-native paths unchanged
  • -006: apr trace --payload emits ffn_swigl line on GGUF (PR cascade gate)

Validation

$ pv validate contracts/apr-vs-gguf-forward-parity-v1.yaml
0 error(s), 0 warning(s)
Contract is valid.

$ pv score contracts/apr-vs-gguf-forward-parity-v1.yaml
apr-vs-gguf-forward-parity-v1 — 0.71 (Grade C)
  Spec: 0.70 | Falsify: 1.00 | Kani: 0.25 | Lean: 0.50 | Bind: 1.00

Key design — Toyota Way enforcement

FALSIFY-APR-GGUF-PARITY-003 is the load-bearing falsifier: it asserts that the gate-matmul ratio (the §28 root cause) must be in [0.7, 1.4]. This prevents a route-around fix that clamps silu_g * u to bring ffn_swigl into bounds while leaving the gate-matmul precision issue intact (which would still fail PARITY-003).

This forces the fix to be at the actual root: mod_apr_transformer.rs:138-140 helpers::f32_matmul → Q4K-aware kernel dispatch.

Coverage flip projection

State PARTIAL DISCHARGED
Now (PR D — contract authored) 33 12
PR E merged (fix lands, all 6 FALSIFY pass) 28 17 (62%)

PR D + PR E together discharge 5 MODEL-1 PARTIALs at once: SHIP-002/005/006/007/008.

What this PR does NOT do

  • Does not implement the fix (that's PR E)
  • Does not flip status to ACTIVE (that happens post-PR-E)
  • Does not run the test live (no CI fixture for 7+ GB teacher; live test is operator-dispatched)

Test plan

  • CI workspace-test passes
  • CI gate passes
  • pv validate contracts/apr-vs-gguf-forward-parity-v1.yaml exits 0
  • Contract status field is PROPOSED (not yet ACTIVE)

🤖 Generated with Claude Code

@noahgift noahgift enabled auto-merge (squash) April 27, 2026 10:22
noahgift added a commit that referenced this pull request Apr 27, 2026
…oard + critical-path map — spec v2.73.0 → v2.74.0 (#1087)

Session-end snapshot consolidating today's 10-PR cascade into a
single source-of-truth for next session.

The goal: ship two models to HF, both built end-to-end on the
in-tree Sovereign AI Stack.

Coverage scoreboard EOD 2026-04-27:
| Category    | DISCHARGED | PARTIAL | Total | %D  |
|-------------|-----------:|--------:|------:|----:|
| MODEL-1     |          5 |       5 |    10 | 50% |
| MODEL-2     |          3 |       9 |    12 | 25% |
| GPUTRAIN    |          7 |       0 |     7 |100% |
| Ship Gates  |          - |      12 |    12 |  0% |
| Falsifiers  |          - |       7 |     7 |  0% |
| Sum         |         15 |      33 |    48 | 31% |

Critical path — MODEL-1: PR E (replace helpers::f32_matmul with
Q4K-fused dispatch) discharges 5 PARTIALs at one fix site.
~150-300 LOC.

Critical path — MODEL-2: P1.1 (apr pull dataset extension) →
P1.4 (corpus pull) → P2 (100K-step training) discharges 9
PARTIALs.

10-PR session cascade (6 merged, 4 open + this):
- #1076-#1080: spec + contract foundation (MERGED)
- #1081: P3 PR A scaffold (MERGED)
- #1082-#1083: P3 PR B+C wiring (OPEN, stacked)
- #1084-#1085: §27/§28 binding criterion + root cause (OPEN)
- #1086: PR D forward-parity contract (OPEN)

Falsification chain (complete, root-reached):
§15.4 → §16 → §17 → §23 → §27 → §28 → PR D contract → PR E (next)
"forward path" → ... → "APR F32 vs GGUF Q4K matmul precision"
                            → "binding criterion as durable spec"
                            → "fix at mod_apr_transformer.rs:138-140"

Methodology preserved: zero eprintln!, zero route-arounds, apr
canonical, contract-first, lambda-labs pre-authorized, 5-whys
reaches root.

Next session: PR E first (5 ACs), then P1.1 + P1.4 + P2
(9 ACs).

Spec v2.73.0 → v2.74.0. No coverage flip at amendment — §29 is
a scoreboard, not a discharge.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@noahgift noahgift force-pushed the feat/p3-prd-apr-vs-gguf-forward-parity-contract branch from 788e635 to e470df4 Compare April 27, 2026 14:21
…ct codifying the §28 binding criterion

PR D of the SHIP-TWO-001 §28.8 falsifiable PR sequence. Authors a
provable contract that defines the per-layer ffn_swigl parity
binding criterion as durable spec. Status PROPOSED until PR E
(the actual fix replacing helpers::f32_matmul with Q4K-fused
matmul dispatch) lands.

3 equations:
- per_layer_ffn_swigl_parity: r_i = APR.std / GGUF.std ∈ [0.5, 2.0]
  for all i ∈ [0, 28). Currently FAILS at layer 3 (r_3 = 18.23×).
- divergence_starts_at_gate_matmul: §28 evidence — divergence
  originates at gate-projection matmul (1.36×), amplified by
  silu (4.59×) into the 18.23× ffn_swigl ratio.
- fix_must_match_gguf_kernel_path: §28.4 — fix replaces
  f32_matmul with fused_q4k_q8k_parallel_matvec_into when
  weight.qtype == GGUF_TYPE_Q4_K.

6 falsification tests:
- FALSIFY-APR-GGUF-PARITY-001: per-layer ffn_swigl ratio bounds
- -002: layer 3 specifically
- -003: gate matmul precision is the root cause (Toyota Way
  enforcement — prevents route-around fix at silu_g*u)
- -004: pv validate
- -005: F32-native paths unchanged
- -006: apr trace --payload still emits ffn_swigl on GGUF

4 proof obligations + 2 Kani harnesses with bounds.

Validation:
  $ pv validate contracts/apr-vs-gguf-forward-parity-v1.yaml
  0 error(s), 0 warning(s)
  Contract is valid.

  $ pv score contracts/apr-vs-gguf-forward-parity-v1.yaml
  apr-vs-gguf-forward-parity-v1 — 0.71 (Grade C)
  Spec: 0.70 | Falsify: 1.00 | Kani: 0.25 | Lean: 0.50 | Bind: 1.00

Status: PROPOSED. Promotion to ACTIVE requires:
- PR E lands (replaces f32_matmul with Q4K-fused dispatch)
- Live drift-prevention test PASSES on canonical 7B teacher
- All 6 FALSIFY-APR-GGUF-PARITY-* gates pass

On PR E success:
- Coverage flip 33+12 → 28+17 (§26.5 / §28.9)
- Discharges SHIP-002, SHIP-005, SHIP-006, SHIP-007, SHIP-008
  (5 MODEL-1 PARTIALs transitively gated on §17.5)

This PR (D) ships the binding criterion as durable spec. PR E
ships the fix. §29 records the discharge.

Spec: SPEC-SHIP-TWO-001 §28.8
References:
- §27 (PR #1084) — P3 binding criterion verdict (18.23× ratio)
- §28 (PR #1085) — root cause refined to F32 vs Q4K matmul
- evidence/ship-007-apr-vs-gguf-2026-04-27/ — full sub-FFN bisection
- feedback_fix_root_cause_never_route_around.md
- contracts/qwen2-e2e-verification-v1.yaml (sibling MODEL-1 contract)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@noahgift noahgift force-pushed the feat/p3-prd-apr-vs-gguf-forward-parity-contract branch from e470df4 to d8d7cb2 Compare April 27, 2026 14:59
@noahgift noahgift merged commit 67cd8f3 into main Apr 27, 2026
10 checks passed
@noahgift noahgift deleted the feat/p3-prd-apr-vs-gguf-forward-parity-contract branch April 27, 2026 15:20
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