Repository navigation
Studio: push only the exported merged model to the Hub on a Mac - #12239
Conversation
NilayYadav
left a comment
There was a problem hiding this comment.
Codex coverage
Mirror: NilayYadav#154, pinned to upstream head 47c76bb19445454712c71597f8a73af7b8774426 (same commit and tree as this PR's current head).
Rounds: 2. Converged: Codex answered "Didn't find any major issues" on 47c76bb in round 2.
- Round 1, P1, pass the Hub token to the second (staged) MLX save for a reused folder: rejected: on the MLX path the bound
save_pretrained_mergedonly readstokeninside its push branch (unsloth_zoomlx/utils.pysave_pretrained_merged, push_to_hub False here) andsave_merged_modeltakes no token, so forwarding it changes nothing; the reused-folder push also succeeded on Apple Silicon with no ambient Hugging Face credential in the Studio home.
Final Codex result on 47c76bb: no major issues.
NilayYadav
left a comment
There was a problem hiding this comment.
Review + reproduction evidence
Pinned review: 47c76bb19445454712c71597f8a73af7b8774426. No blocking findings.
I reproduced the Mac merged push on this PR's merge base and on the PR head. Setup: Apple Silicon, macOS 26, Studio from ./install.sh --local in a throwaway home, logged in through the form, and a LoRA on unsloth/gemma-3-270m-it. I ran Export > Merged Model > Push to Hub, then listed the repo files with huggingface_hub:
- main (1a46fe1):
- Fresh folder: the repo gets
export_metadata.jsonwith"source_checkpoint": "/private/tmp/pr12239/base-home/studio/outputs/unsloth_gemma-3-270m-it_pr12239". - A merged push to the default folder after a LoRA save to it: the repo also gets
adapter_config.jsonandadapters.safetensors. It is missingtokenizer.model,added_tokens.json,generation_config.jsonandspecial_tokens_map.json, because the.cache/thatupload_large_folderleaves in the export folder marks them as already committed. - A pre-created private repo with Private off: the repo was made public.
- Fresh folder: the repo gets
- PR head (47c76bb): all three repos hold the same 11 model files, no metadata and no adapter files. The private repo stays private. No staging dir is left and no
.cache/is written into the export folder. - Adjacent flows, identical on both: LoRA push (5 files) and local-only merged export.
-
Same flows through a real Apple Silicon probe: it builds a real gemma-3-270m-it LoRA, then runs the real
ExportBackendand unsloth_zoo save and push, with only theHfApinetwork calls recorded. On main it fails all 3 scenarios:upload_large_foldersendsexport_metadata.json, the reused folder also sendsadapter_config.jsonandadapters.safetensors, and the private repo is left public. On the PR head all 3 pass with oneupload_foldereach. The macOS Actions A/B mirrors of this harness sat in the fork's queue for over an hour without starting, so I closed them. This result is from the same harness run on my Mac. -
Upstream CI on this PR: 33 pass. The 2 red jobs fail only
test_every_playwright_driver_is_invoked_by_cionplaywright_user_message_time.py. That test fails the same way on main 501b15f (Backend CI run 36489139211), so it is not caused by this PR. -
Tests on Modal: the 4 new tests fail on the merge base and pass on the head. The other 38 tests in
test_export_hub_push.pyare unchanged. -
Blast radius: only the
_IS_MLXbranch of the merged push changes. Non-Mac pushes, and Mac local, GGUF and LoRA exports, take the same code as before. A reused folder costs one extra merged save, the same as the non-Mac path.
Follow-up, not blocking: export_base_model has the same MLX push_to_hub_merged call (export.py around line 1283). The Export page never calls /export/base, so only raw API callers reach it.
Unrelated to this PR, and the same on main: the Push to Hub token field refuses Hugging Face OAuth tokens longer than 512 characters (PUT /api/settings/hugging-face-token returns 422). A merged push with the field empty also stops with "Repository ID and Hugging Face token required" instead of using the CLI login.
Conclusion: The bug is real on every Mac merged push, and the PR fixes it. The fix matches the non-Mac merged path. Ready to merge once upstream CI is green.
The Mac base-model push still handed the save folder to push_to_hub_merged, which uploads everything in it: export_metadata.json with the absolute path of the source checkpoint, leftovers of an earlier export to the same folder, and an unticked Private switch made an existing private repo public. Both Mac full-model pushes now share one upload helper that opens the repo like every other Studio push, skips the local metadata, and uploads a clean second save when the folder was reused.
|
Pushed 1fc1b7b on top of this PR: the Mac base-model push had the same problem as the merged one.
Validated with a real MLX load and LoRA merge on a tiny Qwen2 checkpoint, pushed to a recording fake |
|
Codex and CI on
|
Lyxot
left a comment
There was a problem hiding this comment.
LGTM. The Mac merged and base Hub pushes now upload only the exported model and never loosen repo visibility. Validated on a real MLX merge against a fake Hub, and Codex found no major issues. The remaining upstream failures come from main's own Playwright CI registration, which main has since fixed.

On a Mac, pushing a merged model to the Hugging Face Hub uploads the whole save folder. Even the first push sends export_metadata.json, which holds the full local path of your training run (like /Users/you/.unsloth/studio/outputs/run). If the folder already held a LoRA adapter exported there earlier, the adapter files land in the merged repo too.
The Mac merged push now uploads the way the other platforms already do, with a single upload of the folder instead of the resumable large-folder upload it used before. The local metadata file stays out, and a folder that was not empty gets a clean copy of the merged model uploaded instead. The model card is still uploaded, and the local export is unchanged.
Because the merged push now opens the repo like every other Studio push, an unticked Private switch no longer makes an existing private repo public here.