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: MOSS-Image, SDXL-Turbo and MiniMax-H3 default steps / guidance follow the reference workflows (#16097)

Daniel Hanc569b23c441d
diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.py
index 0612bc58128..c3d255691eb 100644
--- a/studio/backend/core/inference/diffusion.py
+++ b/studio/backend/core/inference/diffusion.py
@@ -13653,6 +13653,17 @@ class DiffusionBackend:
if inpaint_padding_applied is None and init_pil is not None:
soft_overlay = (init_pil, mask_pil)
+ if (
+ workflow in ("img2img", "inpaint", "upscale")
+ and init_pil is not None
+ and "strength" in call_params
+ ):
+ applied = strength if strength is not None else call_params["strength"].default
+ if isinstance(applied, (int, float)):
+ # SDXL-style img2img runs int(N * strength) steps: a 1-step default would denoise none.
+ steps = diffusion_hires.min_inference_steps(
+ steps, float(applied), diffusion_hires.timestep_rule(pipe)
+ )
kwargs: dict[str, Any] = {
# prompt / generator are set per chunk below, one Generator per image.
"num_inference_steps": steps,
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index 8b02cd2afce..cf1b3e39407 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -2099,12 +2099,12 @@ _GENERATION_DEFAULTS: tuple[tuple[str, int, float], ...] = (
("hidream", 50, 5.0),
# Ideogram 4: an explicit 48 steps at 7 still runs the card's tapered schedule.
("ideogram", 20, 7.0),
- # MOSS-Image: ComfyUI workflow, 50 steps at CFG 3.
- ("moss-image", 50, 3.0),
- ("moss_image", 50, 3.0),
- ("mossimage", 50, 3.0),
- # SDXL: Turbo distilled; base wants ~30 steps + CFG ~7. "sdxl-turbo" precedes "sdxl".
- ("sdxl-turbo", 3, 0.0),
+ # MOSS-Image: the SFT and Base t2i templates both run 25 steps at CFG 2.5.
+ ("moss-image", 25, 2.5),
+ ("moss_image", 25, 2.5),
+ ("mossimage", 25, 2.5),
+ # SDXL-Turbo: 1 step, CFG 1. "sdxl-turbo" must precede "sdxl".
+ ("sdxl-turbo", 1, 0.0),
("stable-diffusion-xl", 25, 7.0),
("sdxl", 25, 7.0),
)
diff --git a/studio/backend/core/inference/diffusion_hires.py b/studio/backend/core/inference/diffusion_hires.py
index f396bd02746..9a230493670 100644
--- a/studio/backend/core/inference/diffusion_hires.py
+++ b/studio/backend/core/inference/diffusion_hires.py
@@ -126,6 +126,18 @@ def steps_run(num_inference_steps: int, strength: float, rule: str) -> int:
return n - t_start
+def min_inference_steps(steps: int, strength: float, rule: str) -> int:
+ """``steps``, raised to the smallest count that still denoises at least one step at ``strength``."""
+ n = max(1, int(steps))
+ s = float(strength)
+ if s <= 0.0 or s >= 1.0:
+ return n
+ limit = int(math.ceil(1.0 / max(s, MIN_DENOISE))) + 2
+ while steps_run(n, s, rule) < 1 and n < limit:
+ n += 1
+ return n
+
+
def refine_inference_steps(steps: int, denoise: float, rule: str) -> int:
"""The ``num_inference_steps`` that makes the refine pass run EXACTLY ``steps`` steps at ``denoise``."""
steps = max(1, int(steps))
diff --git a/studio/backend/core/inference/video_families.py b/studio/backend/core/inference/video_families.py
index bb181513d3c..52f4a956918 100644
--- a/studio/backend/core/inference/video_families.py
+++ b/studio/backend/core/inference/video_families.py
@@ -557,7 +557,8 @@ _FAMILIES: tuple[VideoFamily, ...] = (
base_repo = "MiniMaxAI/MiniMax-H3",
aliases = ("minimax_h3", "minimaxh3", "h3"),
has_audio = True,
- default_steps = 30,
+ # The t2v template's non-LoRA path: 20 steps, BasicGuider (CFG 1); the turbo LoRA path is the PDD row.
+ default_steps = 20,
default_guidance = 1.0,
default_num_frames = 124,
default_fps = 24,
diff --git a/studio/backend/tests/fixtures/diffusion_family_data_freeze.json b/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
index 7f0bf92adef..a6b8c70ccea 100644
--- a/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
+++ b/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
@@ -225,17 +225,17 @@
],
"minimax-h3": {
"fields": [
- 30,
+ 20,
1.0
],
"resolved": [
- 30,
+ 20,
1.0
]
},
"moss-image": [
- 50,
- 3.0
+ 25,
+ 2.5
],
"qwen-image": [
20,
diff --git a/studio/backend/tests/test_diffusion_hires.py b/studio/backend/tests/test_diffusion_hires.py
index dafed138475..4ef676c474e 100644
--- a/studio/backend/tests/test_diffusion_hires.py
+++ b/studio/backend/tests/test_diffusion_hires.py
@@ -1549,3 +1549,33 @@ def test_generation_log_line_takes_a_latent_base_pass():
{"images": [torch.zeros(1, 4, 8, 8)], "workflow": "txt2img"}, engine = "diffusers"
)
assert "images=1" in line and "size=" not in line
+
+
[email protected]("strength", [0.3, 0.5, 0.6, 0.75, 0.99])
+def test_img2img_never_schedules_zero_steps_on_a_floor_pipeline(strength):
+ n = hires.min_inference_steps(1, strength, hires.RULE_FLOOR)
+ assert hires.steps_run(n, strength, hires.RULE_FLOOR) == 1
+ assert hires.steps_run(n - 1, strength, hires.RULE_FLOOR) == 0
+
+
+def test_min_inference_steps_keeps_counts_that_already_denoise():
+ assert hires.min_inference_steps(3, 0.6, hires.RULE_FLOOR) == 3
+ assert hires.min_inference_steps(1, 0.6, hires.RULE_FLOW) == 1
+ assert hires.min_inference_steps(1, 1.0, hires.RULE_FLOOR) == 1
+
+
+def test_img2img_inpaint_and_upscale_raise_steps_before_the_call():
+ import core.inference.diffusion as diffusion
+
+ src = inspect.getsource(diffusion)
+ guard = src.index("diffusion_hires.min_inference_steps(")
+ assert 'workflow in ("img2img", "inpaint", "upscale")' in src[guard - 600 : guard]
+ assert src.index('"num_inference_steps": steps,', guard) > guard
+
+
+def test_upscale_default_strength_keeps_one_step_and_hires_refine_is_untouched():
+ # The standalone Upscale default strength is 0.35; the Hires refine already schedules >= 1 step.
+ n = hires.min_inference_steps(1, 0.35, hires.RULE_FLOOR)
+ assert n == 3 and hires.steps_run(n, 0.35, hires.RULE_FLOOR) == 1
+ refine = hires.refine_inference_steps(1, 0.35, hires.RULE_FLOOR)
+ assert hires.min_inference_steps(refine, 0.35, hires.RULE_FLOOR) == refine
diff --git a/studio/backend/tests/test_diffusion_moss_image.py b/studio/backend/tests/test_diffusion_moss_image.py
index 1e2aae5ec21..f6498549120 100644
--- a/studio/backend/tests/test_diffusion_moss_image.py
+++ b/studio/backend/tests/test_diffusion_moss_image.py
@@ -443,7 +443,7 @@ def test_family_row_defaults_and_trust():
and fam.transformer_class == "MOSSImageTransformer"
)
for repo in ("OpenMOSS-Team/MOSS-Image-SFT", "OpenMOSS-Team/MOSS-Image-Base", "moss-image"):
- assert df.default_generation_params(repo) == (50, 3.0), repo
+ assert df.default_generation_params(repo) == (25, 2.5), repo
trusted = trusted_repo_ids(df._FAMILIES)
assert {"openmoss-team/moss-image-sft", "openmoss-team/moss-image-base"} <= trusted
diff --git a/studio/backend/tests/test_generation_defaults_reference_workflows.py b/studio/backend/tests/test_generation_defaults_reference_workflows.py
new file mode 100644
index 00000000000..7fbc9e1edfc
--- /dev/null
+++ b/studio/backend/tests/test_generation_defaults_reference_workflows.py
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Default steps / guidance match the reference workflows; frontend tables match the backend."""
+
+from __future__ import annotations
+
+import re
+from pathlib import Path
+
+import pytest
+
+from core.inference import diffusion_families as df
+from core.inference import video_families as vf
+
+_FRONTEND = Path(__file__).resolve().parents[2] / "frontend" / "src" / "features"
+_ROW = re.compile(r'\{\s*match:\s*"([^"]+)",\s*steps:\s*([\d.]+),\s*guidance:\s*([\d.]+)\s*\}')
+
+
+def _frontend_rows(relative: str) -> dict[str, tuple[int, float]]:
+ text = (_FRONTEND / relative).read_text(encoding = "utf-8")
+ return {m[1]: (int(m[2]), float(m[3])) for m in _ROW.finditer(text)}
+
+
+ "repo, want",
+ [
+ ("OpenMOSS-Team/MOSS-Image-SFT", (25, 2.5)),
+ ("OpenMOSS-Team/MOSS-Image-Base", (25, 2.5)),
+ ("unsloth/MOSS-Image-SFT-FP8", (25, 2.5)),
+ ("stabilityai/sdxl-turbo", (1, 0.0)),
+ ("unsloth/sdxl-turbo", (1, 0.0)),
+ # Unchanged: already the reference values (Z-Image's diffusers g is the reference cfg minus 1).
+ ("stabilityai/stable-diffusion-xl-base-1.0", (25, 7.0)),
+ ("Tongyi-MAI/Z-Image", (25, 3.0)),
+ ("black-forest-labs/FLUX.3-Image-Klein-Base", (50, 3.5)),
+ ("flux.3-klein", (16, 1.0)),
+ ],
+)
+def test_image_defaults(repo, want):
+ assert df.default_generation_params(repo) == want
+
+
+def test_minimax_h3_default_is_the_non_lora_reference_recipe():
+ fam = vf.detect_video_family("MiniMaxAI/MiniMax-H3")
+ assert fam is not None and fam.name == "minimax-h3"
+ assert (fam.default_steps, fam.default_guidance) == (20, 1.0)
+ assert vf.default_video_generation_params(
+ "MiniMaxAI/MiniMax-H3", fallback = (fam.default_steps, fam.default_guidance), family = fam.name
+ ) == (20, 1.0)
+ assert vf.default_video_generation_params(
+ "someone/MiniMax-H3-PDD", fallback = (20, 1.0), family = fam.name
+ ) == (8, 1.0)
+
+
+def test_ltx2_keeps_its_single_stage_recipe():
+ fam = vf.detect_video_family("Lightricks/LTX-2")
+ assert (fam.default_steps, fam.default_guidance) == (40, 4.0)
+
+
+def test_images_page_table_matches_backend():
+ rows = _frontend_rows("images/image-generation-defaults.ts")
+ for key in (
+ "moss-image",
+ "moss_image",
+ "mossimage",
+ "sdxl-turbo",
+ "sdxl",
+ "z-image",
+ "flux.3-klein-base",
+ ):
+ assert rows[key] == df.default_generation_params(key), key
+ backend = {k: (s, g) for k, s, g in df._GENERATION_DEFAULTS}
+ for key, value in rows.items():
+ if key in backend:
+ assert value == backend[key], key
+
+
+def test_video_page_minimax_row_matches_backend():
+ rows = _frontend_rows("video/video-page.tsx")
+ fam = vf.detect_video_family("MiniMaxAI/MiniMax-H3")
+ assert rows["minimax-h3"] == (fam.default_steps, fam.default_guidance)
diff --git a/studio/frontend/src/features/images/image-generation-defaults.ts b/studio/frontend/src/features/images/image-generation-defaults.ts
index 40fa6115052..6f6eaf949b7 100644
--- a/studio/frontend/src/features/images/image-generation-defaults.ts
+++ b/studio/frontend/src/features/images/image-generation-defaults.ts
@@ -56,15 +56,15 @@ const MODEL_DEFAULTS: Array<{
{ match: "qwen-image", steps: 20, guidance: 4 },
{ match: "z-image", steps: 25, guidance: 3 },
{ match: "ideogram", steps: 20, guidance: 7 },
- { match: "moss-image", steps: 50, guidance: 3 },
- { match: "moss_image", steps: 50, guidance: 3 },
- { match: "mossimage", steps: 50, guidance: 3 },
+ { match: "moss-image", steps: 25, guidance: 2.5 },
+ { match: "moss_image", steps: 25, guidance: 2.5 },
+ { match: "mossimage", steps: 25, guidance: 2.5 },
{ match: "lumina", steps: 50, guidance: 4 },
{ match: "hunyuanimage", steps: 50, guidance: 3.25 },
{ match: "hidream-i1-dev", steps: 28, guidance: 0 },
{ match: "hidream-i1-fast", steps: 16, guidance: 0 },
{ match: "hidream", steps: 50, guidance: 5 },
- { match: "sdxl-turbo", steps: 3, guidance: 0 },
+ { match: "sdxl-turbo", steps: 1, guidance: 0 },
{ match: "stable-diffusion-xl", steps: 25, guidance: 7 },
{ match: "sdxl", steps: 25, guidance: 7 },
];
diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsx
index 378f8726d47..caa9fbf4280 100644
--- a/studio/frontend/src/features/video/video-page.tsx
+++ b/studio/frontend/src/features/video/video-page.tsx
@@ -281,7 +281,7 @@ function useVideoModels(
const DEFAULT_GEN = { steps: 8, guidance: 1 };
const MODEL_DEFAULTS: Array<{ match: string; steps: number; guidance: number }> = [
- { match: "minimax-h3", steps: 30, guidance: 1 },
+ { match: "minimax-h3", steps: 20, guidance: 1 },
{ match: "cosmos3-nano", steps: 35, guidance: 6 },
{ match: "cosmos3-edge", steps: 20, guidance: 6 },
// "distilled" before the generic "ltx": the distilled model runs at 8 steps, guidance 1.
diff --git a/studio/frontend/tests/image-generation-defaults.test.ts b/studio/frontend/tests/image-generation-defaults.test.ts
index cf1f04e6fe9..fed0103d8c9 100644
--- a/studio/frontend/tests/image-generation-defaults.test.ts
+++ b/studio/frontend/tests/image-generation-defaults.test.ts
@@ -175,6 +175,8 @@ test("defaults follow ComfyUI's official templates for the same model", () => {
// diffusers Z-Image guidance g equals ComfyUI cfg g + 1.
["Tongyi-MAI/Z-Image", { steps: 25, guidance: 3 }],
["stabilityai/stable-diffusion-xl-base-1.0", { steps: 25, guidance: 7 }],
+ ["stabilityai/sdxl-turbo", { steps: 1, guidance: 0 }],
+ ["unsloth/sdxl-turbo", { steps: 1, guidance: 0 }],
["ideogram-ai/ideogram-4-fp8", { steps: 20, guidance: 7 }],
] as const) {
assert.deepEqual(defaultsFor(id), want, id);
@@ -304,18 +306,18 @@ test("an explicit FLUX.3 family decides the recipe over a name that reads as the
);
});
-test("MOSS-Image SFT and Base get ComfyUI's MOSS recipe", () => {
+test("MOSS-Image SFT and Base get the reference workflow's 25 / 2.5 recipe", () => {
for (const id of [
"OpenMOSS-Team/MOSS-Image-SFT",
"OpenMOSS-Team/MOSS-Image-Base",
"someone/moss_image_sft_merge",
"moss-image",
]) {
- assert.deepEqual(defaultsFor(id), { steps: 50, guidance: 3 }, id);
+ assert.deepEqual(defaultsFor(id), { steps: 25, guidance: 2.5 }, id);
}
const key = defaultsKeyFor("/models/my-model", "moss-image");
assert.equal(key, "moss-image");
- assert.deepEqual(defaultsFor(key), { steps: 50, guidance: 3 });
+ assert.deepEqual(defaultsFor(key), { steps: 25, guidance: 2.5 });
});
test("a GGUF filename naming Krea 2 Raw outranks its multi-checkpoint repo", () => {
diff --git a/studio/frontend/tests/video-model-defaults.test.ts b/studio/frontend/tests/video-model-defaults.test.ts
index 15d69e05581..ae73a177c6e 100644
--- a/studio/frontend/tests/video-model-defaults.test.ts
+++ b/studio/frontend/tests/video-model-defaults.test.ts
@@ -65,8 +65,8 @@ test("the other families keep their recipes", () => {
const cases: Array<[string, number, number]> = [
["Wan-AI/Wan2.2-T2V-A14B-Diffusers", 20, 3.5],
["Wan-AI/Wan2.2-TI2V-5B-Diffusers", 20, 5],
- ["MiniMaxAI/MiniMax-H3", 30, 1],
- ["MiniMaxAI/MiniMax_H3", 30, 1],
+ ["MiniMaxAI/MiniMax-H3", 20, 1],
+ ["MiniMaxAI/MiniMax_H3", 20, 1],
["Lightricks/LTX-2.3", 40, 4],
["Lightricks/LTX-2.3/ltx-2.3-22b-distilled.safetensors", 8, 1],
["Lightricks/LTX-2.5-Diffusers", 8, 1],