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.

Keep the MLX adamw_8bit optimizer instead of collapsing it to adamw (#9950)

Vineeth Sai Varikuntla49b2ff98c329
diff --git a/tests/python/test_mlx_public_trainer_api.py b/tests/python/test_mlx_public_trainer_api.py
index fe97ba4c1dc..4bf984d7ed0 100644
--- a/tests/python/test_mlx_public_trainer_api.py
+++ b/tests/python/test_mlx_public_trainer_api.py
@@ -457,7 +457,7 @@ def test_mlx_training_arguments_normalize_optim_and_object_aliases():
with pytest.warns(RuntimeWarning, match = "save_strategy"):
args = unsloth._coerce_mlx_training_args(ArgsObject())
- assert args.optim == "adamw"
+ assert args.optim == "adamw_8bit"
assert args.eval_steps == 0
assert args.lr_scheduler_type == "cosine"
assert args.max_seq_length == 321
diff --git a/unsloth/__init__.py b/unsloth/__init__.py
index a9f11e8f328..d278fa0e902 100644
--- a/unsloth/__init__.py
+++ b/unsloth/__init__.py
@@ -656,9 +656,9 @@ if _IS_MLX:
strategy = strategy.rsplit(".", 1)[-1]
return strategy in ("no", "none", "false")
+ # Mirrors zoo's _normalize_mlx_optimizer_name; adamw_8bit is a real MLX optimizer, never collapse it.
_MLX_ADAMW_OPTIMIZER_ALIASES = frozenset(
(
- "adamw_8bit",
"paged_adamw_8bit",
"adamw_bnb_8bit",
"paged_adamw_32bit",
@@ -690,8 +690,7 @@ if _IS_MLX:
try:
return _normalize_mlx_optimizer_name(value)
except ValueError:
- # Older unsloth-zoo lacks the CUDA/TRL optimizer aliases, so map the common adamw_* names and keep
- # notebook defaults (optim="adamw_8bit") working.
+ # Older unsloth-zoo lacks the CUDA/TRL optimizer aliases, so map the common adamw_* names.
opt = str(getattr(value, "value", value) or "adamw").strip().lower()
opt = opt.rsplit(".", 1)[-1].replace("-", "_")
if opt in _MLX_ADAMW_OPTIMIZER_ALIASES: