Skip to content

aa: add runtime min_len knob to gate when AA starts extrapolating#45

Merged
bodono merged 1 commit intomasterfrom
aa-min-len
Apr 22, 2026
Merged

aa: add runtime min_len knob to gate when AA starts extrapolating#45
bodono merged 1 commit intomasterfrom
aa-min-len

Conversation

@bodono
Copy link
Copy Markdown
Member

@bodono bodono commented Apr 22, 2026

Summary

  • Replace the compile-time FILL_MEMORY_BEFORE_SOLVE switch with a runtime min_len parameter on aa_init. min_len=mem preserves the historical "wait for memory to fill" behavior (the default); min_len=1 lets callers extrapolate from the very first residual pair when mem is large but early acceleration matters.
  • Breaking change: aa_init grows a min_len argument between mem and type1. The Python binding adds min_len as a keyword-only argument defaulting to min(mem, dim), so existing Python callers are unaffected.
  • Validation mirrors mem: min_len < 1 with mem > 0 is rejected; min_len > min(mem, dim) is clamped silently, matching how mem is clamped to dim for rank stability. mem=0 keeps AA disabled and ignores min_len.

Test plan

  • 7 new C unit tests in tests/c/run_tests.c (early extrapolation, safeguard-reject churn at κ=1e10 with min_len=1, validation: reject min_len=0, clamp min_len>mem, mem=0 ignore path)
  • 5 new Python tests in tests/python/test_aa.py (default, min_len=1 early-apply, validation, clamping, mem=0 ignore)
  • Full C suite passes (make LDLIBS="-framework Accelerate" test — all tests pass)
  • Full Python suite passes (36/36)
  • Bench iteration counts / final errors match master byte-for-byte on the default min_len path (14 configs spot-checked)

🤖 Generated with Claude Code

Replace the compile-time FILL_MEMORY_BEFORE_SOLVE switch with a runtime
min_len parameter on aa_init. min_len=mem preserves the historical
"wait for the memory to fill" behavior (now the default in both the C
and Python APIs); min_len=1 lets callers extrapolate from the very
first residual pair when mem is large but early acceleration matters.

Breaking change: aa_init grows a min_len argument between mem and
type1. The Python binding adds min_len as a keyword-only argument
defaulting to min(mem, dim), so existing Python callers are unaffected.

Validation mirrors mem: min_len < 1 with mem > 0 is rejected; min_len
above min(mem, dim) is clamped silently, matching how mem itself is
clamped to dim for rank stability. Mem=0 keeps AA disabled and ignores
min_len entirely.

Coverage:
- 7 new C unit tests in tests/c/run_tests.c exercising early
  extrapolation, safeguard-reject churn under min_len=1 at kappa=1e10,
  and both validation paths (reject min_len=0, clamp min_len>mem).
- 5 new Python tests in tests/python/test_aa.py covering the default,
  min_len=1 early-apply behavior, validation, and clamping.
- Bench iteration counts / final errors match master byte-for-byte on
  the default min_len path (14 configs spot-checked).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@bodono bodono merged commit 05df5f2 into master Apr 22, 2026
27 checks passed
@bodono bodono deleted the aa-min-len branch April 22, 2026 11:52
bodono added a commit that referenced this pull request Apr 22, 2026
Since 0.0.2:
 - Pivoted-QR solver hygiene: warn on mem>dim, slim aa_reset (#44)
 - Runtime min_len knob to gate when AA starts extrapolating (#45)
 - Dim-independent rank tolerance (len·ε·|R₁₁|) (#46)
 - Lifetime diagnostics API: aa_get_stats + AaStats struct with split
   rejection-cause counters (#47)

Co-Authored-By: Claude Opus 4.7 <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.

1 participant