Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: skip torchcodec for torch below the compatibility table (#10506)
Rudra Bhaskar3779ac4f334a
diff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex cdab5c555cb..3a55cab1f16 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -381,6 +381,7 @@ _TORCHCODEC_TORCH_SPECS: dict[int, str] = {6: "torchcodec>=0.2.0,<0.3.0",5: "torchcodec>=0.1.0,<0.2.0",}+_TORCHCODEC_MIN_KNOWN_MINOR = min(_TORCHCODEC_TORCH_SPECS)_TORCHCODEC_MAX_KNOWN_MINOR = max(_TORCHCODEC_TORCH_SPECS)# Not every platform was published from 0.1. Read off the live PyPI index:@@ -709,10 +710,10 @@ def _torchcodec_spec_is_installable(spec: str) -> bool:return True-def _select_torchcodec_spec(torch_version: "str | None") -> str:+def _select_torchcodec_spec(torch_version: "str | None") -> "str | None":"""Map an installed torch version (e.g. '2.11.0+cu128') to the torchcodec spec built- against it. Falls back to _TORCHCODEC_DEFAULT_SPEC for torch <=2.4, a non-2.x major, or- an unparseable/missing version. Pure function."""+ against it, or None below the oldest known torch minor. Falls back to+ _TORCHCODEC_DEFAULT_SPEC for a non-2.x major or an unparseable/missing version."""if not torch_version:return _TORCHCODEC_DEFAULT_SPECrelease = str(torch_version).split("+", 1)[0] # drop +cu128/+rocm7.2/+cpu@@ -725,6 +726,8 @@ def _select_torchcodec_spec(torch_version: "str | None") -> str:return _TORCHCODEC_DEFAULT_SPECif major != 2:return _TORCHCODEC_DEFAULT_SPEC+ if minor < _TORCHCODEC_MIN_KNOWN_MINOR:+ return None# Clamp to the ABI-stable floor, never the 0.11 row: 0.11 is locked to torch 2.11 exactly.minor = min(minor, _TORCHCODEC_MAX_KNOWN_MINOR)return _TORCHCODEC_TORCH_SPECS.get(minor, _TORCHCODEC_DEFAULT_SPEC)@@ -8032,6 +8035,12 @@ def install_python_stack() -> int:elif not _codec_torch_ver:_progress("torchcodec (skipped, torch version unknown)")_note("could not read the installed torch version -- leaving torchcodec alone")+ elif _select_torchcodec_spec(_codec_torch_ver) is None:+ _progress("torchcodec (skipped, unsupported torch version)")+ _note(+ f"torch {_codec_torch_ver} is below the oldest supported torchcodec pairing "+ f"(torch 2.{_TORCHCODEC_MIN_KNOWN_MINOR}) -- leaving torchcodec alone"+ )elif not _torchcodec_spec_is_installable(_select_torchcodec_spec(_codec_torch_ver)):# This platform published no wheel in the window this torch selects. Skipping is what# such a host got before this step existed; attempting it would end the install.diff --git a/tests/python/test_torchcodec_torch_compat.py b/tests/python/test_torchcodec_torch_compat.pyindex d51d81d7ab0..69418e9ae7b 100644--- a/tests/python/test_torchcodec_torch_compat.py+++ b/tests/python/test_torchcodec_torch_compat.py@@ -274,6 +274,41 @@ def test_select_torchcodec_spec_falls_back_on_unknown_torch():assert ips._select_torchcodec_spec(value) == ips._TORCHCODEC_DEFAULT_SPEC+def test_select_torchcodec_spec_skips_older_torch():+ ips = _load_install_python_stack()+ for minor in range(min(ips._TORCHCODEC_TORCH_SPECS)):+ for suffix in (".0", ".1+cu121", ".0+cpu", ".0rc1"):+ assert ips._select_torchcodec_spec(f"2.{minor}{suffix}") is None++[email protected]("version", ["2.3.0", "2.4.0+cu121"])+def test_torchcodec_step_skips_older_torch(version):+ from textwrap import dedent+ from unittest.mock import Mock++ ips = _load_install_python_stack()+ namespace = vars(ips).copy()+ namespace.update(+ NO_TORCH = False,+ PLATFORM_LACKS_TORCHCODEC_WHEEL = False,+ _probe_installed_torch_version = lambda: version,+ _progress = Mock(),+ _note = Mock(),+ _torchcodec_spec_is_installable = Mock(side_effect = AssertionError("must skip")),+ pip_install_try = Mock(side_effect = AssertionError("must not install")),+ )+ source = Path(ips.__file__).read_text(encoding = "utf-8")+ step = source.split("# 13b. torchcodec", 1)[1].split("# 14.", 1)[0]+ exec(dedent(step[step.index(" _codec_torch_ver = None") :]), namespace)+ namespace["_progress"].assert_called_once_with(+ "torchcodec (skipped, unsupported torch version)"+ )+ namespace["_note"].assert_called_once_with(+ f"torch {version} is below the oldest supported torchcodec pairing "+ f"(torch 2.{ips._TORCHCODEC_MIN_KNOWN_MINOR}) -- leaving torchcodec alone"+ )++def test_select_torchcodec_spec_matches_pyproject_audio_extras():"""The installer's specs and the pip extras must not drift apart."""ips = _load_install_python_stack()@@ -297,7 +332,7 @@ def test_select_torchcodec_spec_matches_pyproject_audio_extras():# `2.6: {0.2, 0.3}` and `2.5: {0.1, 0.2}` survived: upstream pairs 0.3 with torch 2.7 and 0.2# with torch 2.6, so the installer's window picked a release built against the NEXT torch.# torch 2.4 -> 0.0.3 is deliberately omitted below: the installer floors at 2.5 and returns-# _TORCHCODEC_DEFAULT_SPEC underneath it.+# None underneath it._UPSTREAM_TORCH_TO_TORCHCODEC_MINORS = {"2.11": {"0.11"},"2.10": {"0.10"},@@ -700,7 +735,7 @@ def test_the_installer_never_installs_what_the_guard_rejects(monkeypatch):ips = _load_install_python_stack()probes = [f"0.{n}.0" for n in range(0, 20)]- for minor in range(5, 15): # torch 2.5 .. 2.14, i.e. past the last lockstep row+ for minor in range(min(ips._TORCHCODEC_TORCH_SPECS), 15):torch_v = f"2.{minor}.0"specifier = SpecifierSet(ips._select_torchcodec_spec(torch_v).split("torchcodec", 1)[1])admitted = [p for p in probes if specifier.contains(p)]@@ -827,7 +862,7 @@ def test_the_installer_never_selects_a_spec_with_no_wheel_here(monkeypatch):ips = _load_install_python_stack()for label in _SIM_HOSTS:for python in ((3, 9), (3, 10), (3, 12), (3, 13), (3, 14)):- for minor in range(4, 15):+ for minor in range(min(ips._TORCHCODEC_TORCH_SPECS), 15):_patch_host(ips, monkeypatch, label)monkeypatch.setattr(ips.sys, "version_info", python + (0, "final", 0))spec = ips._select_torchcodec_spec(f"2.{minor}.0")