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
MXFP4 dequantize branch test: run the locals the branch reads ahead of it (#15558)
Daniel Han3c1a0b8c2c26
diff --git a/tests/test_mxfp4_lora_packed_experts_dequantize.py b/tests/test_mxfp4_lora_packed_experts_dequantize.pyindex dcb3f271e52..7513ca09eb7 100644--- a/tests/test_mxfp4_lora_packed_experts_dequantize.py+++ b/tests/test_mxfp4_lora_packed_experts_dequantize.py@@ -43,6 +43,33 @@ def _dequantize_branch():return found[0]+def _locals_read_by(branch):+ """`name = ...` statements ahead of `branch` in each block enclosing it within its function,+ outermost first, whose name the branch reads (e.g. `_fp8_full_finetune` from #15367)."""+ parents = {child: node for node in ast.walk(TREE) for child in ast.iter_child_nodes(node)}+ read = {+ n.id for n in ast.walk(branch) if isinstance(n, ast.Name) and isinstance(n.ctx, ast.Load)+ }+ levels, node = [], branch+ while node in parents and not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):+ parent = parents[node]+ for _, value in ast.iter_fields(parent):+ if isinstance(value, list) and any(stmt is node for stmt in value):+ ahead = value[: next(i for i, stmt in enumerate(value) if stmt is node)]+ levels.append(+ [+ stmt+ for stmt in ahead+ if isinstance(stmt, ast.Assign)+ and len(stmt.targets) == 1+ and isinstance(stmt.targets[0], ast.Name)+ and stmt.targets[0].id in read+ ]+ )+ node = parent+ return [stmt for level in reversed(levels) for stmt in level]++class _Mxfp4Config:def __init__(self,@@ -197,7 +224,9 @@ def _run_branch("auto_config": types.SimpleNamespace(num_hidden_layers = 24),}node = _dequantize_branch()- code = ast.Module(body = [node], type_ignores = [])+ # The branch's own locals, computed from the inputs above; a stub given here wins.+ lifted = [stmt for stmt in _locals_read_by(node) if stmt.targets[0].id not in ns]+ code = ast.Module(body = [*lifted, node], type_ignores = [])ast.fix_missing_locations(code)exec(compile(code, str(VISION), "exec"), ns)return ns["quantizer_kwargs"].get("dequantize", False)