Skip to content

Feat/model hub - #5783

Closed
danielhanchen wants to merge 19 commits into
unslothai:mainfrom
Sneakr:feat/model-hub
Closed

danielhanchen wants to merge 19 commits into
unslothai:mainfrom
Sneakr:feat/model-hub

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

No description provided.

Imagineer99 and others added 16 commits April 3, 2026 12:06
Tests for resolve_cached_repo_id_case and get_model_config case resolution
belong in their own PR to keep this change focused on the runtime fix.
- Check exact-case path before memo to ensure a newly-appeared exact
  match always wins over a previously memoized variant
- Validate memoized entries still exist on disk before returning them
  to prevent stale results when cache dirs are deleted/recreated
- Use .is_dir() instead of .exists() for exact-case cache check
  (cache entries are always directories)
- Remove redundant fallback in _detect_audio_from_tokenizer since
  get_cache_path already handles case resolution and returns None
  when the model is not cached
- New download-jobs feature replaces models/download-manager

- New inventory feature for unified model/dataset discovery

- New chat/model-runtime feature: per-model load config, hydration, rollback

- Models catalog split into lists/rows; new hub option menu, on-device folders dialog, per-model config notice

- Training rework: cache-reference, dataset-slices, freeform validation, model-config-fetch, resource-availability, conflict detection, draft + config persistence

- Chat template validation shared between backend and frontend

- New shared lib modules: model-identity, model-identifiers, model-capabilities, local-path, network, token-fingerprint, unsloth-support, debounced-persist-storage

- Remove superseded modules: download-manager-store, use-filter-starved-pause, use-hub-inventory, transport-preference
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces comprehensive offline loading and training capabilities for models and datasets, including local cache resolution, GGUF variant matching, and support for Ollama models. It adds a new load_settings module to manage transformers load settings and updates various inference and training backends to support local-only files. The review feedback highlights two issues: a potential ImportError in worker.py due to _cached_transformers_snapshot_path being imported from the wrong module (model_config instead of hf_cache_scan), and a potential TypeError in llama_cpp.py if gguf_filename is None when attempting a path join.

Comment on lines 10 to 11
from typing import Optional, Dict, Any
from utils.paths import (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The function _cached_transformers_snapshot_path is used in from_identifier and imported by other modules from utils.models.model_config, but it is not imported here. This will cause a NameError at runtime. Please import it from utils.hf_cache_scan.

Suggested change
from typing import Optional, Dict, Any
from utils.paths import (
from typing import Optional, Dict, Any
from utils.hf_cache_scan import _cached_transformers_snapshot_path
from utils.paths import (

Comment on lines +2304 to +2317
try:
from utils.models.model_config import _iter_hf_cache_snapshots

for snap in _iter_hf_cache_snapshots(hf_repo):
main_path = snap / gguf_filename
if not main_path.is_file():
continue
if not all((snap / shard).is_file() for shard in gguf_extra_shards):
continue
local_path = str(main_path.resolve())
logger.info("Resolved GGUF from local HF cache: %s", local_path)
return local_path
except Exception as e:
logger.debug(f"Local HF cache lookup for GGUF file failed: {e}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If hf_variant is None or falsy, gguf_filename remains None. This will cause snap / gguf_filename to raise a TypeError at runtime. Although wrapped in a broad try...except block, it is cleaner and safer to guard against None before attempting the path join.

Suggested change
try:
from utils.models.model_config import _iter_hf_cache_snapshots
for snap in _iter_hf_cache_snapshots(hf_repo):
main_path = snap / gguf_filename
if not main_path.is_file():
continue
if not all((snap / shard).is_file() for shard in gguf_extra_shards):
continue
local_path = str(main_path.resolve())
logger.info("Resolved GGUF from local HF cache: %s", local_path)
return local_path
except Exception as e:
logger.debug(f"Local HF cache lookup for GGUF file failed: {e}")
if gguf_filename:
try:
from utils.models.model_config import _iter_hf_cache_snapshots
for snap in _iter_hf_cache_snapshots(hf_repo):
main_path = snap / gguf_filename
if not main_path.is_file():
continue
if not all((snap / shard).is_file() for shard in gguf_extra_shards):
continue
local_path = str(main_path.resolve())
logger.info("Resolved GGUF from local HF cache: %s", local_path)
return local_path
except Exception as e:
logger.debug(f"Local HF cache lookup for GGUF file failed: {e}")

Sneakr and others added 2 commits May 27, 2026 00:44
Resolved 7 conflict files. Preserved the model-hub branch's
per-model-config, download-manager, and feature/inventory split.
Adopted upstream's chat-history backend + chat-settings-storage
abstraction.

- backend/routes/inference.py: kept runtime_model_identifier helper
- model-selector.tsx: kept reworked picker (PickerTabToggle, onPick)
- chat-adapter.ts: merged storage refactor + getHfToken + features/inventory + pushImagePart attachments
- chat-api.ts: kept re-export shim, grafted in 16 chat-history fns
- chat-page.tsx: kept per-model-config plumbing + adopted external-provider builtin tools (web fetch, image gen, prompt-cache TTL)
- chat-settings-sheet.tsx: dropped duplicate Model section (lives in ModelConfigPage), adopted preset-state-from-store
- chat-runtime-store.ts: adopted async chat-settings-storage hydration, preserved activeModelLoadSource + ChatModelLoadInfo

Follow-up build fixes:
- Tailwind v4 syntax in index.css (! suffix, no spaces in arbitrary values)
- 5 missing setter type signatures on ChatRuntimeStore
- Re-imported Select family for prompt-cache TTL UI
- Removed duplicate barrel exports in features/chat/index.ts
- tests/test_cached_gguf_routes.py: remove obsolete _stub_classify fixture
- tests/test_training_worker_flash_attn.py: pin FLA model-type discovery via shared helper
- core/training/resume.py: make artifacts_present and get_resume_checkpoint_path exception-safe against ValueError from resolve_output_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants