Skip to content

Add longcat_flash_lsa to the fused-MoE conversion snapshot - #12018

Merged
danielhanchen merged 1 commit into
mainfrom
moe-snapshot-covers-longcat-lsa
Sep 26, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
moe-snapshot-covers-longcat-lsa

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

tests/version_compat/test_peft_conversion_symbol_backfill.py::test_the_moe_snapshot_matches_the_installed_transformers fails depending on test order:

$ pytest tests/version_compat/test_peft_conversion_symbol_backfill.py -k moe_snapshot
1 passed
$ pytest tests/test_longcat_lsa.py tests/version_compat/test_peft_conversion_symbol_backfill.py
FAILED ...::test_the_moe_snapshot_matches_the_installed_transformers
    AssertionError: fused MoE model types missing from the snapshot: ['longcat_flash_lsa']

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 in Repo 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_PATTERN with longcat_flash's family (_register_conversions in unsloth/models/longcat_lsa.py). The drift test compares import_fixes._PEFT_MOE_CONVERSION_PATTERNS against 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 _ConversionMapStandIn uses to decide which lookups are fused MoE on a transformers without a conversion map. longcat_flash_lsa should get the same clear error as longcat_flash there, not a silent None.

Fix

  • longcat_flash_lsa: qwen2_moe joins the snapshot, next to longcat_flash, with a comment on where it comes from.
  • New test_the_snapshot_covers_the_types_unsloth_registers_itself checks the pairing directly. longcat_lsa.py still registers that type from longcat_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.py together: 1 failure on main, 85 passed here.
  • test_peft_conversion_symbol_backfill.py alone: 66 passed.
  • With main's import_fixes.py: the drift test (after the LongCat tests) and the new test fail (2 failed).

#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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 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-26T10:41:18.974623Z 61e0781 Manual request
🔒 Security Review ⚠️ Failed 2026-09-26T10:40:10.108385Z 61e0781 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 61e0781e1f

ℹ️ 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 76b6cab into main Sep 26, 2026
27 of 28 checks passed
@danielhanchen
danielhanchen deleted the moe-snapshot-covers-longcat-lsa branch September 26, 2026 10:43
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`.
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