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
Precision conflict test: lift every loader.py helper from_pretrained reaches (#15515)
Daniel Han8df1aaf186c4
diff --git a/tests/test_optimized_precision_conflicts.py b/tests/test_optimized_precision_conflicts.pyindex 5d8908b16f2..1ede39ddf1f 100644--- a/tests/test_optimized_precision_conflicts.py+++ b/tests/test_optimized_precision_conflicts.py@@ -44,6 +44,36 @@ def _loader_utils_functions(tree, path, method):]+def _module_definitions(tree):+ """loader.py's own top-level functions and literal constants, by name."""+ defined = {}+ for node in tree.body:+ if isinstance(node, ast.FunctionDef):+ defined[node.name] = node+ elif (+ isinstance(node, ast.Assign)+ and len(node.targets) == 1+ and isinstance(node.targets[0], ast.Name)+ ):+ try:+ ast.literal_eval(node.value)+ except ValueError:+ continue+ defined[node.targets[0].id] = node+ return defined+++def _closure(roots, defined):+ """Every definition in `defined` the roots reach by name, transitively, in source order."""+ wanted, pending = set(), list(roots)+ while pending:+ for node in ast.walk(pending.pop()):+ if isinstance(node, ast.Name) and node.id in defined and node.id not in wanted:+ wanted.add(node.id)+ pending.append(defined[node.id])+ return [node for name, node in defined.items() if name in wanted]++@pytest.fixturedef loader():path = Path(__file__).resolve().parents[1] / "unsloth/models/loader.py"@@ -55,13 +85,6 @@ def loader():n for n in cls.body if isinstance(n, ast.FunctionDef) and n.name == "from_pretrained")method.decorator_list = []- helpers = [- n- for n in tree.body- if isinstance(n, ast.FunctionDef)- and n.name- in ("_precision_flags_conflict", "_modelscope_snapshot_or_none", "_fold_rope_parameters")- ]captured = {"config_calls": 0}def dispatch(**kwargs):@@ -116,6 +139,13 @@ def loader():flags = __future__.annotations.compiler_flag # annotations such as Union stay unevaluatedsource = str(path.parent / "loader_utils.py")exec(compile(ast.Module(body = real, type_ignores = []), source, "exec", flags = flags), env)+ # Every loader.py helper from_pretrained reaches and no stub above replaces, new ones included+ # (a fixed list missed _agree_fast_inference_across_ranks from #15390).+ defined = {name: node for name, node in _module_definitions(tree).items() if name not in env}+ helpers = _closure([method], defined)+ for node in helpers:+ if isinstance(node, ast.FunctionDef):+ node.decorator_list = []exec(compile(ast.Module(body = [*helpers, method], type_ignores = []), str(path), "exec"), env)return env, captured