Repository navigation
Studio: stop merging the model twice when pushing a merged export to the Hub - #11050
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: 93ac172158
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70f808afd3
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 544d8fd9b5
ℹ️ 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".
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b643d9aff
ℹ️ 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".
…ush with no weights
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
Review + GitHub Actions and Studio evidencePinned head: Studio, Chromium 1440×1100, Modal L4, transformers 5.5.0, local stand-in Hub (no real token). Export page,
GitHub Actions A/B. Same workflow and the same tests from
Full CI on a fresh-main staging copy of The red |
|
Confirmed the merged Push to Hub path in studio/backend/core/export/export.py still falls through to push_to_hub_merged and merges a second copy, and that the saved folder is never the one uploaded. Will get this reviewed. |
…d disk Three follow-ups to uploading the saved merged export instead of merging a second time. A merged folder with no weights is no longer refused. The refusal was justified by a Kaggle /tmp redirect, which cannot reach this call: `kaggle_tmp_redirect` returns an absolute path unchanged, and Studio always resolves the save directory to one. Before the folder was uploaded at all such a push still succeeded through `push_to_hub_merged`, so the weights test now sits in the branch condition and a folder without them falls through to that merging push rather than failing the export. `export_metadata.json` stays out of the repo. It is Studio bookkeeping the Chat page reads from disk, and its base model comes from an adapter's `base_model_name_or_path`, so it can be a local filesystem path — the same leak the model card already avoids, and the GGUF push already keeps the file local. Finder metadata is ignored for the same reason, and no longer makes a fresh export folder look reused. The clean second save for a reused folder is staged where it fits. Pinning it beside the export puts a second full checkpoint on a filesystem that has just taken the merge, and `merge_and_overwrite_lora` refuses a save its destination cannot hold; pinning it to the temporary directory fails wherever that is the smaller one. Free space alone is not enough either, since only the export directory itself has to be writable, so the roomier candidate is tried first and the other is used when it refuses the folder.
|
Reviewed the branch and pushed A merged folder with no weights is no longer refused. The refusal cited a Kaggle
The clean second save for a reused folder is staged where it fits. Putting it beside the export places a second full checkpoint on a filesystem that has just absorbed the merge, and Validation: 78 tests across |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9d1e2d751
ℹ️ 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".
…e one it saved The weights test sat in the branch condition and so read the export directory. A reused folder holding a stale checkpoint file satisfies that test, after which the clean staging save can still come out empty and be uploaded, publishing a repository with no weights and reporting success. The test now runs on the folder actually being uploaded, after the staging save. Anything without weights takes the merging push instead, which stays the single `push_to_hub_merged` call site, so the branch condition is back to asking only whether the export directory exists.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46f20bc0f6
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
Lyxot
left a comment
There was a problem hiding this comment.
Approving. The double merge is real and this removes it: the folder already saved to disk is what gets uploaded, matching what the GGUF and compressed-tensors pushes already do. A reused save folder can hold files the export did not write, so that case uploads a clean staging copy instead, staged on whichever filesystem has room for it and falling back when one refuses the folder. A folder without weights falls through to push_to_hub_merged rather than publishing an empty repository, and Studio's own export_metadata.json stays out of the repo, as the GGUF push already ensures.
Merge safety checked against main at f70af706b1: merges cleanly, and main has touched none of the four files this changes. Full CI on a fresh-main copy of the branch was green apart from two jobs that are red for reasons outside this change:
Repo tests (CPU, studio)— reproduces on pristinemain. The PowerShell shared-runner meta-test namestests/python/test_uv_requirements_path_space.py:124, added by #11064.(Python 3.13, l-r)—test_mcp_stdio_sessions.py::test_close_generation_keys_hold_no_secrets, 1 failed against 18,305 passed, and it fails again on re-run. It cannot come from here: that shard's file set is byte-identical tomain's, andcore/export/export.pyis never imported in it (importingcore.inference.mcp_clientdoes not load it, and notest_[l-r]*file references it).(Python 3.13, a-k), the shard holding every test file this changes, passed.
Also verified HfApi.file_exists against the huggingface-hub>=0.34.0 floor, since the unit tests only exercise it through a double; the (Python 3.11, floor) job passed.
…the Hub (unslothai#11050) * Studio: upload the saved merged export to the Hub instead of merging again * Studio: keep the old Hub push when the merged export folder was not empty * Studio: keep an existing repo's model card when pushing a saved merged export * Studio: upload the saved merged export before a best-effort model card * Studio: upload a clean second save for a reused folder and refuse a push with no weights * Studio: keep a merged Hub push out of the export's own bookkeeping and disk Three follow-ups to uploading the saved merged export instead of merging a second time. A merged folder with no weights is no longer refused. The refusal was justified by a Kaggle /tmp redirect, which cannot reach this call: `kaggle_tmp_redirect` returns an absolute path unchanged, and Studio always resolves the save directory to one. Before the folder was uploaded at all such a push still succeeded through `push_to_hub_merged`, so the weights test now sits in the branch condition and a folder without them falls through to that merging push rather than failing the export. `export_metadata.json` stays out of the repo. It is Studio bookkeeping the Chat page reads from disk, and its base model comes from an adapter's `base_model_name_or_path`, so it can be a local filesystem path — the same leak the model card already avoids, and the GGUF push already keeps the file local. Finder metadata is ignored for the same reason, and no longer makes a fresh export folder look reused. The clean second save for a reused folder is staged where it fits. Pinning it beside the export puts a second full checkpoint on a filesystem that has just taken the merge, and `merge_and_overwrite_lora` refuses a save its destination cannot hold; pinning it to the temporary directory fails wherever that is the smaller one. Free space alone is not enough either, since only the export directory itself has to be writable, so the roomier candidate is tried first and the other is used when it refuses the folder. * Studio: check the folder a merged Hub push is about to upload, not the one it saved The weights test sat in the branch condition and so read the export directory. A reused folder holding a stale checkpoint file satisfies that test, after which the clean staging save can still come out empty and be uploaded, publishing a repository with no weights and reporting success. The test now runs on the folder actually being uploaded, after the staging save. Anything without weights takes the merging push instead, which stays the single `push_to_hub_merged` call site, so the branch condition is back to asking only whether the export directory exists. --------- Co-authored-by: Daniel Han <[email protected]> Co-authored-by: Lyxot <[email protected]>


Exporting a LoRA as Merged 16-bit or 4-bit with Push to Hub merged the whole model twice. It saved the merged model to your folder, then merged it again into a second copy just for the upload. That made the export slower, needed room for an extra copy of the model, and uploaded a different copy than the one on disk.
The push now uploads the folder that was already saved, like the GGUF (#10317) and FP8 or torchao (#10943) exports already do. If Private is on, an existing public repo is made private first, same as the FP8 export.
After training a small Qwen3-0.6B LoRA and exporting it as Merged 16-bit with Push to Hub, the main log shows a second merge into a folder named after the repo. With this change there is one merge, the upload comes from the save folder, and the uploaded files are the same. Merged 4-bit is covered by unit tests only, because saving it locally already fails on transformers 5.5.