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: reject a training random_seed outside the numpy range up front (#15176)

Vineeth Sai Varikuntla33114dae86a6
diff --git a/studio/backend/models/training.py b/studio/backend/models/training.py
index 96c76c642b8..548a6f59791 100644
--- a/studio/backend/models/training.py
+++ b/studio/backend/models/training.py
@@ -597,8 +597,11 @@ class TrainingStartRequest(BaseModel):
"back to the incoming activation dtype."
),
)
+ # numpy's range (transformers.set_seed): out of it, the run only fails after the model loads.
random_seed: int = Field(
3407,
+ ge = 0,
+ le = 2**32 - 1,
description = (
"Random seed; matches the Unsloth backend / MLX worker default "
"and unsloth's historical recommended value."
diff --git a/studio/backend/tests/test_studio_train_validation.py b/studio/backend/tests/test_studio_train_validation.py
index 2e98daca423..a991de1d144 100644
--- a/studio/backend/tests/test_studio_train_validation.py
+++ b/studio/backend/tests/test_studio_train_validation.py
@@ -133,3 +133,21 @@ class TestLoraAlphaCap:
def test_below_min_rejects(self):
with pytest.raises(ValidationError):
_check_field("lora_alpha", 0)
+
+
+class TestRandomSeedRange:
+ @pytest.mark.parametrize("value", [0, 3407, 2**32 - 1])
+ def test_in_range_accepts(self, value):
+ _check_field("random_seed", value)
+
+ @pytest.mark.parametrize("value", [-1, 2**32])
+ def test_out_of_range_rejects(self, value):
+ with pytest.raises(ValidationError) as exc:
+ _check_field("random_seed", value)
+ assert "random_seed" in str(exc.value)
+
+ @pytest.mark.parametrize("value", [-1, 2**32])
+ def test_out_of_range_is_what_set_seed_refuses(self, value):
+ np = pytest.importorskip("numpy")
+ with pytest.raises(ValueError):
+ np.random.seed(value)