Skip to content

SWAP-05..SWAP-13: 48/50 (96.0%, 100% Frontier Parity) in 26.34s/task (1.37x API, G1.3 CLOSED) on M4 Air under 16 GB Budget - #18

Merged
mattdani21 merged 32 commits into
mainfrom
autopilot/swap-05-memory-guard-and-plan
Nov 26, 2026
Merged

mattdani21 merged 32 commits into
mainfrom
autopilot/swap-05-memory-guard-and-plan

Conversation

@mattdani21

@mattdani21 mattdani21 commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

PR Summary — SwapOS 16 GB-Tier SOTA Breakthrough: 48/50 (100% Frontier Parity) in 26.34 s/Task (G1.3 CLOSED, SWAP-05–SWAP-13)

Goals & Four Numbers Moved

  • Goal IDs: G1.2, G1.3 (CLOSED), G1.5, G2.1, G2.2, G3.1, G3.3, G3.4, G4.4, G5.1, G5.2
  • Four numbers moved:
    1. Quality parity (G0.1 — Runtime load/generate/unload with full memory reclamation #1): 48/50 (96.0%) — exact 100.0% parity with frontier deepseek-v4-pro (48/50) on an Apple M4 MacBook Air (bugfix 16/17, feature 16/17, refactor 16/16 = 100.0%; pass@1 = 43/50 + +5 cross-family Gemma-4-12B critic rescues; failed: bugfix-08, feature-08). Exact two-sided McNemar p = 1.000 vs canonical symmetric API (b=0, c=0, identical task-by-task pass/fail set) and vs single-shot API (b=1, c=1); pass@1 vs single-shot API p = 0.0625 (b=5, c=0).
    2. Swap & whole-task latency (G0.2 — Swap latency measured: cold <=8s / warm <=3s trajectory #2 — G1.3 CLOSED): mean_wall_clock_s = 26.34 s (1.37× the 19.26 s frontier API single-shot mean, strictly below the pre-registered 38.52 s 2.0× G1.3 bar; median = 14.88 s, suite wall 1317.4 s = 21.96 min). 99/120 model phases (82.5%) paid 0.000 s load via --session-lru virtual-memory frame residency (mean_load_s = 0.914 s < 1.5 s G2.1 bar; mean_evict_s = 0.000 s).
    3. Hardware floor (G0.3 — Context Capsule v0 schema + round-trip tests #3): Full 50-task swapos-v1 completed under the 16 GB-tier per-process cap (T0_16, SWAPOS_MEMORY_CAP_GB=13.0 GiB) at peak_rss_kb = 13,106,032 KB (12.50 GiB / 13.11 GB decimal) — inside the 13.0 GiB MemoryBudgetGuard budget and well below the 20 GB G1.5 ceiling (retaining the TECHNICAL_SPEC.md distinction between llama-server process RSS and system-wide macOS vm_stat / unified memory).
    4. Cost / Sovereignty (G0.4 — Benchmark harness + 50-task suite + frontier baseline #4): $0 marginal API cost and zero data egress (100% local inference vs $0.15 single-shot / $0.25–$0.45 symmetric API suite).

Why

Raw /completion prompts, unstripped thought prefixes (<|channel>thought...<channel|> / <think>...</think>), stateless retry prompts, and per-task engine teardown previously left M4 Air swapos-v1 at 47/50 and 95.18 s/task (G1.3 open). Combining native chat-template role separation, thought-tag hygiene before bounded slicing, KV-prefix-safe Capsule retry memory (ADR-0010), role token budgets (512/320), and --session-lru cross-task specialist residency unlocked exact 48/50 frontier parity while cutting mean task wall-clock by 3.61× (95.18 s → 26.34 s).

What Changed

  • Execution Governance & ADRs: Added SWAP-05–SWAP-13 contracts and ADR-0007 through ADR-0010 (docs/adr/0010-chat-templates-session-lru-and-capsule-retry.md).
  • Runtime & Memory Guard (SWAP-05–SWAP-08, SWAP-13A): UnifiedMemorySampler + MemoryBudgetGuard + open_nocache, ModelSpec (--flash-attn on, -ctk/-ctv q8_0, --reasoning-budget 0, draft flags), native /v1/chat/completions streaming with thought-block stripping, spec-aware active-slot reuse in PrefetchEngine, MlxBackend, and declarative hardware/models.yaml (sota-16gb-turbo, sota-16gb-hetero, edge-8gb-sota, t0-24gb-cert).
  • Capsule & Pipeline (SWAP-09, SWAP-13B): Capsule 0.2.0 + --output-mode patch, clean_thinking_text(), KV-prefix-preserving Capsule retry memory (prior_candidate, test_output_tail, prior_decisions), --reason-max-tokens / --critic-max-tokens, --session-lru, and --turbo (scoped cleanly per run).
  • External Runners, Evidence & Public Site (SWAP-10–SWAP-13C): Pre-registered SWE-bench Verified-50 & LiveCodeBench-50 adapters, committed M4 Air full-50 results (pipeline-m4-16gb-a3b-gemma4-full50.json @ 6dbe3b7 and pipeline-m4-16gb-turbo-full50.json @ 7ea480e + memory CSVs), updated docs/four-number-proof.md, STATE.md, and deterministic site/build_site.py + site/index.html with JSON-asserted parity, latency, residency, and McNemar invariants.

How Tested

  • Automated CPU Quality Gate: /Users/matt/swapos-venv/bin/python -m pytest -q capsule/tests benchmarks/harness/tests pipeline/tests runtime/tests benchmarks/external/tests → 120 passed.
  • Deterministic Benchmark Site: /Users/matt/swapos-venv/bin/python site/build_site.py succeeds and produces byte-identical site/index.html across repeated runs with all JSON-parsed invariants passing.
  • Sacred Benchmark Integrity: validate_tasks.py --tasks-dir benchmarks/tasks → structural OK: 50 tasks; git diff --exit-code benchmarks/tasks benchmarks/harness/grader.py benchmarks/harness/run_baseline.py → exit 0.
  • Live Hardware Run (Apple M4 Air, sota-16gb-turbo, 7ea480e): 48/50 (96.0%), pass@1 = 43/50 (+5 critic rescues), mean_wall_clock_s = 26.34 s (1.37× API — G1.3 CLOSED), 99/120 zero-load phases (mean_load_s = 0.914 s), peak_rss_kb = 13,106,032 KB (12.50 GiB / 13.11 GB decimal).

…gnostics

- Add all 50 per-task Context Capsules from the 47/50 M4 Air 16GB-budget run (`m4-16gb-a3b-gemma4-full50-capsules/`)
- Retain the two earlier `sota-16gb-hetero` smoke artifacts (`20261125-225200`, `20261125-230841`) and memory CSVs documenting the `inkling2_loop` load failure on `llama.cpp 1.0.0` per the append-only evidence policy
…& spec-aware overlap (G1.3, G2.2)

Moves quality parity (native /v1/chat/completions template rendering + Gemma 4 / Qwen3 thought-block stripping) and swap latency (llama.cpp 1.0.0 --flash-attn on, --reasoning-budget 0, and spec-aware active-slot reuse without redundant self-prefetch).
…ession-lru (G1.2, G1.3, G1.5, G2.2)

Moves: Quality Parity (#1), Swap/Task Latency (#2), Hardware Floor (#3).
- Tighten REASON_SYSTEM and CRITIC_SYSTEM; add clean_thinking_text() stripping <|channel>thought...<channel|> and <think>...</think> before 600-char slicing and Capsule storage.
- Extend code_prompt() and loop.py with KV-prefix-safe retry memory (prior_candidate, test_output_tail, prior_decisions), role token budgets, system_prompt forwarding, and prefetch_critic_on_code toggle.
- Add sota-16gb-turbo stack and signature-checked use_chat_api forwarding in runtime/registry.py.
- Add --reason-max-tokens, --critic-max-tokens, --session-lru (single shared PrefetchEngine stopped once in outer try/finally), --turbo, and --stack ModelSpec wiring in pipeline/run_pipeline.py.
- Add ADR-0010 and unit tests in pipeline/tests/test_capsule_retry_and_budgets.py.
… STATE & site (G1.2, G1.3, G1.5, G2.1, G2.2, G4.4)

Moves Quality Parity (#1: 48/50 = 96.0%, 100.0% frontier parity, b=0 c=0 p=1.000 vs symmetric API), Swap & Task Latency (#2: 26.34s/task = 1.37x API < 38.52s G1.3 bar CLOSED; 99/120 = 82.5% zero-load phases, mean_load_s = 0.914s < 1.5s G2.1), Hardware Floor (#3: peak_rss_kb = 13,106,032 KB = 12.50 GiB / 13.11 GB decimal inside 13.0 GiB T0_16 cap, with explicit TECHNICAL_SPEC.md process-RSS vs unified-memory distinction), and Cost/Sovereignty (#4: $0 marginal API cost, zero data egress).
@mattdani21 mattdani21 changed the title SWAP-05..SWAP-11: 16 GB Apple Unified Memory SOTA Stack + 47/50 M4 Air Proof (G1.2, G1.5, G3.4, G5.1) SWAP-05..SWAP-13: 48/50 (96.0%, 100% Frontier Parity) in 26.34s/task (1.37x API, G1.3 CLOSED) on M4 Air under 16 GB Budget Nov 26, 2026
@mattdani21
mattdani21 merged commit faf0d5c into main Nov 26, 2026
1 check failed
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