Skip to content

Let the composite renaming tests run inside the transformers 5.4 window - #11572

Merged
danielhanchen merged 3 commits into
mainfrom
fix/composite-renaming-tests-inside-the-window
Sep 22, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix/composite-renaming-tests-inside-the-window

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Repo tests (CPU, rest) is red on every recent PR (#11559, #11558, #11555, #11553, #11528) with five failures in tests/test_composite_prefix_renaming.py and tests/test_import_fixes_drift.py. Those tests came in with #11452. That lane installs transformers>=4.51,<5.5 (studio-backend-ci.yml:297, pinned since #5298), which resolves to 5.4.0, the exact release the repair targets. #11452's run of that lane was cancelled, so it merged without a verdict at that pin.

Reproduced on main f39470176 with transformers 5.4.0: 5 failed. With 5.17.0: all pass.

fix_transformers_composite_prefix_renaming itself is correct. On 5.4.0 it installs at import, and unsloth_zoo's moe_utils_bnb4bit wrapper then sits on top of it. The tests are what fail:

Test Why it failed on 5.4.0 Now
test_transformers_scopes_a_submodules_conversion_mapping Failed whenever the probe answered "unscoped", which is the correct answer on 5.4.0 Fails if the probe answers "unscoped" on a release carrying upstream PR #45567 (the probe drifted), or if no repair from either package is live inside the window
test_installation_is_gated_on_the_probe Read the flag off the top function only, but zoo's MoE wrapper is on top and publishes no __wrapped__ Walks the chain by both links (_composite_prefix_renaming_repaired)
test_the_patch_is_idempotent_and_undoable, test_the_patch_rebinds_the_copies_other_modules_imported, test_a_vllm_module_holding_its_own_copy_is_rebound forced_install measured installs starting from whatever the import left live, which already contained the repair, so it declined ("the repair declined", 'function' object has no attribute '__wrapped__') forced_install starts from the bare upstream function

forced_install does that swap through monkeypatch, not by assignment. Fixture teardown is LIFO, so a test that also monkeypatches get_model_conversion_mapping (test_a_module_holding_the_pre_zoo_function_is_still_rebound) would otherwise restore the stripped function after the fixture's finally, and leave the repair uninstalled for every test after it. That ordering failure was reproduced before the change and is gone after it.

Verification

  • transformers 5.4.0: 77 passed, 11 skipped, in file order, in reverse order, and under -n 4
  • transformers 5.17.0: 76 passed, 12 skipped, in the same three runs
  • Sabotage, on 5.4.0 with both unsloth's and unsloth_zoo's copies of the repair disabled: the gate and drift tests fail. With only unsloth's disabled they pass, correctly, because zoo's copy is live.
  • Sabotage: the drift test run on 5.4.0 with transformers.__version__ faked to 5.6.0 fails with the probe-drift message.

Also: stand-in modules on transformers 4.x

On transformers 4.x, importing unsloth installs inert stand-ins for transformers.core_model_loading and transformers.conversion_mapping so peft can import. _weight_renaming() and _conversion_mapping() found them, and at 4.57.6 four tests ran against them and failed (test_a_renaming_that_lands_off_the_map_is_destructive, test_rescoped_renaming_matches_upstreams_doubled_prefix_semantics, test_a_non_composite_model_is_untouched, test_a_module_holding_the_pre_zoo_function_is_still_rebound). No lane pins 4.x for these files today, but zoo's copy of the same tests is red on exactly this (unslothai/unsloth-zoo#1345). Both helpers now skip a module that is not a file on disk.

transformers before after
4.57.6 4 failed, 63 passed, 21 skipped 48 passed, 40 skipped
5.4.0 5 failed, 72 passed, 11 skipped 77 passed, 11 skipped
5.17.0 76 passed, 12 skipped 76 passed, 12 skipped

The Repo tests (CPU, rest) lane pins transformers<5.5 and so installs 5.4.0,
the exact release fix_transformers_composite_prefix_renaming exists for. #11452
added five tests there whose own lane was cancelled before it reported, and all
five fail on main at that pin:

- the drift test failed whenever the probe answered unscoped, which on 5.4.0 is
  the expected answer. It now fails when the probe answers unscoped on a
  release that ships upstream's fix (the probe drifted), or when no repair,
  unsloth's or unsloth_zoo's, is live inside the window.
- the install gate read only the top of the chain. unsloth_zoo's MoE wrapper
  sits on top of the repair and publishes no __wrapped__, so a live repair
  read as missing. It now walks the chain by both links.
- forced_install measured installs from whatever the import left live, where
  the repair is already in the chain and declines. It now starts from the
  bare upstream function, through monkeypatch so a test that monkeypatches the
  same attribute cannot restore the stripped function on teardown.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T18:02:21.044025Z 2fd03a4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

On transformers 4.x, importing unsloth installs inert stand-ins for
transformers.core_model_loading and transformers.conversion_mapping so peft
can import. The helpers found them and ran four tests against a WeightRenaming
that renames nothing; at 4.57.6 those four fail. A real module is a file on
disk, and the stand-ins are not.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 2fd03a4fb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen
danielhanchen merged commit 30868af into main Sep 22, 2026
34 of 37 checks passed
@danielhanchen
danielhanchen deleted the fix/composite-renaming-tests-inside-the-window branch September 22, 2026 19:10
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ow (unslothai#11572)

* Let the composite renaming tests run inside the transformers 5.4 window

The Repo tests (CPU, rest) lane pins transformers<5.5 and so installs 5.4.0,
the exact release fix_transformers_composite_prefix_renaming exists for. unslothai#11452
added five tests there whose own lane was cancelled before it reported, and all
five fail on main at that pin:

- the drift test failed whenever the probe answered unscoped, which on 5.4.0 is
  the expected answer. It now fails when the probe answers unscoped on a
  release that ships upstream's fix (the probe drifted), or when no repair,
  unsloth's or unsloth_zoo's, is live inside the window.
- the install gate read only the top of the chain. unsloth_zoo's MoE wrapper
  sits on top of the repair and publishes no __wrapped__, so a live repair
  read as missing. It now walks the chain by both links.
- forced_install measured installs from whatever the import left live, where
  the repair is already in the chain and declines. It now starts from the
  bare upstream function, through monkeypatch so a test that monkeypatches the
  same attribute cannot restore the stripped function on teardown.

* Skip the composite renaming tests on unsloth's own stand-in modules

On transformers 4.x, importing unsloth installs inert stand-ins for
transformers.core_model_loading and transformers.conversion_mapping so peft
can import. The helpers found them and ran four tests against a WeightRenaming
that renames nothing; at 4.57.6 those four fail. A real module is a file on
disk, and the stand-ins are not.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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