Skip to content

convert : fetch tokenizer vocab and remote code with --remote - #26193

Closed
GrEarl wants to merge 2 commits into
ggml-org:masterfrom
GrEarl:remote-fetch-tokenizer-code
Closed

convert : fetch tokenizer vocab and remote code with --remote#26193
GrEarl wants to merge 2 commits into
ggml-org:masterfrom
GrEarl:remote-fetch-tokenizer-code

Conversation

@GrEarl

@GrEarl GrEarl commented Jul 27, 2026

Copy link
Copy Markdown

--remote currently downloads ["LICENSE", "*.json", "*.md", "*.txt", "tokenizer.model"]. Two kinds of tokenizer files are not covered, so set_vocab() fails for models that need them even though the same model converts fine from a full local snapshot:

  • tiktoken.model — where Kimi K2 / K2.5 / K3 keep their vocabulary. Not matched by tokenizer.model.
  • *.py — several converters call AutoTokenizer.from_pretrained(self.dir_model, trust_remote_code=True), which resolves the tokenizer class from the model directory. For Kimi that is tokenization_kimi.py, which in turn relative-imports encoding_k3.py.

Concretely, on moonshotai/Kimi-K3 via kimi_linear.py:

OSError: ... does not appear to have a file named tokenization_kimi.py

deepseek.py reaches the same call for Kimi-K2/K2.5, so this is not specific to one architecture.

Measured on moonshotai/Kimi-K3 with snapshot_download:

files size tiktoken.model tokenization_kimi.py encoding_k3.py
before 15 57.05 MiB missing missing missing
after 33 59.89 MiB ok ok ok

+2.84 MiB. Most of the 57 MiB in both cases is model.safetensors.index.json, already pulled by *.json.

*.model subsumes the existing tokenizer.model entry, so that one is dropped rather than kept alongside.

On *.py: this only makes --remote match what already happens for a local directory. The converters that need these files already run them via trust_remote_code=True; today the download simply omits them and the conversion aborts. If pulling model code unconditionally is not wanted, the alternative is to pass the already-available self.remote_hf_model_id to AutoTokenizer.from_pretrained so transformers resolves the code from the Hub, but that touches every converter that makes the call rather than one line here.

Not verified: I have not run a full --remote conversion to completion on a model that needs this — the download side is what I measured. Found while testing #26185 (model: add Kimi-K3 text model), where --remote stops in set_vocab for this reason; details in #26185 (comment)

AI usage disclosure: yes. The before/after file listing above is output from a command I ran; the change is the one line shown in the diff.

@GrEarl
GrEarl requested a review from CISC as a code owner July 27, 2026 19:43
@ggml-gh-bot

ggml-gh-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

Hi @GrEarl, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

  • Multiple open PRs from a new contributor: We limit new contributors (those without a previously merged PR) to 1 open PR at a time. You currently have 2 open PRs.

  • AI-generated content: While code is allowed to be generated by AI, please write the PR description and commit messages on your own without the help of AI.


Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@GrEarl
GrEarl deleted the remote-fetch-tokenizer-code branch July 27, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant