feat: ADR-018 AC-3 cross-turn prefix reuse (v0.3.11) + full-suite benchmark#12
Merged
Conversation
…ntal prefill) Reuse the KV already cached for the longest matching token prefix and feed only the divergent suffix, instead of re-prefilling the whole conversation every turn. - el-runtime: `InferenceSession::continue_prompt` + the `InferenceEngine::prefill_reuse` port. Safe default re-prefills the full context; stateful engines override for the fast path. A failed continue leaves a recoverable session. - el-engine-candle: `QwenEngine::prefill_reuse` does longest-common-prefix reuse against the live cache and falls back to a full prefill on any mismatch. - Soundness: reuse must leave the cache byte-identical to a fresh prefill — proven by the `ReuseEngine` mock (`prefill_reuse_leaves_same_state_as_a_fresh_prefill`) and it fails open on a wrong/short match. Measured on the full el-bench suite this cuts multi-turn (mindeval) ~3x and the whole-suite wall by a third (see docs/benchmarks/2026-06-23-...).
…ion in README - New report 2026-06-23-adr-018-ac3-prefix-reuse-full-suite.md: full el-bench run (66 tasks / 97 replies, 0 errors, 35.7 min) on the same i5-14500 host as the prior reports. AC-3 cuts prefill from 56.8% to 29.5% of compute and the whole-suite wall by 33.5% vs the 2026-06-22 run; mindeval ~3x faster. Notes that the prefill *kernel* is unchanged (~15 tok/s per forward) so ADR-020 batched prefill is still pending, and decode (~14 tok/s) is now the dominant cost. - README: replace the single-report Benchmarks blurb with a progression table across the three perf reports plus a clinical-safety headline.
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
Performance phase 0.5: lands ADR-018 AC-3 (cross-turn prefix reuse / incremental prefill), bumps the workspace to 0.3.11, and documents the measured win with a full-suite
el-benchreport plus a README progression table.Three focused commits:
feat(runtime,engine): ADR-018 AC-3chore: bump workspace version to 0.3.11cargo set-version --workspace 0.3.11(follows master's 0.3.10).docs(benchmarks): AC-3 report + README2026-06-23report and a benchmark progression table in the README.What AC-3 changes
InferenceSession::continue_prompt+ theInferenceEngine::prefill_reuseport. Safe default re-prefills the full context; stateful engines override for the fast path. A failed continue leaves a recoverable session.QwenEngine::prefill_reusedoes longest-common-prefix reuse against the live cache and falls back to a full prefill on any mismatch.ReuseEnginemock testprefill_reuse_leaves_same_state_as_a_fresh_prefill, and it fails open on a wrong/short match.Measured impact (full el-bench suite, Qwen2.5-0.5B q4_k_m, i5-14500)
Same harness/inputs/host as the 2026-06-22 run; only the AC-3 code differs. 66 tasks → 97/97 replies, 0 errors.
mindeval(multi-turn) avg ms/replyHonest caveat (in the report): the prefill kernel is unchanged — per-forward rate is still ~15 tok/s — so AC-3 wins by doing less work, not faster math. ADR-020 (batched prefill) is still pending for cold/first-turn prefill, and the ~14 tok/s decode floor is now the dominant cost.
Verification
cargo build --workspace— clean at 0.3.11 (excludingel-chat, whose binary was locked by a stale local process;el-chatsource is untouched by this PR and compiled fine).cargo test -p el-runtime— 31/31 pass, including the AC-3 soundness and recoverable-session tests.Notes for reviewers
session.rs,ports.rs,el-engine-candle/src/lib.rs, ADR-018 doc) was already present in the working tree at the start of this work; this PR commits it as-is alongside the version bump and benchmark docs.master(which had advanced to 0.3.10) before committing, so the diff is clean — no spurious revert of master's README/CI/packaging commits.2026-06-22report's "prefill is the Add multi-registry release CI (crates.io · npm · pub.dev) — ADR-011 #1 cost" conclusion is now superseded on the prefill axis by the new report (left intact for history).🤖 Generated with Claude Code