Conversation
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
from
August 8, 2026 17:37
a51850f to
af5993f
Compare
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
from
August 12, 2026 15:26
af5993f to
0531b4b
Compare
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
from
August 14, 2026 21:08
0531b4b to
52a09e0
Compare
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
2 times, most recently
from
August 28, 2026 14:46
48c2c56 to
2e44b8c
Compare
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
from
August 31, 2026 05:38
2e44b8c to
5b3d114
Compare
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
from
September 5, 2026 09:33
5b3d114 to
b29136f
Compare
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
from
September 14, 2026 06:09
b29136f to
e893cdb
Compare
pd95
removed this pull request from stack #26
September 14, 2026 18:24
pd95
added this pull request to stack #27
September 14, 2026 18:24
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
pd95
force-pushed
the
fix/tokenizer-sparse-added-tokens
branch
from
September 18, 2026 12:17
e893cdb to
fe0227a
Compare
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.
Motivation
Hugging Face tokenizer files may assign added tokens IDs far above the base
vocabulary and leave gaps between IDs. Ollama stores vocabulary entries in an
ID-indexed slice. Growing that slice one token at a time causes repeated
allocation and copying, while trusting an unchecked high ID can trigger an
excessive allocation. Duplicate IDs can also overwrite an existing token
silently.
The complete required extent is knowable before insertion and should be
validated before memory is allocated.
What this changes
model creation;
dense vocabularies.
Dependency and scope
This generic tokenizer change depends on Gemma parser-safety PR #12. It does
not introduce a tokenizer format or model-family-specific behavior.
Compare:
fix/gemma4-tool-call-safety...fix/tokenizer-sparse-added-tokens
Validation
The complete
x/tokenizerpackage passes with the expanded loader tests,together with the integrated Linux test/lint/build and Darwin MLX build gates.
Refresh and AI assistance
Reconstructed on Ollama
v0.34.0; heade893cdbc39691edc1ccac63d7caa21e135fb7fb6. Codex materially assistedimplementation review, tests, refresh validation, and this PR description.