cli: auto-size context window to the prompt (long-context usable end-to-end) - #60
Merged
Conversation
…text verified
The completion CLI hardcoded session_opts={0} → the 4096 state default, so
any prompt longer than that hit GEIST_E_TOO_MANY_TOKENS (after the engine
fix) or the silent decode no-op (before it). Now it tokenizes the prompt
through a throwaway default session (tokenize touches no KV cache) and, only
when prompt + decode budget exceeds 4096, rebuilds the session sized to the
workload. Short/medium prompts keep the single-session fast path.
Closes the ctx>=4096 issue end-to-end on Metal (the engine fix 541e442 was
CPU-only-verified): pp5235 greedy completion produces coherent text and is
token-identical to the cpu_neon reference across the 4096 boundary; decode
runs at 22 ms/tok (was 0.0 ms/tok = full no-op). README known-issue updated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
geisten
added a commit
that referenced
this pull request
Jul 5, 2026
…72) The metal-beat-llamacpp-plan.md close (987/81.2, 2026-07-04) predates the #58/#60 Metal work and the #62/#63 dead-flag cleanup. Add a dated data point: a fresh cool compare_metal.sh on main (1020d45) reads 1006 pp512 / 81.6 tg64 / 445 total vs llama same-run 1540/92.8 — within noise of the close. Confirms the flag/kernel/replay removals did not regress Metal. No historical numbers changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #59 (engine ctx≥4096 fix). That fix made the engine correct — a prefill past the session window is rejected with
GEIST_E_TOO_MANY_TOKENSinstead of the old silent decode no-op — but the completion CLI still hardcodedsession_opts = {0}, so it always got the 4096 default and any longer prompt was rejected. This makes long context actually usable from the CLI, and corrects the now-stale README known-issue.What changed
tools/geist.c— before creating the real session, tokenize the prompt through a throwaway default session (tokenize touches no KV cache, so it only pays the tokenizer pass) and, only when prompt + decode budget exceeds the 4096 default, rebuild the session sized to the workload. Short/medium prompts keep the single-session fast path untouched.README.md— the Metal-status blurb still said "decode after a ≥4096-token prefill no-ops (RoPE table sizing, fix in progress)". #59 landed the engine fix but didn't update this; corrected to describe the working behavior.Verification (on current main = #58 + #59)
"The capital of France is"→Paris; 24-token greedy parity vs the cpu_scalar reference unchanged.cpu_neon cpu_scalar metalbuild: 38 unit + 44 int, 0 failed; the fix(engine): honor session max_seq_len; stop decode no-op past ctx 4096 #59 oversized-prefill reject test passes on Metal too.🤖 Generated with Claude Code