Skip to content

Load Qwen2.5-Omni checkpoints that name Qwen2_5OmniModel - #13087

Merged
danielhanchen merged 3 commits into
mainfrom
fix-qwen25-omni-model-arch
Oct 9, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix-qwen25-omni-model-arch

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Fixes #2325

Every official Qwen2.5-Omni checkpoint (Qwen/Qwen2.5-Omni-3B, Qwen/Qwen2.5-Omni-7B and the unsloth/Qwen2.5-Omni-* mirrors) names its architecture Qwen2_5OmniModel in config.json, a name from the pre-release transformers branch, and keeps its vision config under thinker_config. FastModel decides "is this a VLM" from an architecture ending in ForConditionalGeneration or a top-level vision_config, so these checkpoints were treated as text models and sent to AutoModelForCausalLM, which has no mapping for Qwen2_5OmniConfig:

ValueError: Unrecognized configuration class <class 'transformers.models.qwen2_5_omni.configuration_qwen2_5_omni.Qwen2_5OmniConfig'> for this kind of AutoModel: AutoModelForCausalLM.

This affects FastModel, FastLanguageModel and FastVisionModel alike. A checkpoint that names Qwen2_5OmniForConditionalGeneration (for example hf-internal-testing/tiny-random-Qwen2_5OmniForConditionalGeneration) already loaded and trained, so the rest of the Omni path (thinker hand-off, processor, LoRA on the text core) is already in place; only the routing missed.

Change

_has_vision_config also looks one level down at thinker_config.vision_config, and both VLM checks in FastModel.from_pretrained use it. Configs without a thinker_config evaluate exactly as before.

Evidence

unsloth/Qwen2.5-Omni-3B, LoRA r=8 on the 7 text projections, 10 SFT steps of a small text dataset, then greedy text generation (return_audio=False), on a B200, transformers 5.17.0, torch 2.13, TRL 0.25.1, PEFT 0.21.2:

Loader main this PR
FastModel(load_in_4bit=True) (the issue's call) ValueError above loads, losses 2.560 -> 1.247, 252/252 text LoRA B changed, generates " 6."
FastLanguageModel 16 bit ValueError above loads, losses 2.660 -> 1.259, 252/252 changed, generates " 6."
FastVisionModel(load_in_4bit=True) ValueError above loads, losses 2.560 -> 1.247, generates " 6."
FastLanguageModel(fast_inference=True) AttributeError: 'Qwen2_5OmniConfig' object has no attribute 'vocab_size' clear "Fast inference is only supported for ... vision model types" error (vLLM fast inference for Qwen2.5-Omni is not added here)

Parity against plain transformers + PEFT on the thinker (same data, seed, LoRA targets, 14,966,784 trainable parameters on both sides):

Step 1 loss Step 1 grad norm
transformers + PEFT (padding_free=True) 2.650 5.552
Unsloth FastLanguageModel 16 bit 2.660 5.619

Forward loss on two fixed sequences, no training: transformers 3.7117 / 3.4589, Unsloth 3.7150 / 3.4600.

Tests: the new test_qwen2_5_omni_routes_to_a_multimodal_class[Qwen2_5OmniModel] fails on main and passes here; the ForConditionalGeneration case and a plain Qwen2ForCausalLM checkpoint route as before. The 33 loader / vision / omni / processor test files give 444 passed on main and 447 passed here (the 3 new tests), with no failures on either side.

@danielhanchen danielhanchen self-assigned this Oct 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 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-10-08T17:12:21.981822Z d54636c Manual request
🔒 Security Review ⚠️ Failed 2026-10-08T16:07:45.400119Z 0f5346f 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 0f5346f1f7

ℹ️ 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

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: d54636c0f4

ℹ️ 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 9656b58 into main Oct 9, 2026
@danielhanchen
danielhanchen deleted the fix-qwen25-omni-model-arch branch October 9, 2026 12:11
danielhanchen added a commit that referenced this pull request Oct 10, 2026
…uting merges (#13173)

* Fix the two Backend CI test failures on main after the branch-restore and Omni routing merges

test_new_chat_context_recount: #13109 made the history restore estimate the
selected branch (estimateContextUsage(branch)) instead of every stored row.
The product change is right; the harness that replays the sliced restore did
not bind the loader's new `branch` local, so every history-hydration case
threw "branch is not defined", and the binding guard's self-check still
pinned `msgs`. Bind `branch` with the real orderBySelectedBranch and
resolveSavedBranchHead from message-order.ts, the way the loader computes it
without a saved head, and make the guard's self-check require only the
destructured remoteId plus one plain local, not a specific input of the
block.

test_omni_text_only_load: #13087's _route tests call FastModel.from_pretrained,
which repoints transformers' LOSS_MAPPING at Unsloth's Triton loss for the
whole process before the route is captured, and never undo it. Any Omni
forward with labels later in that xdist worker then ran Triton on the CPU
runner ("0 active drivers"), so 0 to 4 of these tests failed depending on
scheduling. Stub patch_loss_functions in _route, which routing does not need,
and have the Omni tests use transformers' own causal-LM loss on a CPU host so
another leaker cannot break them; on a GPU host they keep Unsloth's loss.

* Restore the whole loss mapping after each Omni test, and sort the harness messages like the loader

The Omni fixture now snapshots LOSS_MAPPING, installs transformers' own loss
for the test body on CPU, and puts the full snapshot back afterwards, so a
load inside the test (_capture_fast_base_kwargs) cannot leave the Triton loss
behind for the next test in the worker.

The recount harness sorts the stored messages by createdAt, role and id
before taking msgs.at(-1) as the fallback head, as runtime-provider.tsx does,
so an unsorted fixture cannot price a branch the loader would not select.
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.

[Feature] Qwen 2.5-Omni Support?

1 participant