Reuse completed rendering during assistant boundary checks - #985
Draft
bradhilton wants to merge 2 commits into
Draft
bradhilton wants to merge 2 commits into
bradhilton wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
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
test_prefix_render_cache._history(32), structured tool calls without native token records, using the existing local public tokenizer/template.42f7171f03f1dbe5754bc17edf724162b8b1350b463b83348ca025dee3a00f88, bound to commit2ba6d02ee77624e299cd96ab0b6712da392de40e.