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
Derive warmup steps from a model default that gives a ratio (#8723)
Vineeth Sai Varikuntlaa4fa4512140c
diff --git a/studio/frontend/src/features/training/api/models-api.ts b/studio/frontend/src/features/training/api/models-api.tsindex c764bd780cf..8d1c38684bd 100644--- a/studio/frontend/src/features/training/api/models-api.ts+++ b/studio/frontend/src/features/training/api/models-api.ts@@ -24,6 +24,7 @@ interface BackendTrainingDefaults {batch_size?: number;gradient_accumulation_steps?: number;warmup_steps?: number;+ warmup_ratio?: number;max_steps?: number;save_steps?: number;eval_steps?: number;diff --git a/studio/frontend/src/features/training/lib/model-defaults.ts b/studio/frontend/src/features/training/lib/model-defaults.tsindex d87a9ccb90e..1bcc0901a8c 100644--- a/studio/frontend/src/features/training/lib/model-defaults.ts+++ b/studio/frontend/src/features/training/lib/model-defaults.ts@@ -123,12 +123,24 @@ export function mapBackendModelConfigToTrainingPatch(const gradAccum = toNumber(training?.gradient_accumulation_steps);if (gradAccum !== undefined) patch.gradientAccumulation = gradAccum;- const warmupSteps = toNumber(training?.warmup_steps);- if (warmupSteps !== undefined) patch.warmupSteps = warmupSteps;-const maxSteps = toNumber(training?.max_steps);if (maxSteps !== undefined) patch.maxSteps = maxSteps;+ const warmupSteps = toNumber(training?.warmup_steps);+ if (warmupSteps !== undefined) {+ patch.warmupSteps = warmupSteps;+ } else {+ // Ten shipped model_defaults express warmup as a ratio and set no+ // warmup_steps, default.yaml among them, so reading only warmup_steps left+ // every one of them on the generic UI default. Materialize with ceil, the+ // way TrainingArguments.get_warmup_steps does, so a small ratio such as an+ // imported 0.03 over 10 steps asks for warmup and gets it instead of zero.+ const warmupRatio = toNumber(training?.warmup_ratio);+ if (warmupRatio !== undefined && maxSteps !== undefined && maxSteps > 0) {+ patch.warmupSteps = Math.ceil(warmupRatio * maxSteps);+ }+ }+const saveSteps = toNumber(training?.save_steps);if (saveSteps !== undefined) patch.saveSteps = saveSteps;diff --git a/studio/frontend/tests/training-model-defaults-warmup-ratio.test.ts b/studio/frontend/tests/training-model-defaults-warmup-ratio.test.tsnew file mode 100644index 00000000000..aea4eebc104--- /dev/null+++ b/studio/frontend/tests/training-model-defaults-warmup-ratio.test.ts@@ -0,0 +1,117 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// Ten shipped model_defaults express warmup as a ratio and set no warmup_steps,+// so the form has to derive it or those recommendations never arrive.++import assert from "node:assert/strict";+import { readFileSync, readdirSync } from "node:fs";+import test from "node:test";++import type { BackendModelConfig } from "../src/features/training/api/models-api.ts";+import { registerStoreStubResolver } from "./helpers/kit.ts";++registerStoreStubResolver();++const yaml = await import("js-yaml");+const { mapBackendModelConfigToTrainingPatch } = await import(+ "../src/features/training/lib/model-defaults.ts"+);++const MODEL_DEFAULTS_DIR = new URL(+ "../../backend/assets/configs/model_defaults/",+ import.meta.url,+);++function shippedConfigs(): { name: string; config: BackendModelConfig }[] {+ const found: { name: string; config: BackendModelConfig }[] = [];+ const walk = (dir: URL, prefix: string) => {+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ if (entry.isDirectory()) {+ walk(new URL(`${entry.name}/`, dir), `${prefix}${entry.name}/`);+ } else if (entry.name.endsWith(".yaml")) {+ const text = readFileSync(new URL(entry.name, dir), "utf8");+ found.push({+ name: `${prefix}${entry.name}`,+ config: (yaml.load(text) ?? {}) as BackendModelConfig,+ });+ }+ }+ };+ walk(MODEL_DEFAULTS_DIR, "");+ return found;+}++test("a warmup_ratio default reaches the form as steps", () => {+ const patch = mapBackendModelConfigToTrainingPatch({+ training: { warmup_ratio: 0.1, max_steps: 30 },+ });+ assert.equal(patch.warmupSteps, 3);+});++test("an explicit warmup_steps still wins over a ratio", () => {+ const patch = mapBackendModelConfigToTrainingPatch({+ training: { warmup_steps: 7, warmup_ratio: 0.1, max_steps: 30 },+ });+ assert.equal(patch.warmupSteps, 7);+});++test("a ratio too small to reach one step still gets one", () => {+ // Rounding would write 0 here, and mappers.ts submits warmupSteps as a+ // concrete warmup_steps, so a config that asked for warmup would train with+ // none. An explicit 0 is a different statement and is left at 0.+ for (const [training, expected] of [+ [{ warmup_ratio: 0.03, max_steps: 10 }, 1],+ [{ warmup_ratio: 0.01, max_steps: 30 }, 1],+ [{ warmup_ratio: 0, max_steps: 30 }, 0],+ ] as const) {+ const patch = mapBackendModelConfigToTrainingPatch({ training });+ assert.equal(patch.warmupSteps, expected, JSON.stringify(training));+ }+});++test("a ratio with no usable max_steps leaves warmup alone", () => {+ for (const training of [+ { warmup_ratio: 0.1 },+ { warmup_ratio: 0.1, max_steps: 0 },+ ]) {+ const patch = mapBackendModelConfigToTrainingPatch({ training });+ assert.equal(patch.warmupSteps, undefined, JSON.stringify(training));+ }+});++test("every shipped model default carries its warmup into the patch", () => {+ const configs = shippedConfigs();+ // Guard the fixture: a move or rename should fail loudly rather than leave+ // this test silently checking nothing.+ assert.ok(+ configs.length > 50,+ `only found ${configs.length} shipped configs`,+ );++ const ratioOnly = configs.filter(+ ({ config }) =>+ config.training?.warmup_ratio !== undefined &&+ config.training?.warmup_steps === undefined,+ );+ assert.ok(+ ratioOnly.length > 0,+ "expected at least one shipped config to express warmup as a ratio",+ );++ for (const { name, config } of configs) {+ const training = config.training ?? {};+ if (+ training.warmup_steps === undefined &&+ training.warmup_ratio === undefined+ ) {+ continue;+ }+ const patch = mapBackendModelConfigToTrainingPatch(config);+ assert.equal(+ typeof patch.warmupSteps,+ "number",+ `${name} declares a warmup but none reached the patch`,+ );+ }+});