Skip to content

test(inference): close Gemma 4 F32 attention evidence gaps (ST4A) - #62

Merged
ezutfen merged 2 commits into
mainfrom
feat/larql-inference-trust-001a-st4a
Jul 12, 2026
Merged

test(inference): close Gemma 4 F32 attention evidence gaps (ST4A)#62
ezutfen merged 2 commits into
mainfrom
feat/larql-inference-trust-001a-st4a

Conversation

@ezutfen

@ezutfen ezutfen commented Jul 12, 2026

Copy link
Copy Markdown

Closes the remaining ST4 attention-evidence gaps without reopening or
expanding its implementation scope. Tests + evidence only — no attention
implementation change.

What

PR #60 landed the F32 CPU Gemma 4 local/global attention + shared-KV
routing. This closeout slice adds the missing acceptance evidence:

  1. Canonical prefill/decode equivalence at the 512-window boundaries
    511 / 512 / 513 / 1024, driven through the production
    kv_prefill_run / kv_decode_step_run loops (Route A one-shot prefill
    vs Route B prefill-prefix + single decode). Real numerical comparison of
    the post-layer hidden state, local source K/V tail, local/global cache
    lengths, shared-consumer absence, and the absolute position pointer.
  2. Qwen2 full-attention regression on a real Qwen2 fixture
    (family == "qwen2", Q/K/V biases): intrinsic window None, full
    causal prefix retained past 512, decode grows cache +1, no shared-KV
    routing, and old-key sensitivity (position-600 decode depends on
    position-0 K/V that a 512-token window would evict).
  3. Source append-count proof: local/global sources append exactly one
    row per decode token (unambiguous deltas below the window cap) and
    shared consumers append zero, across several decode steps.
  4. Correct ST4 report metadata (head 2889157, merge b2584c0, CI
    11/11), Qwen result (was N/A), and measured prefill/decode data (was
    claimed), plus a concise ST4A closeout section.

Measured results (canonical loops, abs tolerance 1e-5)

target hidden max abs hidden max rel local K/V tail abs local len global len
511 1.073e-6 1.023e-6 0 512 512
512 0 0 0 512 513
513 0 0 0 512 514
1024 0 0 0 512 1025

Qwen2 old-key sensitivity: abs 3.679e-4, rel 1.334e-2.

Scope

In scope: F32 CPU synthetic correctness tests + ST4 evidence/report
correction. Q4_K runs as regression only and remains excluded from the
GREEN claim
. No official Gemma 4 checkpoint, no Transformers logits, no
ST5 first-token parity, no GPU paths, no implementation redesign.

Decision

GREEN — all 15 ST4A decision-gate criteria pass.

Next slice: LARQL-INFERENCE-TRUST-001A-ST5 (F32 CPU first-token semantic
parity and first-divergence diagnostics) — not started in this PR.

ezutfen added 2 commits July 12, 2026 11:48
Close the remaining ST4 attention-evidence gaps with synthetic F32 CPU
tests driven through the canonical kv_prefill_run / kv_decode_step_run
loops. No attention implementation change.

* larql-kv/tests/st4_shared_kv.rs:
  - Canonical prefill/decode numerical equivalence at the 512-window
    boundaries 511/512/513/1024 (Route A one-shot prefill vs Route B
    prefill-prefix + single decode). Compares the post-layer hidden state,
    the local source K/V tail, local/global source cache lengths, shared
    consumer absence, and the absolute position pointer.
  - Absolute-position-independent-of-clipped-cache-length pin at 1024.
  - Qwen2 full-attention regression: intrinsic window None, full causal
    prefix retained past 512, decode grows cache +1, no shared-KV routing,
    and old-key sensitivity (position-600 decode depends on position-0 K/V
    outside a 512-token window).
  - Source append-count proof: local/global sources append exactly one row
    per decode token (unambiguous deltas below the window cap) and shared
    consumers append zero; plus the clipped steady-state companion.

* larql-models/src/test_fixtures.rs:
  - make_synthetic_e2b_like_weights_random_window512 + arch json: 4-layer
    E2B-like Gemma 4 shape with a 512-token intrinsic window.
  - make_qwen2_test_weights: small Qwen2 fixture with Q/K/V biases.
  - Refactor make_synthetic_e2b_like_weights_random to share its body.

* larql-inference/src/test_utils.rs: re-export the two new fixtures.
Correct the ST4 (PR #60) report metadata and add the ST4A closeout.

* Correct ST4 PR #60 metadata: head SHA 2889157, squash merge b2584c0,
  CI all 11 workflows green. Remove the prior 'pending PR head' /
  'pending PR creation' placeholders.
* Replace the Qwen 'N/A' result with the passing Qwen2 full-attention
  regression result.
* Replace the claimed prefill/decode data with actual measured canonical
  -loop results (max abs <= 1.073e-6 across 511/512/513/1024; bit-exact
  local K/V tail; local 512 / global target+1 cache lengths).
* Add the ST4A closeout section: work-start SHA, tested implementation
  SHA, target positions, per-position abs/rel diffs, local/global cache
  lengths, source append deltas, Qwen regression, Q4_K exclusion, GREEN.
@ezutfen
ezutfen merged commit c023735 into main Jul 12, 2026
18 checks passed
@ezutfen
ezutfen deleted the feat/larql-inference-trust-001a-st4a branch July 12, 2026 16:18
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