Skip to content

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.

Tests: load the helpers ORPO rewriter constants are built with (#15296)

Daniel Han9b98bb94938a
diff --git a/tests/python/test_orpo_processor_text_tokenizer.py b/tests/python/test_orpo_processor_text_tokenizer.py
index d191b4e139b..df6d6cf9944 100644
--- a/tests/python/test_orpo_processor_text_tokenizer.py
+++ b/tests/python/test_orpo_processor_text_tokenizer.py
@@ -13,11 +13,22 @@ def _load_orpo_rewriter(name = "orpo_trainer_text_tokenizer"):
src = open(RL_PATH, encoding = "utf-8").read()
tree = ast.parse(src)
ns = {"re": re}
+ private = [
+ node
+ for node in tree.body
+ if isinstance(node, ast.Assign)
+ and any(isinstance(t, ast.Name) and t.id.startswith("_") for t in node.targets)
+ ]
+ # Some private constants are built by a module-level helper (e.g. _fused_pass_logps_re).
+ called = {
+ call.func.id
+ for node in private
+ for call in ast.walk(node.value)
+ if isinstance(call, ast.Call) and isinstance(call.func, ast.Name)
+ }
for node in tree.body:
- if isinstance(node, ast.Assign):
- for target in node.targets:
- if isinstance(target, ast.Name) and target.id.startswith("_"):
- exec(ast.get_source_segment(src, node), ns)
+ if node in private or (isinstance(node, ast.FunctionDef) and node.name in called):
+ exec(ast.get_source_segment(src, node), ns)
for node in tree.body:
if isinstance(node, ast.FunctionDef) and node.name == name:
exec(ast.get_source_segment(src, node), ns)