Skip to content

Studio: guard export operations when the Hub is unreachable - #11466

Merged
Lyxot merged 3 commits into
unslothai:mainfrom
Imagineer99:fix/export-offline-window
Sep 25, 2026
Merged

Lyxot merged 3 commits into
unslothai:mainfrom
Imagineer99:fix/export-offline-window

Conversation

@Imagineer99

Copy link
Copy Markdown
Member

Export commands can still consult the Hub after the checkpoint-loading offline window has ended. If connectivity drops between loading and exporting, merge/save metadata requests run without that protection.

Wrap each export command in the existing offline window so it checks connectivity for that operation and restores the previous state afterward, including when export fails.

Supersedes #7065 with only the remaining export change. Also follows the export-window approach in @InfoSage05’s #6861. The broader model-selection, RAG, and GGUF metadata changes are omitted because current main already handles those paths.

Validation: 70 targeted tests passed, 1 skipped. Eight new regression cases cover base, merged, GGUF, and LoRA command dispatch through disconnect, recovery, and export failure; all eight fail on the base revision and pass with this change. These use a stub export backend with real Hub client calls and intercepted HTTP transport. The unrelated MCP policy test was excluded because fastmcp is absent locally. Full GPU merged/GGUF export was not exercised.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the export dispatch in studio/backend/core/export/worker.py is still outside the offline window that load and activation already use, and that the guard stays inert when the endpoint is reachable. Will get this reviewed.

@Lyxot Lyxot self-assigned this Sep 25, 2026
A push needs the Hub, so pinning the whole export offline after a failed probe only guarantees the push fails with huggingface_hub's misleading "unset HF_HUB_OFFLINE" error and prevents recovery if connectivity returns mid-export. Local exports keep the per-export window.

The regression test now intercepts httpx.HTTPTransport, below the request hook where huggingface_hub 1.x enforces offline mode; stubbing httpx.Client.send bypassed that hook and failed every case. It also covers the push path, asserts the exact probe count, and isolates worker-process globals.
@Lyxot

Lyxot commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Pushed a follow-up commit (118aa20) and merged latest main (the branch was 248 commits behind; no conflicts).

What changed:

  • Hub-push exports no longer run inside the offline window. A push needs the Hub, so pinning the whole export offline after a failed probe only guaranteed the push would fail, with huggingface_hub's "unset HF_HUB_OFFLINE" error (a variable the user never set), and it couldn't recover if connectivity came back mid-export. Local exports keep the per-export window, which is what fixes the _patch_mistral_regex → model_info() crash from [Bug] Offline Training and Exporting Is broken #6817.
  • Regression test fixed for huggingface_hub 1.x. Stubbing httpx.Client.send bypassed the request hook where hub 1.x enforces offline mode, so all 8 cases failed on hub 1.32. The test now intercepts at httpx.HTTPTransport, covers the push path, asserts the exact probe count, and no longer leaks worker globals. The export-type parametrization was dropped because the window wraps every type the same way.
  • The _offline_window_if_unreachable docstring now mentions exports.

Known limitation (left for a separate change): inside a local export's offline window, the first compressed-tensors (FP8/NVFP4) export can't provision llm-compressor-main when the Hub is unreachable but PyPI is reachable. _env_offline() can't tell a user-set HF offline from the worker's forced window.

@Lyxot

Lyxot commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Staging check for head b28818c448 (Lyxot#95, same head):

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Local exports get a per-export offline window (fixes the #6817 export crash), Hub pushes stay out of it, and the regression test now runs against huggingface_hub 1.x. Codex and staging CI are clean on b28818c.

@Lyxot
Lyxot merged commit 8bb4322 into unslothai:main Sep 25, 2026
34 of 35 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…i#11466)

Each local export command now runs in the export worker's offline window: it re-probes Hub reachability per export and, when unreachable, forces HF offline for that export and restores the previous state afterwards. This fixes the no-network export crash in transformers' _patch_mistral_regex -> model_info() (unslothai#6817). Hub-push exports skip the window, since a push needs the Hub. Regression tests cover a local disconnect and recovery and a push that is not pinned offline.
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