Skip to content

fix(checkpoint): resolve HF repo Ids before conversion - #589

Open
rbrisita wants to merge 1 commit into
FlashML-org:mainfrom
rbrisita:fix/checkpoint-model_path
Open

rbrisita wants to merge 1 commit into
FlashML-org:mainfrom
rbrisita:fix/checkpoint-model_path

Conversation

@rbrisita

@rbrisita rbrisita commented Oct 2, 2026

Copy link
Copy Markdown

Summary

ft checkpoint --model <hf-repo-id> produced an FTW checkpoint that was
missing its metadata (config.json, tokenizer.json,
tokenizer_config.json, etc), so the output was not self-contained and could
not be loaded with --model <ftw_dir>.

Root cause

convert_checkpoint assumes model_path is a filesystem path. It walks
it with os.walk and checks it with os.path.isfile / os.path.isdir, and
globs it for shards:

  • python/freetoken/checkpoint/convert.py → _copy_metadata
    (os.path.isfile(model_path), os.walk(model_path))
  • _source_fingerprint (glob.glob(os.path.join(model_path, "*.safetensors")))

All of these treat their argument as a local path. A Hugging Face repo
Id such as nvidia/Gemma-4-26B-A4B-NVFP4 is a Hub identifier, not a
filesystem path. So os.walk was looking for a directory named nvidia/ containing
Gemma-4-26B-A4B-NVFP4 relative to CWD.

The dangerous part is that this fails silently: os.walk on a
non-existent path yields nothing instead of raising. _copy_metadata
returned an empty list, copied_metadata was recorded as [], and the
conversion "succeeded" with only the .ftw shards written.

Reproduction

ft checkpoint --model nvidia/Gemma-4-26B-A4B-NVFP4 --out ./gemma-ftw
ls ./gemma-ftw
# only the .ftw shards + index; no config.json / tokenizer*.json, etc

Fix

Resolve the model path once, at the CLI boundary, before handing it to
convert_checkpoint:

model_path = download_hf_weight(ns.model)

download_hf_weight already handles the local-vs-repo distinction
elsewhere in FreeToken: a path that exists on disk is used as-is, and a
repo Id is fetched via snapshot_download and returned as a local
directory. convert_checkpoint then sees a real path in both cases and
needs no changes of its own.

Testing

Specs

 OS: Ubuntu 26.04 resolute
 Kernel: x86_64 Linux 7.0.0-30-generic
 Shell: bash 5.3.9
 Disk: 1TB
 CPU: 12th Gen Intel Core i7-12700H @ 20x 4.6GHz
 RAM: 64GB 
 GPU: NVIDIA GeForce RTX 3050 Laptop GPU
 VRAM: 4GB
 NVIDIA-SMI 595.91.07
 Driver Version: 595.91.07
 CUDA Version: 13.2
 freetoken version 0.1.3

ft checkpoint --model nvidia/Gemma-4-26B-A4B-NVFP4 --out ./out
Output now contains config.json, tokenizer.json,
tokenizer_config.json, etc, and
index["copied_metadata"] is non-empty.

ft checkpoint --model /local/hf-dir --out ./out
Unchanged; local paths still pass through untouched.

ft checkpoint --model /local/ftw-dir --out ./out
Unchanged; responds with "<model> is already an FTW checkpoint".

ft serve --model ./out loads the FTW via the fast path without
referencing the original HF directory.

Issue

FIxes issue #147

KarrAcaRn pushed a commit to KarrAcaRn/FreeToken-ByAI that referenced this pull request Oct 3, 2026
…ting

Alternative to upstream PR FlashML-org#589: resolving at the CLI with download_hf_weight
only fetches weight shards, so a fresh HF cache still lacks tokenizer and
remote-code files. Resolve in convert_checkpoint and pull the metadata too.

Assisted-by: Claude Opus 5.5
KarrAcaRn pushed a commit to KarrAcaRn/FreeToken-ByAI that referenced this pull request Oct 3, 2026
Adds the fork's PR triage tooling (fork/pr_queue.py) and logs FlashML-org#591, FlashML-org#590,
FlashML-org#589, FlashML-org#587 and FlashML-org#585.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
KarrAcaRn pushed a commit to KarrAcaRn/FreeToken-ByAI that referenced this pull request Oct 3, 2026
…ting

Alternative to upstream PR FlashML-org#589: resolving at the CLI with download_hf_weight
only fetches weight shards, so a fresh HF cache still lacks tokenizer and
remote-code files. Resolve in convert_checkpoint and pull the metadata too.

Assisted-by: Claude Opus 5.5
Co-authored-by: rb <986796+rbrisita@users.noreply.github.com>
KarrAcaRn pushed a commit to KarrAcaRn/FreeToken-ByAI that referenced this pull request Oct 3, 2026
Adds the fork's PR triage tooling (fork/pr_queue.py) and logs FlashML-org#591, FlashML-org#590,
FlashML-org#589, FlashML-org#587 and FlashML-org#585.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant