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
Trim comments in the MLX DoRA changes
Daniel Han15866d2d7d85
diff --git a/studio/backend/core/training/worker.py b/studio/backend/core/training/worker.pyindex f81c773f55d..3edfa77e2b0 100644--- a/studio/backend/core/training/worker.py+++ b/studio/backend/core/training/worker.py@@ -2569,11 +2569,7 @@ def _normalize_mlx_studio_optimizer(value):def _mlx_dora_peft_kwargs(config, get_peft_model):- """LoRA kwargs a DoRA request adds for MLX, or raise why it cannot run.-- Only version skew is decided here; whether the selected modules can carry- DoRA depends on the loaded model, so the MLX backend refuses those itself.- """+ """LoRA kwargs a DoRA request adds for MLX, or raise why it cannot run."""import inspectif not config.get("use_dora"):@@ -2582,9 +2578,8 @@ def _mlx_dora_peft_kwargs(config, get_peft_model):parameter = inspect.signature(get_peft_model).parameters.get("use_dora")except (TypeError, ValueError):parameter = None- # The name alone is not support: `**use_dora` collects anything, which is- # what the unsupporting version already does, and the positional-only and- # `*use_dora` kinds cannot be bound by keyword at all.+ # A **kwargs catch-all absorbs use_dora and trains plain LoRA, so the+ # parameter must be named and bindable by keyword.named = parameter is not None and parameter.kind in (inspect.Parameter.POSITIONAL_OR_KEYWORD,inspect.Parameter.KEYWORD_ONLY,diff --git a/studio/backend/tests/test_mlx_training_worker_config.py b/studio/backend/tests/test_mlx_training_worker_config.pyindex 67b43a5dcaa..2af8e113518 100644--- a/studio/backend/tests/test_mlx_training_worker_config.py+++ b/studio/backend/tests/test_mlx_training_worker_config.py@@ -34,8 +34,8 @@ def _load_worker_module():sys.modules["loggers"] = loggersutils = types.ModuleType("utils")- # Real package directory: an empty __path__ shadows the package and- # breaks the worker's own imports. Only the stubs below replace it.+ # An empty __path__ shadows the real package and breaks the worker's own+ # imports; only the stubs below replace it.utils.__path__ = [str(Path(__file__).resolve().parents[1] / "utils")]sys.modules["utils"] = utils@@ -115,8 +115,8 @@ def test_mlx_studio_rejects_unknown_scheduler():def test_mlx_dora_requires_the_named_use_dora_parameter():- # The release predating MLX DoRA swallows use_dora through this catch-all- # and trains plain LoRA, so accepting-the-keyword is not support.+ # A **kwargs catch-all absorbs use_dora and trains plain LoRA, so accepting the+ # keyword is not support.def old_zoo(model,r = 16,@@ -153,16 +153,13 @@ def test_mlx_dora_requires_the_named_use_dora_parameter():assert _mlx_dora_peft_kwargs({"use_dora": True}, usable) == {"use_dora": True}with pytest.raises(NotImplementedError, match = "unsloth-zoo"):_mlx_dora_peft_kwargs({"use_dora": True}, old_zoo)- # None of these kinds prove support: two cannot be bound by keyword, and- # `**use_dora` only collects it the way the unsupporting version does.for unusable in (positional_only_zoo, var_positional_zoo, var_keyword_zoo):with pytest.raises(NotImplementedError, match = "unsloth-zoo"):_mlx_dora_peft_kwargs({"use_dora": True}, unusable)- # An unreadable signature (inspect.signature raises here) is not support.with pytest.raises(NotImplementedError, match = "unsloth-zoo"):_mlx_dora_peft_kwargs({"use_dora": True}, object())- # An image-bearing dataset is not proof of a vision model; a text model- # can still train language-only DoRA from it.+ # An image-bearing dataset is not proof of a vision model; a text+ # model can still train language-only DoRA.assert _mlx_dora_peft_kwargs({"use_dora": True,@@ -171,7 +168,6 @@ def test_mlx_dora_requires_the_named_use_dora_parameter():},new_zoo,) == {"use_dora": True}- # Nothing added, nothing checked, when DoRA was not requested.assert _mlx_dora_peft_kwargs({}, old_zoo) == {}assert _mlx_dora_peft_kwargs({"use_dora": False}, old_zoo) == {}diff --git a/studio/backend/tests/test_training_cached_start.py b/studio/backend/tests/test_training_cached_start.pyindex 89cdbb84ec3..ade099c1334 100644--- a/studio/backend/tests/test_training_cached_start.py+++ b/studio/backend/tests/test_training_cached_start.py@@ -1279,8 +1279,7 @@ def test_mlx_start_rejects_unsupported_training_config(request_overrides, expectdef test_mlx_start_accepts_dora():- # MLX trains DoRA, so the platform gate must let it through. LoftQ is- # asserted alongside it so a gate that stopped refusing anything at all+ # LoftQ is asserted alongside DoRA so a gate that stopped refusing anything at all# cannot pass this test.from utils.hardware import hardwarediff --git a/studio/frontend/src/features/studio/sections/lora-params-section.tsx b/studio/frontend/src/features/studio/sections/lora-params-section.tsxindex c99cbbbb427..e7be24ac81c 100644--- a/studio/frontend/src/features/studio/sections/lora-params-section.tsx+++ b/studio/frontend/src/features/studio/sections/lora-params-section.tsx@@ -59,9 +59,8 @@ export function LoraParamsSection(): ReactElement | null {const [open, setOpen] = useState(true);const isCpt = store.trainingMethod === "cpt";const showVisionLora = store.isVisionModel && store.isDatasetImage === true;- // MLX refuses DoRA once vision layers are in the run. `isVisionModel` is- // fetched metadata that can go stale, so this only stops the combination- // being newly selected; the loaded model still settles an existing one.+ // `isVisionModel` can go stale, so this blocks only a NEW selection;+ // the backend settles an existing one.const doraNeedsVisionOff =deviceType === "mac" && showVisionLora && store.finetuneVisionLayers;diff --git a/studio/frontend/src/features/studio/sections/use-mlx-training-config-policy.ts b/studio/frontend/src/features/studio/sections/use-mlx-training-config-policy.tsindex ad64cf9f014..d8d307accf9 100644--- a/studio/frontend/src/features/studio/sections/use-mlx-training-config-policy.ts+++ b/studio/frontend/src/features/studio/sections/use-mlx-training-config-policy.ts@@ -15,8 +15,8 @@ export function useMlxTrainingConfigPolicy(): void {})),);- // Only loftq: MLX trains DoRA, so clearing a `dora` selection here would- // silently substitute plain LoRA for the run the user asked for.+ // Only loftq: clearing a persisted `dora` selection would silently substitute plain+ // LoRA.useEffect(() => {if (isMac && loraVariant === "loftq") {useTrainingConfigStore.setState({ loraVariant: "lora" });diff --git a/studio/frontend/tests/training-validation.test.ts b/studio/frontend/tests/training-validation.test.tsindex 2b04d225e0f..d75258f5189 100644--- a/studio/frontend/tests/training-validation.test.ts+++ b/studio/frontend/tests/training-validation.test.ts@@ -290,8 +290,7 @@ test("training validation accepts DoRA on MLX under an adapter method", () => {{ ...validConfig, trainingMethod, loraVariant: "dora" },"mac",),- // cpt is refused on MLX for its own reason, which must not be read as- // DoRA being refused.+ // cpt is refused on MLX for its own reason, not for DoRA.trainingMethod === "cpt"? { ok: false, errorKey: "studio.params.notSupportedAppleSilicon" }: { ok: true, errorKey: null },diff --git a/tests/studio/test_mlx_training_worker_behaviors.py b/tests/studio/test_mlx_training_worker_behaviors.pyindex 014cb57a16c..c09d75207a8 100644--- a/tests/studio/test_mlx_training_worker_behaviors.py+++ b/tests/studio/test_mlx_training_worker_behaviors.py@@ -36,27 +36,7 @@ def test_run_mlx_training_passes_token_to_from_pretrained():def test_mlx_dora_decided_before_load_and_merged_into_peft_kwargs():- """The DoRA decision must be wired to happen before the base model is- fetched, and to feed the wrap call.-- Dropping the merge would accept a DoRA request and silently train plain- LoRA; deciding after the load would make an unsupported unsloth-zoo cost- a multi-gigabyte download first.-- This checks WIRING, not runtime behavior: the decision precedes the load,- takes the run config, probes the same callable the wrap invokes, and its- result is merged into the mapping that wrap expands without being rebound- in between. It cannot see through code that keeps the shape and defeats- the effect -- burying the merge under a false condition, unsetting the key- afterwards -- because the test and the code it reads live together; the- real-model behavior is covered by the MLX backend's own tests.-- This asserts one specific shape — a `peft_kwargs.update(...)` call and a- `**peft_kwargs` wrap call — rather than trying to recognize every- equivalent formulation. Rewriting that seam another way (a merge- operator, explicit unpacking) is expected to fail here and to be- re-expressed, not worked around.- """+ """Wiring only: dropping the merge would silently train plain LoRA, and deciding after the load would make an unsupported unsloth-zoo cost a multi-gigabyte download first. One shape is asserted, so an equivalent rewrite is meant to fail here and be re-expressed."""tree = ast.parse(WORKER.read_text(encoding = "utf-8"))fn = _find_func(tree, "_run_mlx_training")assert fn is not None@@ -72,8 +52,6 @@ def test_mlx_dora_decided_before_load_and_merged_into_peft_kwargs():):decided_at = node.linenodecision_target = node.targets[0].id- # The run's own config and the same callable the wrap invokes --- # probing anything else answers for something else.passed = [ast.unparse(arg) for arg in node.value.args]assert passed == ["config",@@ -107,7 +85,6 @@ def test_mlx_dora_decided_before_load_and_merged_into_peft_kwargs():]assert wraps, "FastMLXModel.get_peft_model is never called"for wrap in wraps:- # A real ** expansion, not a string that merely looks like one.assert any(kw.arg is None and ast.unparse(kw.value) == "peft_kwargs" for kw in wrap.keywords), (@@ -118,11 +95,8 @@ def test_mlx_dora_decided_before_load_and_merged_into_peft_kwargs():assert (min(merged_at) < first_wrap), "peft_kwargs must be updated before get_peft_model is called"- # ...and not replaced in between, which would drop the merge again.- # A Store/Del context covers the rebinding forms a refactor realistically- # produces. This is a regression check over one function's line range, not- # a proof: string-bound names (import aliases, `case` captures) and- # anything sharing the merge's line are outside it.+ # Store/Del only: string-bound names (import aliases, `case` captures)+ # and the merge's own line are outside this check.rebound = [node.linenofor node in ast.walk(fn)