Skip to content

[Cherry-Pick] [FDConfig] Unify num_experts_per_tok to moe_k in ModelConfig for MoE model compatibility(#7509)#7517

Merged
CSWYF3634076 merged 2 commits into
PaddlePaddle:release/2.6from
xyxinyang:release/2.6
Apr 21, 2026
Merged

[Cherry-Pick] [FDConfig] Unify num_experts_per_tok to moe_k in ModelConfig for MoE model compatibility(#7509)#7517
CSWYF3634076 merged 2 commits into
PaddlePaddle:release/2.6from
xyxinyang:release/2.6

Conversation

@xyxinyang
Copy link
Copy Markdown
Collaborator

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

Unify num_experts_per_tok to moe_k in ModelConfig for MoE model compatibility. This enables R3 support for models like Qwen3VLMOE, DeepSeek V3, and other MoE models that use num_experts_per_tok instead of moe_k in their config.

Modifications

  • Added unified field mapping in ModelConfig (fastdeploy/config.py)

Usage or Command

N/A

Accuracy Tests

N/A

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Apr 20, 2026

Thanks for your contribution!

PaddlePaddle-bot

This comment was marked as outdated.

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review | 2026-04-21 12:16:15

📋 Review 摘要

PR 概述:将 MoE 模型 config 中的 num_experts_per_tok 统一映射到 moe_k,使 ERNIE 4.5 MoE 等使用 moe_k 的模型能兼容 Qwen3VLMOE、DeepSeek V3 等使用 num_experts_per_tok 的模型配置。
变更范围fastdeploy/config.pyModelConfig.override_name_from_config() 方法
影响面 Tag[FDConfig]

问题

未发现阻塞性问题。

总体评价

变更简洁、安全,与现有的 num_expertsmoe_num_expertsn_routed_expertsmoe_num_experts 等字段映射模式保持一致。hasattr 双重检查保证了向后兼容性——仅在 config.json 包含 num_experts_per_tok 且缺少 moe_k 时才做映射,不会影响已有模型的加载行为。

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release/2.6@f4f7760). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.6    #7517   +/-   ##
==============================================
  Coverage               ?   73.57%           
==============================================
  Files                  ?      376           
  Lines                  ?    53000           
  Branches               ?     8280           
==============================================
  Hits                   ?    38995           
  Misses                 ?    11260           
  Partials               ?     2745           
Flag Coverage Δ
GPU 73.57% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CSWYF3634076 CSWYF3634076 merged commit 95261f0 into PaddlePaddle:release/2.6 Apr 21, 2026
34 of 37 checks passed
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.

4 participants