Skip to content

feat(studio): ModelScope as a model source and a custom Hugging Face endpoint - #11761

Merged
danielhanchen merged 46 commits into
unslothai:mainfrom
Lyxot:feat/studio-hub-source
Sep 26, 2026
Merged

danielhanchen merged 46 commits into
unslothai:mainfrom
Lyxot:feat/studio-hub-source

Conversation

@Lyxot

@Lyxot Lyxot commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Unsloth Studio can now pull models and datasets from ModelScope when Hugging Face is blocked or slow, and the owner can set a custom Hugging Face endpoint (for example a mirror) in Settings. Before this, the only option on a network that blocks huggingface.co was starting the server with HF_ENDPOINT set, and even then the browser-side catalog, the dataset split picker and several loaders did not follow it.

What changed

  • Model hub settings. A new "Model hub" section in General settings lets the owner choose the model source (Hugging Face or ModelScope), save a custom Hugging Face endpoint, and choose whether the datasets server follows it. The choice is persisted and applied live: the backend rewrites HF_ENDPOINT / HF_DATASETS_SERVER and refreshes the values huggingface_hub and datasets capture at import. Workers started afterwards inherit the change. An operator-set HF_ENDPOINT stays in effect until the owner saves.
  • ModelScope as a source. The backend serves a read-only Hugging Face Hub API emulation backed by ModelScope's public API. HF_ENDPOINT points at a loopback listener, and the browser uses an authenticated mount on the backend origin. Catalog search, model and dataset info, trees, paths-info and resolve keep their single Hugging Face code path, so downloads, the cache layout (models--org--name), inventory, chat and training loaders, subprocess workers and datasets work unchanged. Branch heads come from git's ref advertisement. Writes are refused with an explanation, and managed-account downloads are refused under ModelScope, so a same-named private Hugging Face snapshot cannot be unlocked by a ModelScope answer.
  • One-click switch. Wherever Unsloth Studio reports that Hugging Face is unreachable (the hub page, the model picker, including its Recommended lists), the owner gets a "Use ModelScope" button. The Hugging Face endpoint rows are hidden while ModelScope serves.
  • Custom endpoints in the browser. The browser reaches a settings-saved endpoint through backend proxy mounts, so neither the page's CSP nor the desktop app's needs to know the mirror. The Hugging Face token stays on the server side of that proxy.
  • Dataset split options without a datasets server. When no datasets server answers (a mirror or ModelScope), split options come from the repo's files, resolved the same way training resolves them.
  • Presets whose ModelScope copies live under another organisation. A verified table maps 9 model and 9 dataset ids (for example the default dictation model, MiniMax, MOSS-TTS, a FLUX ControlNet, openai/gsm8k, tatsu-lab/alpaca) to their ModelScope organisation copies. Each copy's files match by LFS sha256 (or by size for non-LFS files), and the result is served under the Hugging Face id, so the cache folder and every caller are unchanged. One hash-pinned Hugging Face commit that ModelScope's history lacks (the DAC speech codec OuteTTS loads) maps to a ModelScope commit whose loaded files match. It is answered and cached under the requested pin, so offline reuse works.
  • Clear failures for presets ModelScope does not host. For example: whisper.cpp dictation, Orpheus's SNAC codec, some Unsloth datasets. The adapter's 404 now says "<repo> is not on ModelScope. Switch the model source to Hugging Face in Settings to use it." Every place that reports a Hub failure surfaces that sentence instead of its generic text: model loads, dictation downloads, TTS codecs, dataset options and format checks, GGUF variants, download jobs, and image and video loads. Previously users saw messages such as "Download failed for 'tiny'.", "Model 'orpheus-3b-0.1-ft' not found" (naming the wrong repo), or "private or gated".

Risks and tradeoffs

  • The ModelScope adapter is an emulation of the subset of Hub routes Unsloth Studio uses, not the full Hub API. Anything outside that subset answers 404 or 403.
  • Same-named repos on the two hubs share one cache folder, as they would with any mirror. The alias table only covers organisation-owned copies verified file by file. Other ids are used as-is, and a repo missing on ModelScope fails with the message above rather than being hidden. A static hide-list would go stale: unsloth/Qwen-Image-2.1 was missing when the table was researched and is now hosted.
  • Switching the source affects workers started afterwards. Running workers keep the endpoint they started with, and the loopback listener stays up for the process lifetime so they keep working.

Validation

  • Backend: the branch's test files plus the related loader, STT, diffusion, dataset and download suites all pass. Every new test was mutation-checked by reverting the production change it covers.
  • Frontend: tsc -b, tsc -p tsconfig.test.json, i18n:check:strict (all 12 locales), and the touched node test files pass.
  • Live against modelscope.cn with a temporary HF_HOME:
    • Search, info and small-file downloads through the adapter land in the standard cache layout under Hugging Face ids, including the aliased presets.
    • load_dataset("openai/gsm8k", "main", split="test") loads 1319 rows.
    • The DAC pin downloads into snapshots/<pin> and reloads with local_files_only.
    • Missing presets (whisper tiny, unsloth/LaTeX_OCR options, unsloth/Radiology_mini check-format, the SNAC codec, unsloth/Z-Image) each report the missing repo by name.
  • UI: a live Unsloth Studio run, comparing merge-base and head with Hugging Face blocked in the browser. Screenshots are below.
cd studio/backend && python -m pytest tests/test_modelscope_hub.py tests/test_hub_settings.py tests/test_hub_endpoint_proxy.py -q
cd studio/frontend && npm run typecheck && npm run i18n:check:strict

Screenshots

  1. 01_settings_hub.png: Settings, Model hub: the source selector, the endpoint and the datasets-server toggle.
图片
  1. 02_settings_modelscope.png: Settings with ModelScope selected: the endpoint rows are hidden.
图片
  1. 03_hub_blocked.png: Hub page with Hugging Face blocked: the Use ModelScope switch.
图片
  1. 04_hub_endpoint_unreachable.png: A saved custom endpoint that cannot be reached: the switch is offered, and after it the catalog loads from ModelScope at once.
图片
  1. 05_picker_blocked.png: Model picker with Hugging Face blocked: the Recommended lists name the unreachable hub and offer the switch.
图片
  1. 06_dataset_splits.png: Dataset split options with the datasets server blocked: the split options fall back to the repo's files.
图片
  1. 07_dataset_missing_modelscope.png: A dataset ModelScope does not host: the split picker names it and says how to switch back.
图片
  1. 08_picker_modelscope.png: Dataset picker on ModelScope.
图片
  1. 09_hub_modelscope.png: Hub page on ModelScope.
图片

Before / after (Settings > General)

Left: merge base, no Model hub section and /api/settings/hub returns 404. Right: this PR, the new Model hub section (model source, custom Hugging Face endpoint, dataset preview toggle) and /api/settings/hub returns 200.

Settings General before and after

The installation owner can now set HF_ENDPOINT in Settings > General, and choose whether HF_DATASETS_SERVER follows it. The saved value is applied at startup before huggingface_hub is imported, and on save it refreshes the endpoint copies huggingface_hub and datasets captured at import, so downloads and new workers use it without a restart. Until the owner saves, the operator's environment stays in effect.

Hub answers that decide access, trust or token validity are now remembered per endpoint, and each probe asks the endpoint its answer is filed under: public-repo verdicts and their persisted proofs, per-token repo access, token validation, trusted-org remote-code trust, and the auto-download "not servable" memo. Public-repo proofs recorded by earlier versions are attributed to the environment's endpoint at startup.
The owner can switch the model source to ModelScope with `PUT /api/settings/hub/source`; the choice is saved and applied at startup and on save, like the custom Hugging Face endpoint.

With ModelScope selected, `HF_ENDPOINT` points at a small read-only Hugging Face Hub API served over ModelScope's public API, so huggingface_hub, datasets, download workers and the Hugging Face cache layout keep their single code path. The adapter answers the routes those clients use: model and dataset search, info (commit sha from ModelScope's git ref advertisement), tree, paths-info, resolve, auth-check and a reachability root; writes are refused. Resolve redirects to a commit-pinned ModelScope URL, HEAD included, so downloaded bytes always match the reported commit. ModelScope's own `dataset_infos.json`, which `datasets` cannot parse, is hidden from dataset repos.

The adapter is served twice: on a loopback-only listener with its own thread and event loop, used as `HF_ENDPOINT` by the backend and its workers, and at `/api/hub/modelscope` for the browser. There the catalog needs a signed-in session, small files are relayed to signed-in callers (the browser cannot follow a cross-origin redirect), and anonymous resolves (README images) redirect without any upstream lookup. `/api/health` reports `hub_source`, while the reported endpoints and the page CSP stay on huggingface.co.

A ModelScope `org/name` says nothing about the same-named Hugging Face repo, so while ModelScope is the source no repo counts as public for managed accounts, managed-account downloads are refused, and Hugging Face organisation trust never auto-enables `trust_remote_code`. The applied source is carried in `UNSLOTH_STUDIO_HUB_SOURCE`, so spawned workers apply the same gates. If the adapter cannot start, the backend stays on Hugging Face.
Adds a "Model source" choice (Hugging Face or ModelScope) to the Model hub section in General settings. The owner can switch there, or with a "Use ModelScope" button that the model hub shows the owner when Hugging Face cannot be reached. The choice is saved on the backend, so it persists across restarts and applies to every browser.

With ModelScope selected, `/api/health` reports `hub_source`, and the browser's Hub client is pointed at the backend's `/api/hub/modelscope` mount. It is same-origin, so no CSP change or reload is needed. Requests to that mount carry the Unsloth session instead of the Hugging Face token, chosen by the request's destination so a request queued before a switch still authenticates correctly. A 401 from the mount refreshes the session once and retries. The mount now answers a browser resolve carrying a rejected session with a 401 instead of redirecting, because the page cannot read a cross-origin redirect and so could never refresh.

Switching back to Hugging Face with a custom endpoint saved asks for a reload, since a page served under ModelScope does not allow that endpoint's origins. The catalog's error states, toasts, picker tab and "Open on" links name the active hub. New strings are translated in all locales; the German hub copy now uses the formal address like the rest of that locale.
A custom endpoint or datasets server saved in Settings reached the browser only after a reload, and never in the desktop app, whose webview CSP is built at launch from the environment. The backend now relays browsing to the configured endpoint at /api/hub/proxy/<tag> and /api/hub/datasets-server-proxy/<tag>, where the tag names the endpoint so caches keyed on the Hub URL follow a change. /api/health reports the relay paths, the frontend's Hub fetch sends the Unsloth session with the Hugging Face token beside it in X-HF-Authorization, and CORS exposes the Hub headers to the desktop app. The reload and desktop notices in Settings are removed.
When the datasets-server has no answer for a dataset (a custom mirror, ModelScope, or an unprocessed repo), the subset/split selector now asks a new backend route, POST /api/hub/datasets/hub-options, which resolves the builder configs from the repo files through HF_ENDPOINT, as training does, without reading rows. Under ModelScope the datasets-server is skipped for split options, size stats and example thumbnails, since it only knows Hugging Face repo ids.
…e serves

The endpoint and datasets-server rows apply only to Hugging Face, so Settings hides them while ModelScope is the active source, and Settings search no longer offers them there. A ModelScope that failed to start falls back to Hugging Face and keeps the rows. A failed source switch now reports under the source row. The unused endpointInactive string is removed from every locale.
…ed lists

An empty Recommended list in the model picker used to read "No models found." even when the search failed or the hub was backing off. Both the browse and search views now show the hub failure hint with a retry that clears the backoff, and offer ModelScope when Hugging Face is unreachable.

The ModelScope offer in the model hub is now limited to network failures too: a reachable hub answering an HTTP error such as 401 shows its message instead of a connectivity diagnosis.
… Hugging Face ids

Several presets are hosted on ModelScope by another organisation, so the ModelScope source answered 404 for them, including the default speech-to-text model (unslothai/Qwen3-ASR-0.6B-GGUF is ggml-org/Qwen3-ASR-0.6B-GGUF there), MiniMax video and music, MOSS TTS and its codecs, a FLUX ControlNet, and nine curated datasets such as openai/gsm8k.

The ModelScope adapter now maps those Hugging Face ids to the ModelScope copy on every upstream request (git refs, file lists, detail, resolve and repo pages) and answers under the Hugging Face id, so presets, companion downloads and datasets work unchanged and the cache keeps Hugging Face-named folders. The table lists only organisation-owned copies whose files all match by LFS sha256 (by size where Hugging Face masks a gated repo's hashes). Lookup ignores case, as Hugging Face ids do. Search results are not aliased.
ModelScope keeps its own git history, so a commit pinned on Hugging Face does not exist there. Under the ModelScope source, OuteTTS failed to fetch its DAC codec (ibm-research/DAC.speech.v1.0 pinned at 1ea7f64c).

The adapter now maps a listed pinned commit to the ModelScope commit whose loaded files match (for DAC, 3268c083, where both weight files have the same sha256 and size). It answers a full-sha request under the requested commit, so huggingface_hub caches the pin as that snapshot and reuses it offline, while the bytes come from the mapped commit. Anonymous browser redirects map the pin too. Unlisted pins are not remapped: a pin guards remote code and reproducibility, so there is no fallback to the default branch.
With ModelScope as the model source, presets that ModelScope does not host (whisper.cpp dictation, Orpheus's SNAC codec, several Unsloth datasets) failed with misleading text such as "Download failed for 'tiny'.", "Model 'orpheus-3b-0.1-ft' not found" or "private or gated". The adapter's missing-repo answer now reads "<repo> is not on ModelScope. Switch the model source to Hugging Face in Settings to use it.", and every place that reports a Hub failure (model loads, dictation downloads, TTS codecs, dataset options and format checks, GGUF variants, downloads, image and video loads) surfaces that sentence instead of its generic message. A GGUF TTS codec failure keeps the sentence per load request, so a concurrent load or the tensor-parallel retry cannot drop it.
@Lyxot

Lyxot commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

…elScope serves

With ModelScope as the model source, HF_ENDPOINT points at the ModelScope adapter, which has no whoami route, so every Hugging Face token in settings was reported as unavailable and each check spent one of the hourly validation attempts. Token validation now asks the Hugging Face endpoint the settings select.
… Hub relay

The custom-endpoint relay decoded each path segment before rejecting dot segments, so a request such as a%2F..%2Fb passed as one segment while an endpoint that decodes separators could still resolve it outside its path prefix. Decoded segments are now split again before the check; encoded revisions such as refs%2Fpr%2F1 still pass.
…dpoint

With a custom Hugging Face endpoint the browser reaches it through the backend relay, which answers its own 502 when the endpoint is unreachable. The page read that as a reachable hub returning an HTTP error, so the Use ModelScope switch never appeared for an unreachable mirror. The relay's own 502, which lacks the upstream marker header, now fails like a direct network error.
@Lyxot

Lyxot commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator Author

Staging review and CI at 5236a86040 (the current head):

Changes made while converging:

  • Hugging Face tokens are validated against Hugging Face while ModelScope serves.
  • The Hub relay refuses dot segments hidden behind encoded slashes.
  • The relay's own 502 counts as an unreachable endpoint, so "Use ModelScope" is offered, and switching the source or endpoint clears the stale backoff.
  • Anonymous relay redirects and GET /api/settings/hub no longer reveal a private endpoint to clients that cannot reach it (the settings read is owner only).
  • The startup settings read leaves studio.db untouched.
  • CI fixes: the session-refresh registration moved to main.tsx, the desktop branding wording, the OpenAPI schema, and one test made robust to a second httpx copy in the test process.

The declined review comments and their reasons are in the staging threads.

…passes the proxy

getproxies() on macOS / Windows falls back to the system proxy only while no
*_proxy variable is set, so writing no_proxy switched the system proxy off for
the whole process: read environment proxies instead. Drop huggingface_hub's
shared client rather than closing it (closing aborted downloads streaming on
it), and skip that step on 0.x, which has no shared client and re-reads the
environment per request.
ModelScope publishes no malware scan, so the Hub-scan gate always saw
"unavailable" and let a pickle-only repo load. Under ModelScope, list the repo
and block pickle weights whose directory ships no safetensors alternative, as
the offline gate already does for a cached snapshot.
The policy is sent to every client, including unauthenticated ones, while the
saved endpoint can name a private address the owner-only settings route hides.
The browser reaches a saved endpoint through the backend relay, so only the
operator's environment endpoints (already public before this change) and the
defaults are listed.
…endpoint

The route is unauthenticated, and a saved DNS-named endpoint passed the
reachability rule, so its hostname reached any client. The browser uses the
relay for it, so the defaults are reported instead; operator endpoints are
unchanged.
/api/health publishes the tag unauthenticated, and 48 bits of a bare sha256 of a
private host:port can be brute-forced back to the address. The tag only has to
change with the endpoint, so an HMAC with a per-process key does.
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 26, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 26, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 26, 2026
@danielhanchen
danielhanchen merged commit 0657c17 into unslothai:main Sep 26, 2026
56 of 65 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…endpoint (unslothai#11761)

* feat(studio): save a custom Hugging Face endpoint in settings

The installation owner can now set HF_ENDPOINT in Settings > General, and choose whether HF_DATASETS_SERVER follows it. The saved value is applied at startup before huggingface_hub is imported, and on save it refreshes the endpoint copies huggingface_hub and datasets captured at import, so downloads and new workers use it without a restart. Until the owner saves, the operator's environment stays in effect.

Hub answers that decide access, trust or token validity are now remembered per endpoint, and each probe asks the endpoint its answer is filed under: public-repo verdicts and their persisted proofs, per-token repo access, token validation, trusted-org remote-code trust, and the auto-download "not servable" memo. Public-repo proofs recorded by earlier versions are attributed to the environment's endpoint at startup.

* feat(studio): add ModelScope as a model source

The owner can switch the model source to ModelScope with `PUT /api/settings/hub/source`; the choice is saved and applied at startup and on save, like the custom Hugging Face endpoint.

With ModelScope selected, `HF_ENDPOINT` points at a small read-only Hugging Face Hub API served over ModelScope's public API, so huggingface_hub, datasets, download workers and the Hugging Face cache layout keep their single code path. The adapter answers the routes those clients use: model and dataset search, info (commit sha from ModelScope's git ref advertisement), tree, paths-info, resolve, auth-check and a reachability root; writes are refused. Resolve redirects to a commit-pinned ModelScope URL, HEAD included, so downloaded bytes always match the reported commit. ModelScope's own `dataset_infos.json`, which `datasets` cannot parse, is hidden from dataset repos.

The adapter is served twice: on a loopback-only listener with its own thread and event loop, used as `HF_ENDPOINT` by the backend and its workers, and at `/api/hub/modelscope` for the browser. There the catalog needs a signed-in session, small files are relayed to signed-in callers (the browser cannot follow a cross-origin redirect), and anonymous resolves (README images) redirect without any upstream lookup. `/api/health` reports `hub_source`, while the reported endpoints and the page CSP stay on huggingface.co.

A ModelScope `org/name` says nothing about the same-named Hugging Face repo, so while ModelScope is the source no repo counts as public for managed accounts, managed-account downloads are refused, and Hugging Face organisation trust never auto-enables `trust_remote_code`. The applied source is carried in `UNSLOTH_STUDIO_HUB_SOURCE`, so spawned workers apply the same gates. If the adapter cannot start, the backend stays on Hugging Face.

* feat(studio): switch the model hub to ModelScope from the UI

Adds a "Model source" choice (Hugging Face or ModelScope) to the Model hub section in General settings. The owner can switch there, or with a "Use ModelScope" button that the model hub shows the owner when Hugging Face cannot be reached. The choice is saved on the backend, so it persists across restarts and applies to every browser.

With ModelScope selected, `/api/health` reports `hub_source`, and the browser's Hub client is pointed at the backend's `/api/hub/modelscope` mount. It is same-origin, so no CSP change or reload is needed. Requests to that mount carry the Unsloth session instead of the Hugging Face token, chosen by the request's destination so a request queued before a switch still authenticates correctly. A 401 from the mount refreshes the session once and retries. The mount now answers a browser resolve carrying a rejected session with a 401 instead of redirecting, because the page cannot read a cross-origin redirect and so could never refresh.

Switching back to Hugging Face with a custom endpoint saved asks for a reload, since a page served under ModelScope does not allow that endpoint's origins. The catalog's error states, toasts, picker tab and "Open on" links name the active hub. New strings are translated in all locales; the German hub copy now uses the formal address like the rest of that locale.

* feat(studio): browse a custom Hugging Face endpoint through the backend

A custom endpoint or datasets server saved in Settings reached the browser only after a reload, and never in the desktop app, whose webview CSP is built at launch from the environment. The backend now relays browsing to the configured endpoint at /api/hub/proxy/<tag> and /api/hub/datasets-server-proxy/<tag>, where the tag names the endpoint so caches keyed on the Hub URL follow a change. /api/health reports the relay paths, the frontend's Hub fetch sends the Unsloth session with the Hugging Face token beside it in X-HF-Authorization, and CORS exposes the Hub headers to the desktop app. The reload and desktop notices in Settings are removed.

* feat(studio): fall back to the repo files for dataset split options

When the datasets-server has no answer for a dataset (a custom mirror, ModelScope, or an unprocessed repo), the subset/split selector now asks a new backend route, POST /api/hub/datasets/hub-options, which resolves the builder configs from the repo files through HF_ENDPOINT, as training does, without reading rows. Under ModelScope the datasets-server is skipped for split options, size stats and example thumbnails, since it only knows Hugging Face repo ids.

* feat(studio): hide the Hugging Face endpoint settings while ModelScope serves

The endpoint and datasets-server rows apply only to Hugging Face, so Settings hides them while ModelScope is the active source, and Settings search no longer offers them there. A ModelScope that failed to start falls back to Hugging Face and keeps the rows. A failed source switch now reports under the source row. The unused endpointInactive string is removed from every locale.

* feat(studio): name an unreachable hub in the model picker's Recommended lists

An empty Recommended list in the model picker used to read "No models found." even when the search failed or the hub was backing off. Both the browse and search views now show the hub failure hint with a retry that clears the backoff, and offer ModelScope when Hugging Face is unreachable.

The ModelScope offer in the model hub is now limited to network failures too: a reachable hub answering an HTTP error such as 401 shows its message instead of a connectivity diagnosis.

* feat(studio): serve verified ModelScope copies of presets under their Hugging Face ids

Several presets are hosted on ModelScope by another organisation, so the ModelScope source answered 404 for them, including the default speech-to-text model (unslothai/Qwen3-ASR-0.6B-GGUF is ggml-org/Qwen3-ASR-0.6B-GGUF there), MiniMax video and music, MOSS TTS and its codecs, a FLUX ControlNet, and nine curated datasets such as openai/gsm8k.

The ModelScope adapter now maps those Hugging Face ids to the ModelScope copy on every upstream request (git refs, file lists, detail, resolve and repo pages) and answers under the Hugging Face id, so presets, companion downloads and datasets work unchanged and the cache keeps Hugging Face-named folders. The table lists only organisation-owned copies whose files all match by LFS sha256 (by size where Hugging Face masks a gated repo's hashes). Lookup ignores case, as Hugging Face ids do. Search results are not aliased.

* feat(studio): serve verified pinned Hugging Face commits from ModelScope

ModelScope keeps its own git history, so a commit pinned on Hugging Face does not exist there. Under the ModelScope source, OuteTTS failed to fetch its DAC codec (ibm-research/DAC.speech.v1.0 pinned at 1ea7f64c).

The adapter now maps a listed pinned commit to the ModelScope commit whose loaded files match (for DAC, 3268c083, where both weight files have the same sha256 and size). It answers a full-sha request under the requested commit, so huggingface_hub caches the pin as that snapshot and reuses it offline, while the bytes come from the mapped commit. Anonymous browser redirects map the pin too. Unlisted pins are not remapped: a pin guards remote code and reproducibility, so there is no fallback to the default branch.

* feat(studio): say when a repo is not on ModelScope

With ModelScope as the model source, presets that ModelScope does not host (whisper.cpp dictation, Orpheus's SNAC codec, several Unsloth datasets) failed with misleading text such as "Download failed for 'tiny'.", "Model 'orpheus-3b-0.1-ft' not found" or "private or gated". The adapter's missing-repo answer now reads "<repo> is not on ModelScope. Switch the model source to Hugging Face in Settings to use it.", and every place that reports a Hub failure (model loads, dictation downloads, TTS codecs, dataset options and format checks, GGUF variants, downloads, image and video loads) surfaces that sentence instead of its generic message. A GGUF TTS codec failure keeps the sentence per load request, so a concurrent load or the tensor-parallel retry cannot drop it.

* fix(studio): check Hugging Face tokens against Hugging Face while ModelScope serves

With ModelScope as the model source, HF_ENDPOINT points at the ModelScope adapter, which has no whoami route, so every Hugging Face token in settings was reported as unavailable and each check spent one of the hourly validation attempts. Token validation now asks the Hugging Face endpoint the settings select.

* fix(studio): refuse dot segments hidden behind encoded slashes in the Hub relay

The custom-endpoint relay decoded each path segment before rejecting dot segments, so a request such as a%2F..%2Fb passed as one segment while an endpoint that decodes separators could still resolve it outside its path prefix. Decoded segments are now split again before the check; encoded revisions such as refs%2Fpr%2F1 still pass.

* fix(studio): offer ModelScope when the relay cannot reach a custom endpoint

With a custom Hugging Face endpoint the browser reaches it through the backend relay, which answers its own 502 when the endpoint is unreachable. The page read that as a reachable hub returning an HTTP error, so the Use ModelScope switch never appeared for an unreachable mirror. The relay's own 502, which lacks the upstream marker header, now fails like a direct network error.

* fix(studio): register the Hub session refresh at startup and keep desktop branding in the source notice

* fix(studio): leave studio.db untouched when reading hub settings at import

* fix(studio): keep the ModelScope browser mount out of the OpenAPI schema

* fix(studio): lift Hub backoffs when the model source or endpoint changes

* fix(studio): keep unreachable Hub endpoints out of anonymous relay redirects

* fix(studio): scale the Model hub error widths with the UI font size

* test(studio): build the missing-repo response on huggingface_hub's own httpx

* fix(studio): let only the owner read the saved Hub endpoint

* Trim comments in the Hub source changes

* Probe Hugging Face, not ModelScope, before serving a cached Hub repo

With ModelScope as the source, HF_ENDPOINT points at the loopback adapter, whose
auth-check answers 200 for any repo ModelScope hosts. A public ModelScope repo
named like a private cached Hugging Face repo then let an API-key caller read it.

* Keep the private or gated guidance when the repo-file split fallback is refused

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Require a UI session to change the Hub endpoint or model source

The endpoint receives the installation's Hugging Face token, so an sk-unsloth API
key must not be able to repoint it, matching the Hugging Face token routes.

* Keep the ModelScope loopback adapter off a configured HTTP proxy

httpx sends 127.0.0.1 through HTTP_PROXY / ALL_PROXY unless NO_PROXY lists it, so
selecting ModelScope behind a proxy broke every backend Hub call.

* Keep system proxies and in-flight downloads intact when ModelScope bypasses the proxy

getproxies() on macOS / Windows falls back to the system proxy only while no
*_proxy variable is set, so writing no_proxy switched the system proxy off for
the whole process: read environment proxies instead. Drop huggingface_hub's
shared client rather than closing it (closing aborted downloads streaming on
it), and skip that step on 0.x, which has no shared client and re-reads the
environment per request.

* Name a repo missing on ModelScope in the OpenAI auto-download refusal

* Name a repo missing on ModelScope in training's gate check

* Fail closed on pickle weights while ModelScope serves

ModelScope publishes no malware scan, so the Hub-scan gate always saw
"unavailable" and let a pickle-only repo load. Under ModelScope, list the repo
and block pickle weights whose directory ships no safetensors alternative, as
the offline gate already does for a cached snapshot.

* Keep a settings-saved Hub endpoint out of the global CSP

The policy is sent to every client, including unauthenticated ones, while the
saved endpoint can name a private address the owner-only settings route hides.
The browser reaches a saved endpoint through the backend relay, so only the
operator's environment endpoints (already public before this change) and the
defaults are listed.

* Report the default Hub endpoints in /api/health for a settings-saved endpoint

The route is unauthenticated, and a saved DNS-named endpoint passed the
reachability rule, so its hostname reached any client. The browser uses the
relay for it, so the defaults are reported instead; operator endpoints are
unchanged.

* Key the Hub relay tag per process

/api/health publishes the tag unauthenticated, and 48 bits of a bare sha256 of a
private host:port can be brute-forced back to the address. The tag only has to
change with the endpoint, so an HMAC with a per-process key does.

* Refuse anonymous relay redirects to a settings-saved endpoint from non-loopback clients

* Format relay redirect change

* Relay signed-out README assets for a saved endpoint instead of refusing them off the host

* Relay only raster repository images to signed-out clients, sandboxed and nosniff

* Fail a ModelScope dataset listing that reaches the page cap instead of truncating it

* Scope the ModelScope pickle check to the folders a load reads

* Drop the Newest sort on ModelScope, which has no creation-date order

* Tighten two hub comments

* Skip the trainer ModelScope gate test where torch or transformers is absent

---------

Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: danielhanchen <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

2 participants