No default changes. scripts/e2e/prefix_tail_equivalence.py scores the `reply` prefix-cache tail live: record an agent session against the reply arm (history built from its own output, so it resumes from its own reply checkpoint), replay the exact request bodies on a cold server (--prefix-cache-mib 0), and judge greedy identity of every output item, tool-call integrity of each arm (declared name, call_id, JSON arguments against the tool schema, streamed deltas == done == item, response.completed), restore evidence (cached_tokens) and, with --control, cold-vs-cold determinism. Verdicts PASS / FAIL_* / INCONCLUSIVE_*. Two sequential phases because one 5090 cannot hold two serve instances. Tested on in-process fake servers (15 tests); it has NOT been run against the engine. The plan (scripts/e2e/prefix_tail_equivalence_plan.md) also records the open numeric-gate decision (q_tail_gate needs teacher-forced captures). docs/prefix-cache.md: the stale "EXPERIMENTAL: off by default" lines now agree with the measured paragraph, and both say that the rtx5090-32g profile sets the tail while the live equivalence gate is open. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
71 lines
5.5 KiB
Markdown
71 lines
5.5 KiB
Markdown
# Test plan: prefix-cache `reply` tail, restore vs cold prefill (STRA-328)
|
|
|
|
Status: plan and tool ready; **not run** (needs the 5090, which was not available to this work). Nothing here changes a default.
|
|
`rtx5090-32g` still ships `memory.prefix_cache_tail = reply`; the verdict of this plan decides whether that stays (AGENTS.md: a lossy default needs
|
|
its quality gate).
|
|
|
|
## What is being tested
|
|
|
|
After a request the `reply` tail stores a checkpoint at the end of prompt + committed reply
|
|
(`crates/leleka-runtime/src/qwen_forward/original_serve_prefix.rs`, around lines 511-526). The cells past the prompt were written by the decode
|
|
kernels. The next agent turn resumes from there; a cold prefill of the same tokens would write them with the prefill kernels. The states are not
|
|
bit-identical by construction, so the question is whether the continuation is the same and whether tool calls stay intact.
|
|
|
|
Existing evidence (`docs/prefix-cache.md`, job 9d4/9d5, `scripts/quality/q_tail_gate.py`): d_top1 p99 0.401 and flips 1.45 % for `reply` against 0.394 and
|
|
1.45 % for a chunk-cut control, teacher-forced on 40 requests. That shows the noise floor only. A replay cannot score `reply` itself (an arm's own greedy
|
|
replies diverge from the recorded ones, so the next recorded prompt no longer extends them) and no tool-call integrity check was recorded.
|
|
|
|
## Design
|
|
|
|
Paired, live, greedy, same tokens: `scripts/e2e/prefix_tail_equivalence.py`.
|
|
|
|
1. **Record (reply arm).** A multi-turn agent session (shell / read_file / update_plan tools with canned tool results, a 60-70k-token context file)
|
|
is driven against the reply arm. The history of every request is built from that arm's own output, so each request after the first resumes
|
|
from its own reply checkpoint, as in production. The exact request bodies and the arm's answers are written to a recording.
|
|
2. **Replay (cold arm).** The server is restarted with `--prefix-cache-mib 0` (everything else identical) and the recorded bodies are sent unchanged:
|
|
a cold prefill of identical tokens. With `--control` every cold request is sent twice to establish that greedy decoding is run-to-run
|
|
deterministic on this setup; without that control a difference cannot be blamed on the restore.
|
|
3. **Judge** (`judge()`): per request, output items identical string for string (message text, function_call name and arguments, reasoning text);
|
|
tool-call integrity on each arm (declared name, call_id, arguments parse as a JSON object and satisfy the tool schema, streamed argument deltas ==
|
|
done == item, stream ends with `response.completed`); restore evidence (`usage.input_tokens_details.cached_tokens` of the reply arm >= 50 % of the
|
|
input on at least 80 % of the requests after the first; the cold arm must report none).
|
|
|
|
Verdicts and exit codes: `PASS` 0; `FAIL_OUTPUT_DIFFERS`, `FAIL_TOOL_CALL_INTEGRITY` 1; `INCONCLUSIVE_NO_RESTORE`, `INCONCLUSIVE_NONDETERMINISTIC`,
|
|
`INCONCLUSIVE_COLD_ARM_WARM` 2; usage 3; `ERROR` 4. An inconclusive run is not evidence for the default.
|
|
|
|
## Preconditions on the server
|
|
|
|
* The 5090 free of other jobs (one serve instance at a time; the two phases are sequential for that reason). Memory headroom first (`mem_ok`-style
|
|
check): the server hung on 2026-10-29 around 23:25Z under memory pressure.
|
|
* Same binary, model digest, context, KV type, speculation settings; `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=0` (static tier) in both phases.
|
|
* Outputs in a run root outside Git (they hold prompts and replies). Record the hardware, software, model digest, flags, token counts and cached
|
|
tokens as the charter requires (the result JSON carries per-request input / cached / output tokens).
|
|
|
|
## Commands
|
|
|
|
```
|
|
python3 scripts/e2e/prefix_tail_equivalence.py record --reply-url http://127.0.0.1:8081 --model <model id> --key-file <key file> \
|
|
--context-file <60-70k-token text> --turns 12 --record-out <run root>/tail-record.json
|
|
# stop the server; start it again with the same flags but --prefix-cache-mib 0
|
|
python3 scripts/e2e/prefix_tail_equivalence.py replay --cold-url http://127.0.0.1:8081 --record <run root>/tail-record.json --control \
|
|
--key-file <key file> --out <run root>/tail-equivalence.json
|
|
```
|
|
|
|
Run it on at least three independent sessions (different context files / task scripts) before reading anything into a PASS; one session is one sample.
|
|
|
|
## Numeric gate (acceptance item AC1, q_pair / class numbers)
|
|
|
|
`scripts/quality/q_pair.py LOG_A LOG_B [--control LOG_A2]` compares the top-16 log-probability rows of two port smoke logs of the SAME teacher-forced
|
|
corpus bit for bit; `scripts/quality/q_tail_gate.py REPLAY_LOG CAPTURE_DIR [--control LOG2]` applies the rule p99, max and flip rate each <= 1.25 x the
|
|
chunk-cut control. Both need teacher-forced logs, and the recording above is not in the capture format `q_tail_gate.py` reads. Open decision for the
|
|
owner / TL: either convert the recorded session to a capture directory (the reply arm's tokens as the forced path) or take captures from live
|
|
sessions of job 9e3. Until then this plan gives the greedy-identity and tool-call evidence, not the numeric class.
|
|
|
|
## Decision rule
|
|
|
|
* `PASS` on all sessions and the numeric gate within the control: keep `reply` as the default; add the evidence (verdict JSONs, command lines,
|
|
hardware / software / digest) to `docs/prefix-cache.md`.
|
|
* Any `FAIL_*`: make `prompt` (or `off`) the profile default and mark `reply` as an explicitly experimental mode. That is a separate change that
|
|
needs the owner.
|
|
* `INCONCLUSIVE_*`: fix the setup and re-run; the default stays as it is, flagged as unproven.
|