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
for_training flag test: lift every _utils helper for_training reaches (#15493)
Daniel Han48b3e0bcba2c
diff --git a/tests/test_for_training_generation_flag.py b/tests/test_for_training_generation_flag.pyindex 820558c672e..db64bac659b 100644--- a/tests/test_for_training_generation_flag.py+++ b/tests/test_for_training_generation_flag.py@@ -29,7 +29,12 @@ def _helpers_used_by(method, tree):for node in tree.bodyif isinstance(node, ast.FunctionDef) and not node.decorator_list}- wanted, pending = {}, [method]+ return _closure([method], defined)+++def _closure(roots, defined):+ """Every function in `defined` the roots reach by name, transitively."""+ wanted, pending = {}, 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:@@ -78,6 +83,11 @@ def _for_training(module, class_name):"_has_gradient_checkpointing",)]+ # Plus whatever else for_training reaches in _utils (it imports its helpers from there), so a new helper+ # such as _tensor_parallel_for_training is lifted instead of resolving to None.+ utils_defined = {node.name: node for node in utils.body if isinstance(node, ast.FunctionDef)}+ reached = _closure([method, *shared], utils_defined)+ shared += [node for node in reached if node not in shared]for node in shared:node.decorator_list = []compiled = ast.Module(body = shared + _helpers_used_by(method, tree) + [method], type_ignores = [])