unsloth/studio/backend/core/inference
Roland Tannous f91ef8f9b0
fix(studio): lazy-import transformers in model_config to fix 5.x version switch (#4806)
* fix(studio): lazy-import AutoConfig in model_config.py to fix transformers 5.x version switch

Move `from transformers import AutoConfig` from module level to inside
load_model_config() where it is actually used.

model_config.py is transitively imported at module load time via:
  core/inference/__init__ → llama_cpp → utils.models → model_config

In inference subprocesses (mp.spawn), this chain runs before
_activate_transformers_version() can prepend .venv_t5/ to sys.path.
The eager import caches transformers 4.57.6 in sys.modules, and the
subsequent sys.path change has no effect — Python always checks
sys.modules before sys.path.

Making the import lazy ensures transformers is not loaded until after
version activation, so the subprocess picks up the correct version.

* fix(studio): also lazy-import extract_model_size_b in llama_cpp.py

Belt-and-suspenders: make the import that originally triggered the
chain lazy as well, so future module-level AutoConfig additions in
utils.models cannot reintroduce the problem.

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

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

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-03 02:56:01 +04:00
..
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
_html_to_md.py fix: studio web search SSL failures and empty page content (#4754) 2026-04-01 06:12:02 -07:00
audio_codecs.py studio: per-model inference defaults, GGUF slider fix, reasoning toggle (#4325) 2026-03-16 06:37:55 -07:00
defaults.py UI Changes (#4782) 2026-04-02 08:05:55 -07:00
inference.py [studio] multi gpu: revert to balanced for inference. (#4698) 2026-03-31 01:24:41 -07:00
llama_cpp.py fix(studio): lazy-import transformers in model_config to fix 5.x version switch (#4806) 2026-04-03 02:56:01 +04:00
orchestrator.py fix(studio): prioritize curated defaults over HF download ranking in Recommended (#4792) 2026-04-02 10:46:53 -07:00
tools.py feat(studio): display images from Python tool execution in chat UI (#4778) 2026-04-02 05:08:16 -07:00
worker.py fix: auto-retry stalled HF downloads with HF_HUB_DISABLE_XET=1 (#4712) 2026-03-31 03:00:46 -07:00