Repository navigation
Conversation
… sent before A chat client re-sends its whole conversation every turn, and the CUDA server tokenized all of it each time. For a long agent conversation that is millions of small native allocations a request, made on the request's own thread; glibc keeps much of that memory in the thread's arena after it is freed, so rank 0 grows by GiBs over a session until the node runs out of memory. The tokenizer splits its input at the added tokens it matches before normalization and encodes each part on its own. PromptPieces cuts the rendered prompt after each such token, encodes only the pieces it has not seen and reuses the ids of the rest, within a token budget. The ids are the tokenizer's own: a tokenizer whose added tokens could move a split (rstrip, single_word, special tokens encoded as text) keeps the full encode.
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.
Effect
token_shaidentical between the two images, and--alone --serialequal in every cell.Reproduce
token_shaper reply, the same conversation re-sent with a new last turn each time.Change
server/prompt_pieces.pyand one call incuda/server.py: the rendered prompt is cut after each added token and only unseen pieces are encoded.Why
Type
type: fix: a bug fix, or a fix after review findingsTests
Checklist
AI disclosure
AI: Claude Opus 5.5 via Hermes Agent
Checked: by author