Skip to content

Reuse completed rendering during assistant boundary checks - #985

Draft
bradhilton wants to merge 2 commits into
hayek/recorded-token-default-20260926from
hayek/render-proof-reuse-20260927
Draft

bradhilton wants to merge 2 commits into
hayek/recorded-token-default-20260926from
hayek/render-proof-reuse-20260927

Conversation

@bradhilton

Copy link
Copy Markdown
Collaborator

Assistant boundary checking can render a completed history twice: once to obtain its text, then again while locating the final assistant span. Reuse the text already produced when the complete message objects and generation flag match. The existing renderer eligibility checks still apply, and changed generation prefixes still receive their own boundary proof.

Validation: 80 focused tests pass, covering tool probes, native log-probabilities and STOP flags, mutation, cache bounds, and templates whose generation prefix depends on earlier content. Seven paired public CPU measurements reduced median tokenization time from 429.60 to 418.19 ms, with identical tokens, flags, log-probabilities and ownership masks.

Stacked on #977. The measured gain is modest and specific to one public fixture. The dominant cost of recomputing changed prefixes remains; this has not been validated against the retained 062 workload.

Benchmark and review details
  • Fixture: test_prefix_render_cache._history(32), structured tool calls without native token records, using the existing local public tokenizer/template.
  • One process, one warm pair, then seven alternating baseline/candidate pairs. Garbage collection and output verification run outside timing. All seven candidate wall samples were lower.
  • Baseline uses the prior cache method through an adapter that discards the new optional keyword; both variants have one adapter call. CPU medians: 432.01 → 420.01 ms.
  • All 16 returned results match on complete tokenized values and the four first-occurrence masks; input remains unchanged.
  • Independent source review: 42f7171f03f1dbe5754bc17edf724162b8b1350b463b83348ca025dee3a00f88, bound to commit 2ba6d02ee77624e299cd96ab0b6712da392de40e.
  • No retained-input replay, production latency claim or runtime adoption is included.

This branch has not been deployed

No deployments
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