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
Studio: set the ROCm AOTriton opt-in from the inference package so every entry point gets fused attention (#12668)
Daniel Hana0af6f117f0e
diff --git a/studio/backend/core/inference/__init__.py b/studio/backend/core/inference/__init__.pyindex b059f06515c..7576609ecb1 100644--- a/studio/backend/core/inference/__init__.py+++ b/studio/backend/core/inference/__init__.py@@ -16,8 +16,13 @@ actually accessed, so standalone helpers stay unit-testable without the fullinference stack."""+import osfrom typing import TYPE_CHECKING+# Same ROCm AOTriton opt-in as main.py, for entry points that skip main.py: without it gfx1151 refuses fused+# SDPA and runs MATH. torch reads it at the first SDPA dispatch; `setdefault` keeps an explicit "0".+os.environ.setdefault("TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL", "1")+__all__ = ["InferenceBackend","InferenceOrchestrator",diff --git a/studio/backend/tests/test_inference_aotriton_optin.py b/studio/backend/tests/test_inference_aotriton_optin.pynew file mode 100644index 00000000000..bac806085ab--- /dev/null+++ b/studio/backend/tests/test_inference_aotriton_optin.py@@ -0,0 +1,59 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Fresh interpreter per case: torch latches the variable process-wide at the first SDPA dispatch."""++from __future__ import annotations++import os+import subprocess+import sys+from pathlib import Path++import pytest++BACKEND = Path(__file__).resolve().parents[1]+VAR = "TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL"+++def _value_after_import(module: str, preset: str | None) -> str:+ env = {k: v for k, v in os.environ.items() if k != VAR}+ if preset is not None:+ env[VAR] = preset+ code = (+ "import os, sys\n"+ f"sys.path.insert(0, {str(BACKEND)!r})\n"+ f"import {module}\n"+ f"print('VALUE=' + str(os.environ.get({VAR!r})))\n"+ )+ out = subprocess.run(+ [sys.executable, "-c", code], env = env, capture_output = True, text = True, timeout = 120+ )+ assert out.returncode == 0, out.stderr[-2000:]+ line = [ln for ln in out.stdout.splitlines() if ln.startswith("VALUE=")][-1]+ return line.split("=", 1)[1]++[email protected]("module", ["core.inference", "core.inference.chat_eos"])+def test_inference_import_sets_the_optin(module):+ assert _value_after_import(module, None) == "1"++[email protected]("preset", ["0", "1", "false"])+def test_user_value_is_kept(preset):+ assert _value_after_import("core.inference", preset) == preset+++def test_import_does_not_pull_torch():+ env = {k: v for k, v in os.environ.items() if k != VAR}+ code = (+ "import sys\n"+ f"sys.path.insert(0, {str(BACKEND)!r})\n"+ "import core.inference\n"+ "print('TORCH=' + str('torch' in sys.modules))\n"+ )+ out = subprocess.run(+ [sys.executable, "-c", code], env = env, capture_output = True, text = True, timeout = 120+ )+ assert out.returncode == 0, out.stderr[-2000:]+ assert "TORCH=False" in out.stdout