mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1823] [CLOSED] tokenizer: a long message's ids remembered whole, on top of the piece cache #3700
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3700
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1823
Author: @xrip
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:pr/tokenizer-text-cache📝 Commits (1)
a61d351tokenizer: a long message's ids remembered whole, on top of the piece cache📊 Changes
1 file changed (+13 additions, -0 deletions)
View changed files
📝
tools/strata_tokenizer.py(+13 -0)📄 Description
What
tools/strata_tokenizer.py: on top of 0.1.41's piece cache, a long piece of text between special tokens (one chatmessage, 1,024+ characters) keeps its ids too. The ids are the same; only the work is skipped. At most 256 texts are
kept, and the cache is cleared when full.
Why
An agent sends its whole conversation again every turn. The piece cache skips the BPE merges of repeated pieces, but
the pre-tokenizer regex still runs over the whole conversation each turn. Text between special tokens is already
encoded on its own, so a message seen before can return its ids directly.
Measured
2.5 GHz Xeon E5-2670 v2, before the piece cache existed (fork based on 0.1.38): at a 190K-token conversation,
encoding took 1.06 s per turn before and 0.042 s with this cache. The ids were identical on all 36 turns of a
coding-agent session (34K -> 190K tokens).
How much this adds on top of the piece cache alone was not measured yet: the piece cache already removes the
merges, so the gain is the regex pass over the old messages.
tools.test_strata_tokenizerandserve.test_detokpass.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.