Skip to content

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.

Studio: fix embedding fine-tunes failing at the first step (#17311)

Nilayf39389bb0266
diff --git a/studio/backend/requirements/extras-no-deps.txt b/studio/backend/requirements/extras-no-deps.txt
index bd812204b29..d6eafb22ece 100644
--- a/studio/backend/requirements/extras-no-deps.txt
+++ b/studio/backend/requirements/extras-no-deps.txt
@@ -16,7 +16,7 @@ trl==0.23.1
torch-c-dlpack-ext==0.1.5
# 5.2 requires >=3.10. This file is applied after no-torch-runtime.txt, so an
# unconditional pin here would reject 3.9 outright and undo that file's fallback.
-sentence_transformers==5.2.0; python_version >= "3.10"
+sentence_transformers==5.2.3; python_version >= "3.10"
sentence_transformers==5.1.2; python_version < "3.10"
# Pinned with transformers, not after it: --no-deps skips transformers' own
# tokenizers requirement, so naming only one half of the pair leaves whatever the
diff --git a/studio/backend/requirements/no-torch-runtime.txt b/studio/backend/requirements/no-torch-runtime.txt
index 7e5d773e693..f776cf58329 100644
--- a/studio/backend/requirements/no-torch-runtime.txt
+++ b/studio/backend/requirements/no-torch-runtime.txt
@@ -94,12 +94,9 @@ tokenizers>=0.22.0,<=0.23.0
transformers==5.5.0; python_version >= "3.10"
transformers==4.57.6; python_version < "3.10"
trl>=0.18.2,!=0.19.0,<=1.15.0
-# Matches extras-no-deps.txt rather than the newest release: that file installs
-# --no-deps too and runs after this one, so whatever it names wins. Pinning a
-# higher version here would record a number no install ever ends up with. Bump
-# both together. 5.2 requires >=3.10, so 3.9 keeps the newest release it can take,
-# which is what a bare entry resolved to here before.
-sentence-transformers==5.2.0; python_version >= "3.10"
+# Bump with extras-no-deps.txt: it also installs --no-deps and runs after this file, so its pin wins.
+# 5.2 requires >=3.10; 3.9 keeps 5.1.2, its newest release.
+sentence-transformers==5.2.3; python_version >= "3.10"
sentence-transformers==5.1.2; python_version < "3.10"
cut_cross_entropy==25.1.1
# Apple Silicon stays below 13 with the MLX image engine: mflux imports PIL._typing, which
diff --git a/tests/studio/install/test_sentence_transformers_pin.py b/tests/studio/install/test_sentence_transformers_pin.py
new file mode 100644
index 00000000000..b19cab16322
--- /dev/null
+++ b/tests/studio/install/test_sentence_transformers_pin.py
@@ -0,0 +1,64 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+from __future__ import annotations
+
+import pathlib
+
+from packaging.requirements import InvalidRequirement, Requirement
+from packaging.utils import canonicalize_name
+from packaging.version import Version
+
+REPO_ROOT = pathlib.Path(__file__).resolve().parents[3]
+REQ_ROOT = REPO_ROOT / "studio" / "backend" / "requirements"
+
+TRANSFORMERS_WITHOUT_NESTED_GATHER = Version("5.2.0")
+SENTENCE_TRANSFORMERS_WITH_FALLBACK = Version("5.2.3")
+
+
+def _pins(path: pathlib.Path, name: str) -> dict[str, Version]:
+ out = {}
+ for line in path.read_text(encoding = "utf-8").splitlines():
+ text = line.split("#", 1)[0].strip()
+ if not text or text.startswith("-"):
+ continue
+ try:
+ req = Requirement(text)
+ except InvalidRequirement:
+ continue
+ if canonicalize_name(req.name) != canonicalize_name(name):
+ continue
+ for spec in req.specifier:
+ if spec.operator == "==":
+ out[str(req.marker)] = Version(spec.version)
+ return out
+
+
+def _trains_with(transformers: Version, sentence_transformers: Version) -> bool:
+ return (
+ transformers < TRANSFORMERS_WITHOUT_NESTED_GATHER
+ or sentence_transformers >= SENTENCE_TRANSFORMERS_WITH_FALLBACK
+ )
+
+
+def test_pinned_sentence_transformers_can_log_with_the_pinned_transformers():
+ checked = 0
+ for path in sorted(REQ_ROOT.rglob("*.txt")):
+ st_pins = _pins(path, "sentence-transformers")
+ tf_pins = _pins(path, "transformers")
+ for marker, st in st_pins.items():
+ tf = tf_pins.get(marker)
+ if tf is None:
+ continue
+ checked += 1
+ assert _trains_with(tf, st), (
+ f"{path.relative_to(REPO_ROOT)} pins sentence-transformers=={st} with "
+ f"transformers=={tf} ({marker}); embedding training fails at its first "
+ f"logging step with no attribute '_nested_gather'"
+ )
+ assert checked >= 4
+
+
+def test_the_pair_that_broke_embedding_training_is_rejected():
+ assert not _trains_with(Version("5.5.0"), Version("5.2.0"))
+ assert _trains_with(Version("4.57.6"), Version("5.1.2"))