Skip to content

Studio: fix Push to Hub for base and quantized exports - #10943

Merged
mahiatlinux merged 1 commit into
unslothai:mainfrom
NilayYadav:fix-export-hub-create-repo
Sep 15, 2026
Merged

mahiatlinux merged 1 commit into
unslothai:mainfrom
NilayYadav:fix-export-hub-create-repo

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Push to Hub failed for base model exports and for FP8 and NVFP4 merged exports with "PushToHubMixin has no attribute _create_repo", after the files were already saved. The newer transformers version that Studio installs removed that helper.

These exports now create the Hub repo the same way GGUF exports already do, including keeping it private when asked.

Tested with transformers 5.5.0. On main, all four exports failed with that error. On this branch they reach the Hub and stop only at the fake login used for testing, and against a local test copy of the Hub they upload fully and stay private. 16-bit and GGUF pushes work as before. New tests fail on main and pass here.

Two unrelated problems found while testing are not fixed here. torchao INT8 export fails while saving, and the Hub rejects the model card when the base model is a local folder.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T21:56:17.807333Z b493068 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Review + GitHub Actions and UI evidence

Pinned head: b493068c60ca4b05c77e40032aa9b73791757341, merge base 03af220ac0023ab846727397b3a1de9efa0aec42. No blocking code findings.

Root cause

  • PushToHubMixin._create_repo is defined in transformers v4.57.6 (src/transformers/utils/hub.py) and is gone from v5.0.0 and v5.5.0.
  • Studio pins transformers==5.5.0 on Python ≥ 3.10 (studio/backend/requirements/single-env/constraints.txt).
  • On the non-MLX path, the base export and the compressed/torchao merged upload both raised AttributeError after the files were already on disk.
  • HfApi.create_repo(..., exist_ok=True) exists on both huggingface_hub 0.x and 1.x and returns a RepoUrl carrying the resolved owner/name. It is the same call the GGUF upload already makes, and the private-repo handling (_ensure_hub_repo_private) now matches GGUF too.
  • The only UI route into the broken branch is Merged Model with a quantized format (FP8 / NVFP4 / FP8 portable). The export page never calls /export/base.
  • On Apple Silicon the MLX branch runs instead, so Macs never hit this.

GitHub Actions A/B: passing run, 54 checks, 0 failing

Staged on a branch cut from fresh upstream main (8760d44) with this PR merged in cleanly. It runs as one job on one runner, and the only thing that changes between the two halves is studio/backend/core/export/export.py (upstream main's copy vs this PR's). Real transformers, huggingface_hub, peft and CPU torch push to a local stand-in Hub through HF_ENDPOINT. Only unsloth and Studio's lightweight backend modules are stubbed.

transformers / hub export.py base, private base, public torchao FP8, private
5.5.0 / 1.31.0 main _create_repo AttributeError, 0 Hub writes same same
5.5.0 / 1.31.0 PR pushed: create visibility=private, settings {"visibility":"private"}, README.md + model.safetensors committed pushed: create visibility=public, no settings call pushed: private, same as base
4.57.6 / 0.36.2 main pushed (create private=true) pushed pushed
4.57.6 / 0.36.2 PR pushed, plus settings {"private": true} pushed pushed, plus settings {"private": true}

The PR's own tests pass on the PR head (28 passed). With main's export.py swapped in they give 4 failed, 24 passed. The four failures are exactly the new test_export_hub_push.py cases, and the existing GGUF hub-upload tests still pass.

UI evidence: two isolated installs, merge base vs head, Linux + NVIDIA L4

Both Studios run transformers 5.5.0 and load unsloth/Qwen2.5-0.5B-Instruct. The run is Export → Merged Model → FP8 → Push to Hub, with Private Repository on and destination evidence-user/Qwen2.5-0.5B-Instruct-FP8. The model, the FP8 quantization and both Studios are real. The only stand-in is HF_ENDPOINT: a local Hub that answers repo creation, settings and commits and logs every request.

fact BEFORE AFTER
panel banner Export failed: type object 'PushToHubMixin' has no attribute '_create_repo' Export finished and pushed to Hugging Face Hub.
status Failed, 15% Complete, 100%
FP8 folder written locally yes yes
POST /api/repos/create none 1, visibility: "private"
PUT …/settings none {"visibility": "private"}
files committed to the Hub none README.md, config.json, generation_config.json, model.safetensors, recipe.yaml, chat_template.jinja, tokenizer.json, tokenizer_config.json, export_metadata.json

PR 10943 before/after

CI

A staging copy (fresh upstream main + this PR) passed 37 checks. The only reds are the three Core zoo jobs, and they fail inside unsloth_zoo's own suite at 055c049:

  • test_vllm_flashinfer_block_reversible fails in all three jobs.
  • The gemma4 tests also fail on HF 4.57.6, which has no transformers.models.gemma4.

The same failures show on other open upstream PRs today, and none of them touch Studio export.

Conclusion: the Push to Hub failure and its fix are verified end to end, both on Actions with the real libraries and in the real Studio UI. Private repos stay private, and transformers 4.57.6 is unaffected.

Out of scope, and unchanged by this PR:

  • A model loaded from a local folder still fails at the model card step. RepoCard.validate always posts to huggingface.co/api/validate-yaml, which rejects a filesystem path as base_model. The PR description already notes this.
  • The progress line reads "Exporting merged model (16-bit (FP16))..." during an FP8 export.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: b493068c60

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed studio/backend/core/export/export.py still calls PushToHubMixin._create_repo, which no longer exists in the transformers version Studio pins, so the merged quantized push fails after the files are written; switching to HfApi.create_repo with the private re-check matches the GGUF path, and I will get this reviewed.

@mahiatlinux mahiatlinux self-assigned this Sep 15, 2026
@mahiatlinux
mahiatlinux self-requested a review September 15, 2026 02:31
mahiatlinux
mahiatlinux approved these changes Sep 15, 2026 •
@mahiatlinux

Copy link
Copy Markdown
Contributor

Verified b493068c60ca4b05c77e40032aa9b73791757341 with real GPU exports and live Hugging Face uploads. The scoped _create_repo fix works.

Before

At merge base 03af220ac0023ab846727397b3a1de9efa0aec42, base-model upload and Studio FP8 export fail with PushToHubMixin having no attribute _create_repo. The FP8 failure occurs after actual GPU quantization.

After

Using unsloth/Qwen2.5-0.5B-Instruct at source revision ae616882a38b36759fc46ac3fd6769498833b913:

Export Weight file size Live upload and download SHA-256 GPU reload and generation
Base model 988,097,824 bytes Pass Pass
FP8, compressed-tensors 630,899,568 bytes Pass Pass
FP8, torchao 631,588,328 bytes Pass Pass
NVFP4, four calibration samples 473,780,136 bytes Pass Pass

Every listed exported file, including tokenizer/config files, matched after download. Each reload produced finite logits and generated 16 tokens. Public upload with an unqualified repository name passed. Re-exporting to an existing public repo with private=True made it private; anonymous access returned HTTP 401. All private destination repos also rejected anonymous reads.

Verdict

Confirmed fix. No additional defect found in the changed repository-creation and privacy path.

Regression risk

  • All studio/backend/tests/test_export_*.py tests: 292 passed on head, 288 existing tests passed on merge base.
  • 41 API-contract cases passed: public/private destinations, denied creation/settings/upload, missing credentials, local-only export, and 16-bit delegation. These use the real Hub client with mocked HTTP and model operations.
  • The focused 28 tests plus 41 contract cases also passed with Transformers 4.57.6 / Hub 0.36.2. Earlier prospective-merge verification passed the same 69 checks on 82ce8645628f4a3cae88494973d91e9cfc055b87.
  • Changed-source lint passed.

Compatibility

Two separate official Studio installs from merge base and head, both frontend builds successful. Linux x86_64, Python 3.13.14, RTX 5060 Ti, driver 595.91.07, PyTorch 2.11.0+cu130, Transformers 5.5.0, Hub 1.31.0. Compressed export/reload used Studio's separate Transformers 5.10.2 / compressed-tensors environment.

The source weights came from a disposable local cache. Destination creation, visibility updates, uploads and artifact downloads used the real Hugging Face service through a relay that kept the account credential outside PR processes.

UI evidence

Same model, FP8 selection and private destination in separate installs. Chromium 151.0.7922.34, 1440×1000 viewport. Visually inspected: failure on merge base, completed upload on head. Identical fixed screenshot crops omit the log area.

Before and after Studio FP8 export

Fixes

No source changes or additional commits were needed. Test logs, file hashes, environment and cleanup records. All six disposable Hub repos, live-test installs, processes and the local credential file have been removed.

Gaps

  • Live 16-bit merged upload fails on both merge base and head: unsloth_push_to_hub() got an unexpected keyword argument 'safe_serialization'. Left outside this PR's scope.
  • A separate local-directory-input probe hit the unchanged model-card base_model validation. The successful live runs used the pinned Hub model ID.
  • Three Core zoo CI jobs still fail. This is not an all-CI-green claim.
  • No live MLX/macOS, Windows, XPU, multi-GPU, adapter, vision/audio, GGUF-export or training matrix was run. GPU reload checks establish loading and generation, not model quality or quantized-kernel performance.

@mahiatlinux
mahiatlinux merged commit b83a7f5 into unslothai:main Sep 15, 2026
41 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants