Repository navigation
Tests: undo the Unsloth load's PEFT LoRA forward swap after the probe memo tests - #16908
Merged
Merged
Conversation
… memo tests test_fastmodel_adapter_load_probes_base_config_once (#16793) runs FastModel.from_pretrained up to the weights, which swaps PEFT's LoRA forwards and sets UNSLOTH_* variables for the whole process. A later test in the same xdist worker then ran on Unsloth's LoRA forward: test_preference_chunked_logprobs::test_matches_trl[cpo-*-qwen3_lora] drifted past its gradient tolerance in Repo tests (CPU, studio). Put both back after every test in test_load_probe_memo.py, and pin stock PEFT in the parity test, whose reference is TRL on stock PEFT.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Repo tests (CPU, studio)has been failing on unrelated PRs since #16793 landed, always in the same test with a different parameter each time:Seen on the staging runs for #16109, #16886, #16882 and #16877 today (
cpo-kwargs1,kwargs2,kwargs3,kwargs5,kwargs6, alwaysqwen3_lora).The cause is test pollution. #16793 added
test_load_probe_memo.py::test_fastmodel_adapter_load_probes_base_config_once, which runsFastModel.from_pretrainedup to the weights. That load does what it does in real use: it swaps PEFT's LoRA forwards (peft.tuners.lora.layer.Linearand 8 other LoRA layer classes) for Unsloth's, process-wide, and setsUNSLOTH_FORCE_FLOAT32,UNSLOTH_FULLGRAPH,UNSLOTH_RETURN_LOGITSandUNSLOTH_MODEL_NAME. The test never puts them back, so when xdist schedules the CPO parity test on the same worker later, it compares the chunked path against TRL on Unsloth's LoRA forward instead of stock PEFT, and its tight gradient tolerance trips. The swapped forward is the part that matters: restoring only the environment variables still fails with the same numbers, restoring only the forwards passes.Neither side's product code is wrong. #16793's loader change and its probe-count assertions are correct; only the test leaks process state.
Change
Tests only.
tests/python/test_load_probe_memo.py: an autouse fixture records every PEFT LoRA layer class's ownforwardand theUNSLOTH_*variables before each test and puts them back after. A PEFT module first imported during the load falls back to the_unsloth_original_forwardthe wrapper carries.tests/python/test_preference_chunked_logprobs.py:test_matches_trl[...-qwen3_lora]pins stock PEFT forwards for its duration (throughmonkeypatch), since its reference is TRL on stock PEFT. This keeps it deterministic whatever else ran earlier in the worker.Testing
The failing worker's exact history from a local rerun of the CI shard (
-n 4 --dist loadgroup) replayed serially reproduces the CI failure with the same numbers, and bisects to the #16793 test. With that test followed bytest_matches_trl[cpo-kwargs1-qwen3_lora]:3.814697265625e-06 at index (0, 6), as in CI)The same failing worker's history replayed serially (1595 tests) on this branch:
test_matches_trl[cpo-kwargs1-qwen3_lora]passes. On main the same replay fails it. One other failure in both arms,test_cached_paths_hold_no_credentials.py::test_model_cache_variables_are_not_treated_as_credential_homes, comes from this machine's environment; it passes in CI and is unchanged here.Both touched files pass in full:
tests/python/test_load_probe_memo.pyplustests/python/test_preference_chunked_logprobs.py, 33 passed (torch 2.10.0+cpu, transformers 5.17.0, TRL 1.15.0, PEFT 0.21.2, the CI shard's versions).