Skip to content

added better guidance for if deprecated tokenizer path fails #1568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion torchtitan/components/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ def _load_config(self, config_path: str) -> Optional[dict]:
def _load_tokenizer_from_path(self, tokenizer_path: str) -> Tokenizer:
"""Load tokenizer from various file formats."""
if not os.path.exists(tokenizer_path):
raise FileNotFoundError(f"Tokenizer path '{tokenizer_path}' does not exist")
if "assets/tokenizer" in tokenizer_path:
raise FileNotFoundError(
"Detected ./assets/tokenizer path which was deprecated in https://github.com/pytorch/torchtitan/pull/1540.\n"
"Remove --model.tokenizer_path and download to --model.hf_assets_path using ./scripts/download_hf_assets.py\n"
"See example: https://github.com/pytorch/torchtitan/tree/main/torchtitan/models/deepseek_v3#download-tokenizer"
)
else:
raise FileNotFoundError(
f"Tokenizer path '{tokenizer_path}' does not exist"
)

# Define paths for different tokenizer file types
tokenizer_json_path = os.path.join(tokenizer_path, "tokenizer.json")
Expand Down
Loading