Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5a536c4
Add MLX engine selector (torch|mlx) for training + gradio
Jul 15, 2026
50b0122
mlx-engine: transform underfit demo block to the MLX trainer's --demo…
Jul 15, 2026
21eb9ba
mlx-engine: map optimizer/scheduler/effective-length + adapter_type d…
Jul 15, 2026
e92f973
mlx-engine: --dit-weights is optional (trainer auto-downloads the bas…
Jul 15, 2026
68558cf
dashboard: platform-aware device UI (Apple Silicon MPS/MLX, not just …
Jul 15, 2026
90628e8
dashboard: engine-aware base-model gate + shorten MPS label
Jul 15, 2026
4492c40
dashboard: MLX dataset encoding on Apple (torch-free)
Jul 15, 2026
25a37fd
dashboard: MLX encode writes into latent_dir, not output_dir
Jul 15, 2026
08f90f4
dashboard: pass exclude-file to the MLX encoder
Jul 15, 2026
c1669ee
mlx-engine: pass ARC demos, forward grad-clip, inherit trainer stdout
Jul 15, 2026
b7f6dfd
dashboard: fix Apple/MLX gaps in gradio launch, device panel, resume,…
Jul 15, 2026
f8e606f
dashboard/installer: on-demand + install-time MLX model download
Jul 15, 2026
08c0003
mlx-engine: pass demo `duration` through to the MLX trainer
Jul 15, 2026
ecc15e1
dashboard: don't offer MPS without a torch backend; fix greyed-silent…
Jul 15, 2026
fba6445
dashboard: pass base_model to the MLX gradio launch (--pretrained-name)
Jul 15, 2026
0549280
dashboard: default MLX demos to ARC-only (skip the slow RF demos)
Jul 15, 2026
d8a6a91
dashboard: SA3-medium "Use SAME-S for demos (faster)" toggle
Jul 15, 2026
899dfc8
dashboard: relabel demo presets One/Two/Four on MLX (ARC-only counts)
Jul 15, 2026
de117ea
dashboard: hide dotfile scratch from the checkpoint lists
Jul 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
306 changes: 267 additions & 39 deletions dashboard/index.html

Large diffs are not rendered by default.

500 changes: 436 additions & 64 deletions dashboard/server.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
# stable-audio-tools used so backend code that expects these keys keeps
# working.

# Training/inference engine: torch | mlx
# torch (default) — the in-process PyTorch loop (MPS/CUDA/CPU), unchanged.
# mlx — Apple-Silicon-only; shells out to the separate MLX
# trainer/gradio in the sibling stable-audio-3 checkout
# (see underfit/backends/mlx_engine.py). Overridable via
# --engine or the UNDERFIT_ENGINE env var.
engine = torch

# Name of the run (dashboard overrides via --name)
name = underfit-run

Expand Down
22 changes: 22 additions & 0 deletions lora_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ def get_all_args(defaults_file="defaults.ini"):
p.add_argument("--wandb-config", default=None)
p.add_argument("--backend", default=None,
help="sat | sa3 (default: env UNDERFIT_BACKEND or auto)")
# Pre-register --engine so the generic defaults loop below (which would add
# it from defaults.ini) is swallowed by its ArgumentError guard — this
# explicit registration keeps default=None so we can apply the
# CLI > env > defaults.ini > torch precedence after parsing.
p.add_argument("--engine", default=None, choices=["torch", "mlx"],
help="torch | mlx (default: env UNDERFIT_ENGINE, defaults.ini, "
"else torch). mlx runs the Apple-Silicon MLX trainer in "
"the sibling stable-audio-3 checkout.")
for key, value in defaults.items():
arg_name = f"--{key.replace('_', '-')}"
try:
Expand All @@ -124,13 +132,27 @@ def get_all_args(defaults_file="defaults.ini"):
setattr(args, key, float(val))
except ValueError:
pass
# Engine selection precedence: CLI --engine > env UNDERFIT_ENGINE >
# defaults.ini > torch.
if getattr(args, "engine", None) is None:
args.engine = os.environ.get("UNDERFIT_ENGINE") or defaults.get("engine") or "torch"
args.engine = str(args.engine).strip().strip("'\"").lower()
if args.engine not in ("torch", "mlx"):
raise SystemExit(f"--engine must be 'torch' or 'mlx', got {args.engine!r}")
return args


def main():
args = get_all_args()
if os.environ.get("SLURM_PROCID") is not None:
args.seed = (args.seed or 0) + int(os.environ["SLURM_PROCID"])

# --- MLX engine: delegate to the sibling stable-audio-3 MLX trainer. ---
# Purely additive; the torch path below is unchanged for engine=torch.
if getattr(args, "engine", "torch") == "mlx":
from underfit.backends import mlx_engine
sys.exit(mlx_engine.run_mlx_training(args))

# Pre-warn (and quiet torch's noisy autotune warnings) on pre-Ampere GPUs.
from underfit.utils import check_attention_compute_capability, check_attention_backends
check_attention_compute_capability()
Expand Down
14 changes: 14 additions & 0 deletions run_gradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@


def main(args):
# --- MLX engine: delegate to the sibling stable-audio-3 MLX gradio. ---
# Purely additive; the torch path below is unchanged for engine=torch.
engine = (getattr(args, "engine", None) or os.environ.get("UNDERFIT_ENGINE") or "torch").strip().lower()
if engine == "mlx":
from underfit.backends import mlx_engine
model = mlx_engine.resolve_dit_model(args.model_config, args.pretrained_name)
port_env = os.environ.get("GRADIO_SERVER_PORT")
port = int(port_env) if port_env and port_env.isdigit() else None
sys.exit(mlx_engine.run_mlx_gradio(model, args.lora_ckpt_path, share=True, port=port))

backend = get_backend(args.backend)
print(f"Using backend: {backend.NAME}", flush=True)

Expand Down Expand Up @@ -73,6 +83,10 @@ def main(args):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run gradio interface (Underfit)")
parser.add_argument("--backend", default=None, help="sat | sa3 (default: env UNDERFIT_BACKEND or auto)")
parser.add_argument("--engine", default=None, choices=["torch", "mlx"],
help="torch | mlx (default: env UNDERFIT_ENGINE, else torch). "
"mlx launches the Apple-Silicon MLX gradio in the sibling "
"stable-audio-3 checkout.")
parser.add_argument("--pretrained-name", type=str, required=False)
parser.add_argument("--model-config", type=str, required=False)
parser.add_argument("--ckpt-path", type=str, required=False)
Expand Down
Loading