fix(mlx): resolve tokenizer behavior from model metadata - #2276
Open
RezaGolriz wants to merge 2 commits into
Open
fix(mlx): resolve tokenizer behavior from model metadata#2276RezaGolriz wants to merge 2 commits into
RezaGolriz wants to merge 2 commits into
Conversation
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.
Summary
config.json,generation_config.json, andtokenizer_config.jsoninstead of repository-name substringstrust_remote_codeFixes #1371.
Fixes #2085.
Why this approach
Model names are mutable and user-controlled; architecture and tokenizer metadata describe the artifact that is actually being loaded. The resolver is local-only and fail-closed for malformed existing metadata. This also covers the EOS symptoms in #2265 without adding new model-name allowlists or automatically executing arbitrary repository code.
Validation
uv run pytest -q src/exo/worker/tests/unittests/test_mlx/test_tokenizer_metadata.py— 8 passeduv run pytest -q src/exo/worker/tests/unittests/test_mlx -m 'not slow'— 23 passed, 184 deselecteduv run basedpyright src/exo/worker/engines/mlx/utils_mlx.py src/exo/worker/tests/unittests/test_mlx/test_tokenizer_metadata.pyuv run ruff check src/exo/worker/engines/mlx/utils_mlx.py src/exo/worker/tests/unittests/test_mlx/test_tokenizer_metadata.py src/exo/worker/tests/unittests/test_mlx/test_tokenizers.pymoonshotai/Kimi-K2.6metadata: explicit trust disabled rejects custom code; explicit trust enabled loads, encodes, and decodes successfully with EOS163586Safety
No network lookup is added to tokenizer resolution. Invalid local metadata does not reactivate the legacy name heuristics, and remote code remains an explicit model-card/operator decision.