Skip to content

[Cohere] Fix Cohere2MoE weight loading when using Transformers ≥5.10#44747

Merged
vllm-bot merged 3 commits into
vllm-project:mainfrom
Terrencezzj:cohere2_moe_fix_loading
Jun 9, 2026
Merged

[Cohere] Fix Cohere2MoE weight loading when using Transformers ≥5.10#44747
vllm-bot merged 3 commits into
vllm-project:mainfrom
Terrencezzj:cohere2_moe_fix_loading

Conversation

@Terrencezzj

@Terrencezzj Terrencezzj commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Problem

Cohere2MoeDecoderLayer and Cohere2MoeAttention relied on getattr(config, "first_k_dense_replace", 0) to decide whether a layer uses a dense MLP or MoE.

Under Transformers 5.10+, Cohere2MoeConfig consumes first_k_dense_replace and sets mlp_layer_types = ["dense", "sparse", ...], leaving first_k_dense_replace as None. vLLM then defaulted to 0, built layer 0 as MoE, and failed to load checkpoints with dense layer-0 weights:

KeyError: 'layers.0.mlp.down_proj.weight'

Fix

  • Normalize config in Cohere2MoeModel(before make_layers): if mlp_layer_types is absent, derive it from legacy first_k_dense_replace, otherwise default to all "sparse"
  • add is_prefix_dense_layer()

Test Plan

Test Result

Deterministic generation produces identical output under Transformers 5.9.0 and 5.10.2


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
Signed-off-by: Terrencezzj <terrence@cohere.ai>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Jun 6, 2026
@mergify

mergify Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Hi @Terrencezzj, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

@Terrencezzj

Copy link
Copy Markdown
Contributor Author

Hi @Terrencezzj, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

It's failed because of deepseekv4

@mgoin mgoin added the bug Something isn't working label Jun 9, 2026
@vllm-bot vllm-bot merged commit 3e8afdf into vllm-project:main Jun 9, 2026
53 of 57 checks passed
ekagra-ranjan pushed a commit to ekagra-ranjan/vllm that referenced this pull request Jun 9, 2026
…llm-project#44747)

Signed-off-by: Terrencezzj <terrence@cohere.ai>
Signed-off-by: Ekagra Ranjan <3116519+ekagra-ranjan@users.noreply.github.com>
waqahmed-amd-fi pushed a commit to waqahmed-amd-fi/vllm that referenced this pull request Jun 10, 2026
…llm-project#44747)

Signed-off-by: Terrencezzj <terrence@cohere.ai>
Signed-off-by: Waqar Ahmed <waqar.ahmed@amd.com>
Saddss pushed a commit to Saddss/vllm that referenced this pull request Jun 14, 2026
vivek8123 pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Jun 18, 2026
divineearthly pushed a commit to divineearthly/vllm that referenced this pull request Jun 19, 2026
…llm-project#44747)

Signed-off-by: Terrencezzj <terrence@cohere.ai>
Signed-off-by: divineearthly <divineearthly@gmail.com>
tunglinwood pushed a commit to tunglinwood/vllm that referenced this pull request Jun 22, 2026
nkzhenhua pushed a commit to nkzhenhua/vllm that referenced this pull request Jun 24, 2026
ohsono pushed a commit to ohsono/vllm that referenced this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed

3 participants