Skip to content

ORPO text-tokenizer test: lift the helpers its rl_replacements constants call - #15262

Closed
lonexreb wants to merge 3 commits into
unslothai:mainfrom
lonexreb:fix/orpo-lifter-defines-underscore-helpers
Closed

lonexreb wants to merge 3 commits into
unslothai:mainfrom
lonexreb:fix/orpo-lifter-defines-underscore-helpers

Conversation

@lonexreb

Copy link
Copy Markdown
Contributor

Problem

tests/python/test_orpo_processor_text_tokenizer.py::_load_orpo_rewriter execs every module-level _ constant of rl_replacements.py into a namespace that holds only re. Since #14185 (e6a58b7) three of those constants are built by a helper:

_KTO_LOGPS_RE = _fused_pass_logps_re(_KTO_IDS, _KTO_MASK)
_DPO_REF_LOGPS_RE = _fused_pass_logps_re(_DPO_REF_IDS, _DPO_REF_MASK)
_KTO_REF_LOGPS_RE = _fused_pass_logps_re(...)

so the lifter raises NameError: name '_fused_pass_logps_re' is not defined before it reaches the rewriter, and all six tests in the file fail. This is the Repo tests (CPU, studio) red on #15245 (merge base 674f7f4, after #14185) and it reproduces on current main (db1e8d9). Main's own studio shard has not reported since #14185 landed: every main run after it was cancelled by the next push.

Fix

Before exec'ing a _ constant, exec any _ helper its expression names (and not yet defined). Only the referenced helpers: exec'ing every _ function evaluates default arguments such as DEVICE_TYPE_TORCH, which the lifter's namespace does not have.

Verification

python -m pytest tests/python/test_orpo_processor_text_tokenizer.py: 6 failed with NameError on main, 6 passed with this change. No other test lifts rl_replacements constants this way (grep -rl 'target.id.startswith("_")' tests/).

🤖 Generated with Claude Code

…nts call

_load_orpo_rewriter execs every module-level `_` constant of rl_replacements.py
into a namespace holding only `re`. Since e6a58b7 (unslothai#14185) three of those
constants are built by a helper (_KTO_LOGPS_RE = _fused_pass_logps_re(...)),
so the lifter raises NameError before reaching the rewriter and all six tests
in the file fail (main's "Repo tests (CPU, studio)" shard since 10:16Z; every
main run after it was cancelled by the next push, so the shard never reported).

Exec a `_` helper a constant's expression names before that constant. Only the
referenced helpers: defining every `_` function evaluates default arguments
such as DEVICE_TYPE_TORCH, which the namespace does not have.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@lonexreb

Copy link
Copy Markdown
Contributor Author

Closing: superseded by 9b98bb9 (#15296), which loads the helpers the rewriter constants are built with.

@lonexreb lonexreb closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant