Repository navigation
Add longcat_flash_lsa to the fused-MoE conversion snapshot - #12018
Merged
Merged
Conversation
#11620 registers longcat_flash_lsa into transformers' and peft's _MODEL_TO_CONVERSION_PATTERN with longcat_flash's family when its conversions are set up. In any process where tests/test_longcat_lsa.py has run first, the live map carries that type, and test_the_moe_snapshot_matches_the_installed_transformers fails because the snapshot does not. Whether it fails depends on which xdist worker gets which test. The snapshot now lists it with longcat_flash's family, and a new test checks unsloth's own registration against the snapshot directly, so the pairing is checked in every order.
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. Nice work! 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". |
shaojun
pushed a commit
to shaojun/unsloth
that referenced
this pull request
Sep 29, 2026
…#12018) unslothai#11620 registers longcat_flash_lsa into transformers' and peft's _MODEL_TO_CONVERSION_PATTERN with longcat_flash's family when its conversions are set up. In any process where tests/test_longcat_lsa.py has run first, the live map carries that type, and test_the_moe_snapshot_matches_the_installed_transformers fails because the snapshot does not. Whether it fails depends on which xdist worker gets which test. The snapshot now lists it with longcat_flash's family, and a new test checks unsloth's own registration against the snapshot directly, so the pairing is checked in every order.
danielhanchen
added a commit
that referenced
this pull request
Oct 15, 2026
`pinned-symbol matrix (vLLM, TRL, PEFT, ST, bitsandbytes, transformers)` fails on any PR that runs it (seen on #13851, on main e1cdbf4): ``` FAILED tests/version_compat/test_peft_conversion_symbol_backfill.py::test_the_fused_snapshot_matches_upstream AssertionError: fused MoE types missing from the snapshot: ['UnlimitedOcrTextModel'] ``` That test is the canary against transformers main's `conversion_mapping._MODEL_TO_CONVERSION_PATTERN`, which now carries `"UnlimitedOcrTextModel": "qwen2_moe"` (the unlimited_ocr text model, a fused qwen2_moe-family MoE). The canary is right; this is the same kind of upkeep as #12018 (longcat_flash_lsa). Two changes in `unsloth/import_fixes.py`: 1. The entry goes into `_PEFT_MOE_CONVERSION_PATTERNS`. 2. Unlike every existing entry it is keyed by class name, not by a lowercase model type, and `_UnavailableConversionPatternMap._is_moe` lowercased the key before the snapshot lookup. So the snapshot entry alone would not have helped: with the map gone, `get("UnlimitedOcrTextModel")` would still lowercase to `unlimitedocrtextmodel`, miss the snapshot, find no `moe`/`mixtral` hint in the name, and return a silent `None`, which is the mis-conversion the stand-in exists to refuse. `_is_moe` now checks the key as given as well as lowercased. New test `test_a_fused_class_name_alias_is_refused_in_its_own_case` pins both halves. Verification (`tests/version_compat/test_peft_conversion_symbol_backfill.py`, transformers 5.18.0 installed, upstream map fetched live): - main: the upstream canary fails as above. - With this change: 68 passed. - Sabotage, entry removed: the canary and the new test fail. - Sabotage, entry kept but `_is_moe` back to the lowercase-only lookup: the new test fails (the stand-in returns `None` for the class name). - Formatted with `scripts/run_ruff_format.py`.
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.
Problem
tests/version_compat/test_peft_conversion_symbol_backfill.py::test_the_moe_snapshot_matches_the_installed_transformersfails depending on test order:I hit it in one of two local full
tests/runs on main under-n 8, with no code change in between. The difference was only which worker got which test. Both files are inRepo tests (CPU, rest), so CI can hit it too.Cause
#11620 (LongCat-Flash-Lite-Sparse) registers its own model type,
longcat_flash_lsa, into transformers' and peft's_MODEL_TO_CONVERSION_PATTERNwithlongcat_flash's family (_register_conversionsinunsloth/models/longcat_lsa.py). The drift test comparesimport_fixes._PEFT_MOE_CONVERSION_PATTERNSagainst that live table. Once the registration has run in the same process, the table holds a fused-MoE type the snapshot has never heard of.Which side is wrong
The snapshot. The test's contract is that the snapshot agrees with the live map, and unsloth itself is what puts the new entry in that map, so the snapshot has to carry it. The registration in #11620 is correct. The snapshot is also what
_ConversionMapStandInuses to decide which lookups are fused MoE on a transformers without a conversion map.longcat_flash_lsashould get the same clear error aslongcat_flashthere, not a silentNone.Fix
longcat_flash_lsa: qwen2_moejoins the snapshot, next tolongcat_flash, with a comment on where it comes from.test_the_snapshot_covers_the_types_unsloth_registers_itselfchecks the pairing directly.longcat_lsa.pystill registers that type fromlongcat_flash, and the snapshot gives the two the same family. So a registration the snapshot does not know about fails in every order, not only when the workers happen to line up.Verification
tests/test_longcat_lsa.py+test_peft_conversion_symbol_backfill.pytogether: 1 failure on main, 85 passed here.test_peft_conversion_symbol_backfill.pyalone: 66 passed.import_fixes.py: the drift test (after the LongCat tests) and the new test fail (2 failed).