Repository navigation
Upload merged models to the requested branch or pull request - #10760
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4cde830b89
ℹ️ 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".
| operations = [ | ||
| CommitOperationAdd( | ||
| path_in_repo = path.relative_to(directory).as_posix(), path_or_fileobj = path | ||
| ) |
There was a problem hiding this comment.
Delete stale checkpoint files before committing the merge
When the destination branch already contains a checkpoint with a different serialization or sharding layout, this add-only commit leaves obsolete weight files in place. For example, replacing an unsharded model.safetensors with indexed shards still leaves the old single-file checkpoint, which Transformers can select instead of the newly uploaded weights; similarly, changing serialization formats can retain a stale preferred file. Include deletion operations for superseded checkpoint artifacts so the requested revision cannot silently load the previous model.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This behavior predates this change: Transformers _upload_modified_files emits only CommitOperationAdd, and Zoo uploads through upload_file/upload_folder without deletion patterns. Reproducing the previous uploader leaves the same stale files. Keeping cleanup outside this PR. Sources: https://github.com/huggingface/transformers/blob/main/src/transformers/utils/hub.py and https://github.com/unslothai/unsloth-zoo/blob/main/unsloth_zoo/saving_utils.py
|
@codex review |
|
Verified
Every run has six jobs: Ubuntu, macOS 15, Windows × Hub 0.36.2 and 1.31.0, Python 3.12. All downloaded JUnit reports have zero errors and skips. Each before/after pair uses identical tests, workflow, and dependencies; only Verified assertions include:
Local focused and related saving tests: 100 passed. The focused suite also passed all 35 tests with Hub 1.31.0. These CPU tests execute the saving functions and real model-card/commit-operation classes with deterministic merge and Hub I/O fixtures. No live Hub upload, GPU merge, or UI change is involved. Broader staging at PR code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0820ca5f8
ℹ️ 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".
| if isinstance(model, PeftModel): | ||
| card.data.base_model = base_model |
There was a problem hiding this comment.
Refresh provenance for staged full-model uploads
When a non-PEFT full-finetuned model is uploaded to an existing destination, the remote card is reused but this condition prevents its base_model from being refreshed, so a repository or branch previously populated from another model continues advertising the old lineage. The helper already derives current provenance when no remote card exists, and the newly added full-finetune route confirms these models now pass through this helper; apply the same refresh when card was loaded remotely rather than restricting it to PeftModel.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This is preexisting for full models. The previous path delegates to Transformers push_to_hub; its create_and_tag_model_card loads the existing remote card and appends tags without refreshing base_model. Running that helper and this PR with current model base/model and remote card previous/base returns previous/base in both cases. The adapter path regression was fixed separately. Source: https://github.com/huggingface/transformers/blob/main/src/transformers/utils/hub.py
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d50b365cf5
ℹ️ 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".
| revision = save_kwargs["revision"] | ||
| if revision is not None and not revision.startswith("refs/pr/"): | ||
| try: | ||
| api.create_branch(repo_id = repo_id, repo_type = "model", branch = revision, exist_ok = True) |
There was a problem hiding this comment.
Initialize new repositories before creating a branch
When repo_id is newly created and revision names a branch, the repository is still empty and has no main commit from which HfApi.create_branch can branch, so this request raises before the staged model can be committed. This makes the new named-revision upload path fail for a common first upload; initialize the repository first or otherwise create the initial commit at the requested destination.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Hub create_repo initializes main with a system commit containing .gitattributes, so the stated empty-repository premise does not apply. Official list_repo_commits documentation describes that initial commit: https://huggingface.co/docs/huggingface_hub/package_reference/hf_api#huggingface_hub.HfApi.list_repo_commits . The upstream test_create_and_delete_branch calls repo_factory() then create_branch immediately: https://github.com/huggingface/huggingface_hub/blob/main/tests/test_hf_api.py#L1595 . That factory only calls create_repo and records cleanup, with no upload or extra commit: https://github.com/huggingface/huggingface_hub/blob/main/tests/conftest.py#L200 . No initialization commit to the default branch is needed here.
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Confirmed the merged save path in unsloth/save.py drops revision and create_pr when it hands off to merge_and_overwrite_lora, so files land on main instead of the requested destination; thanks for the staged single-commit approach and the test coverage, will get this reviewed. |
|
At Native checks ran on Windows with an RTX 5090, using a tiny generated BF16 Llama for actual LoRA merging and full-model saving. Thirty-five destination tests passed with Hub 0.34.0, 1.14.0, and 1.31.0 clients; those version suites simulate merging and transport. Large-model temporary disk use was not measured. An export can overwrite a concurrent README edit made after its card snapshot. The optional Python 3.13 timing check failed, and the CPU CI job was cancelled. No exact-base CI attribution was performed. |
Users can choose a branch or pull request when uploading a merged model. The upload could ignore that choice and write files to the main branch. Model files could also fail to stay together at the requested destination. This change prepares the complete model before starting the upload. It uploads all files together to the chosen branch or pull request. The existing model description, tags and dataset information are preserved. This keeps the uploaded model complete and available where the user expects it.