Skip to content

use self.hidden_size not use self.fd_config.model_config.hidden_size#7340

Merged
zhoutianzi666 merged 3 commits intoPaddlePaddle:developfrom
zhoutianzi666:rename_hidden_size
Apr 11, 2026
Merged

use self.hidden_size not use self.fd_config.model_config.hidden_size#7340
zhoutianzi666 merged 3 commits intoPaddlePaddle:developfrom
zhoutianzi666:rename_hidden_size

Conversation

@zhoutianzi666
Copy link
Copy Markdown
Collaborator

@zhoutianzi666 zhoutianzi666 commented Apr 11, 2026

📋 Review 摘要

PR 概述:优化 MoE 层代码,使用缓存的 self.hidden_size 属性替代直接访问嵌套配置

变更范围fastdeploy/model_executor/layers/moe/moe.pytests/distributed/chunked_moe.py

影响面 Tag[Optimization]

📝 PR 规范检查

PR 标题和描述未完全遵循项目规范:

  1. 标题缺少 Tag:根据 checklist,PR 标题必须包含有效的 [Tag]
  2. 描述未填写 Motivation/Modifications:这两个章节需要说明变更的目的和具体改动

标题建议(可直接复制):

  • [Optimization] use self.hidden_size not use self.fd_config.model_config.hidden_size

描述模板(可直接复制):

## Motivation

优化 `forward_chunked_moe` 方法中的属性访问,避免每次调用时遍历嵌套对象 `self.fd_config.model_config.hidden_size`,改用已在 `__init__` 中缓存的 `self.hidden_size` 属性,提高代码可读性和性能。

## Modifications

1.`forward_chunked_moe` 中的 `self.fd_config.model_config.hidden_size` 替换为 `self.hidden_size`
2. 测试文件 `chunked_moe.py` 中补充 `hidden_size` 属性初始化(因为使用 `__new__` 创建对象时不会调用 `__init__`

问题

级别 文件 概述
🟡 建议 PR 标题/描述 缺少 [Tag] 和 Motivation/Modifications 填写

总体评价

代码变更本身是正确的优化性重构。self.hidden_sizeFusedMoE.__init__ 第 207 行已正确初始化,替换后避免了重复访问嵌套配置,有利于提高代码可读性和性能。测试文件中同步添加了属性初始化,确保单元测试正常运行。建议完善 PR 标题和描述后合并。

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 11, 2026

Thanks for your contribution!

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


“liuruian” seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

PaddlePaddle-bot

This comment was marked as outdated.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 11, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7340   +/-   ##
==========================================
  Coverage           ?   74.03%           
==========================================
  Files              ?      383           
  Lines              ?    53636           
  Branches           ?     8412           
==========================================
  Hits               ?    39707           
  Misses             ?    11231           
  Partials           ?     2698           
Flag Coverage Δ
GPU 74.03% <ø> (?)

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.

@zhoutianzi666 zhoutianzi666 changed the title commit use self.hidden_size not use Apr 11, 2026
PaddlePaddle-bot

This comment was marked as outdated.

@zhoutianzi666 zhoutianzi666 changed the title use self.hidden_size not use use self.hidden_size not use self.fd_config.model_config.hidden_size Apr 11, 2026
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.

📋 Review 摘要

PR 概述:优化 MoE 层代码,使用缓存的 self.hidden_size 属性替代直接访问嵌套配置

变更范围fastdeploy/model_executor/layers/moe/moe.pytests/distributed/chunked_moe.py

影响面 Tag[Optimization]

📝 PR 规范检查

PR 标题和描述未完全遵循项目规范:

  1. 标题缺少 Tag:根据 checklist,PR 标题必须包含有效的 [Tag]
  2. 描述未填写 Motivation/Modifications:这两个章节需要说明变更的目的和具体改动

标题建议(可直接复制):

  • [Optimization] use self.hidden_size not use self.fd_config.model_config.hidden_size

描述模板(可直接复制):

## Motivation

优化 `forward_chunked_moe` 方法中的属性访问,避免每次调用时遍历嵌套对象 `self.fd_config.model_config.hidden_size`,改用已在 `__init__` 中缓存的 `self.hidden_size` 属性,提高代码可读性和性能。

## Modifications

1.`forward_chunked_moe` 中的 `self.fd_config.model_config.hidden_size` 替换为 `self.hidden_size`
2. 测试文件 `chunked_moe.py` 中补充 `hidden_size` 属性初始化(因为使用 `__new__` 创建对象时不会调用 `__init__`

问题

级别 文件 概述
🟡 建议 PR 标题/描述 缺少 [Tag] 和 Motivation/Modifications 填写

总体评价

代码变更本身是正确的优化性重构。self.hidden_sizeFusedMoE.__init__ 第 207 行已正确初始化,替换后避免了重复访问嵌套配置,有利于提高代码可读性和性能。测试文件中同步添加了属性初始化,确保单元测试正常运行。建议完善 PR 标题和描述后合并。

Copy link
Copy Markdown
Collaborator

@chang-wenbin chang-wenbin left a comment

Choose a reason for hiding this comment

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

LGTM

@zhoutianzi666 zhoutianzi666 merged commit 225fc8d into PaddlePaddle:develop Apr 11, 2026
35 of 38 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.

5 participants