Skip to content

Fix: respect tokenizer_id over sibling tokenizer/ directory#787

Closed
rcvtkemgtpguv wants to merge 2 commits into
allenai:mainfrom
rcvtkemgtpguv:fix/tokenizer-id-precedence-609
Closed

Fix: respect tokenizer_id over sibling tokenizer/ directory#787
rcvtkemgtpguv wants to merge 2 commits into
allenai:mainfrom
rcvtkemgtpguv:fix/tokenizer-id-precedence-609

Conversation

@rcvtkemgtpguv

Copy link
Copy Markdown

Summary

  • Make convert_checkpoint_to_hf honor an explicit tokenizer_id (-t/--tokenizer) even when a sibling tokenizer/ directory exists.
  • Add a unit test covering the precedence.
  • Changelog entry under Fixed.

Fixes #609.
Supersedes conflicting #629 (same intent; rebased onto current convert_checkpoint.py location).

Test plan

  • pytest src/test/examples/huggingface/test_convert_checkpoint_tokenizer.py
  • Manual: convert an SFT checkpoint that has ../tokenizer/ while passing -t <other-id> and confirm HF tokenizer files come from -t

rcvtkemgtpguv and others added 2 commits July 21, 2026 22:54
Explicit -t/--tokenizer was ignored when a sibling tokenizer/ folder
existed next to the checkpoint (common for SFT runs). Prefer the
explicit tokenizer_id first, matching expected CLI behavior.

Fixes allenai#609.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ec54dcb69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"olmo_core.nn.hf.convert_checkpoint.AutoTokenizer.from_pretrained",
return_value=fake_tok,
) as from_pretrained,
patch("olmo_core.nn.hf.convert_checkpoint.save_hf_model"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve a config file when mocking model saving

When either new test runs, this mock prevents save_hf_model from writing config.json, and the mocked tokenizer's save_pretrained also writes nothing. convert_checkpoint_to_hf unconditionally calls AutoConfig.from_pretrained(output_path) after saving (even with validate=False), so it raises before reaching the assertions; this makes both the regular Test job and Test examples job fail. Patch AutoConfig too or have the mocked save create a minimal config.

Useful? React with 👍 / 👎.

@rcvtkemgtpguv

Copy link
Copy Markdown
Author

Closing for now — may reopen later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

convert_checkpoint_to_hf.py ignores -t/--tokenizer when sibling tokenizer/ directory exists

1 participant