Skip to content

Fix push-hf command in CLI#18

Open
cmpatino wants to merge 9 commits into
thinking-machines-lab:mainfrom
cmpatino:push-hf-cli
Open

Fix push-hf command in CLI#18
cmpatino wants to merge 9 commits into
thinking-machines-lab:mainfrom
cmpatino:push-hf-cli

Conversation

@cmpatino
Copy link
Copy Markdown

@cmpatino cmpatino commented Feb 3, 2026

This PR fixes two issues when using the push-hf command in the CLI:

  1. Fixes how we dealt with the checkpoint_complete file because the previous version conflicted with the Click CLI.
  2. The previous version required having the revision already available in the Hugging Face Hub. We now create the revision if it's not already available.

Comment thread src/tinker/cli/commands/checkpoint.py Outdated
Comment on lines +536 to +537
checkpoint_complete_file = extract_dir / "checkpoint_complete"
checkpoint_complete_file.unlink(missing_ok=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
checkpoint_complete_file = extract_dir / "checkpoint_complete"
checkpoint_complete_file.unlink(missing_ok=True)
checkpoint_complete.unlink(missing_ok=True)

@cmpatino cmpatino marked this pull request as draft February 3, 2026 15:16
The command checks whether the target repository for the upload has a main branch. The previous logic left the main branch empty, which causes problems when using the model with transformers. The CLI now also exposes the `overwrite` arg to avoid overwriting a revision in HF without explicit approval from the user.
@cmpatino
Copy link
Copy Markdown
Author

Improved push-hf Command

Changes

1. Main Branch Initialization with Real Content

  • Before: New repos had main branch with just a minimal README
  • Now: Main branch gets the actual checkpoint content

2. Added --overwrite Flag (default: False)

  • Prevents accidental overwrites of existing branches
  • Requires explicit --overwrite flag to replace existing content

Key Scenarios on Revision Logic

New repo, no revision:

tinker checkpoint push-hf tinker://run/weights/0001 --repo user/model

→ Uploads to main

New repo with revision:

tinker checkpoint push-hf tinker://run/weights/0001 --repo user/model --revision step-0001

→ Uploads to main, creates step-0001 branch from main

Existing branch without --overwrite:

tinker checkpoint push-hf tinker://run/weights/0002 --repo user/model

→ Error: "Branch 'main' already exists. Use --overwrite to replace..."

Existing branch with --overwrite:

tinker checkpoint push-hf tinker://run/weights/0002 --repo user/model --overwrite

→ Overwrites main branch

New revision in existing repo:

tinker checkpoint push-hf tinker://run/weights/0002 --repo user/model --revision step-0002

→ Creates and uploads to step-0002 (main unchanged)

Benefits

  • Main branch always has usable model content
  • Prevents accidental overwrites
  • More efficient branching (no duplicate uploads)

@cmpatino cmpatino marked this pull request as ready for review February 17, 2026 14:57
@cmpatino cmpatino requested a review from kashif February 17, 2026 14:57
Copy link
Copy Markdown
Contributor

@kashif kashif left a comment

Choose a reason for hiding this comment

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

lgtm

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.

2 participants