Skip to content

Conversation

@waliwali777
Copy link
Contributor

@waliwali777 waliwali777 commented Nov 11, 2025

Before submitting

  • Lint code. If there are lint issues, please format the code first.
# Install and register `pre-commit` in the project folder
pip install pre-commit && pre-commit install

# Process previous code files separately
pre-commit run --file XXXX.py
  • Add test cases into tests folder. If there are codecov issues, please add tests cases first.

PR types

Function optimization

PR changes

Models

Description

在重构 trainer ( #2801 )的基础上对 llama 3.1 模型组网接口进行优化
组网统一使用 modeling.py,移除 modeling_network.py 和 modeling_auto.py
该 PR 逻辑如下:

  1. 用户在脚本中开启中层api动半时:

enable_auto_parallel true
use_intermediate_api true

  1. 在 PretrainedConfig 中引入开关 run_single_model,当跑中层api动半时,该开关会被设为开启,并会关闭其他并行配置(将 sharding_parallel_degree、tensor_parallel_degree、sep_parallel_degree、context_parallel_degree 设为1),通过 run_single_model 对 modeling 组网进行 hack,让 modeling.py 在运行时是在单卡代码模式下,避免跑到动手通信的地方

  2. 添加 pretrain 文件,这里会读取运行脚本中的 TrainingArguments、构建 训练数据 和 Trainer,并调用 trainer.train 进行训练。这里当检测到 开启中层api 时,会将 run_single_model 设为 True,并关闭其他并行配置

  3. 在 modeling.py 添加中层api配置。新增文件 auto_dist_config.py,这是中层 api 的配置文件,记录每层在不同并行下的切分状态。给 Qwen2ForCausalLM 添加函数 auto_dist_config ,这个函数会在 trainer 初始化时去读取这个配置,并初始化中层api的环境

@paddle-bot
Copy link

paddle-bot bot commented Nov 11, 2025

Thanks for your contribution!

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 38.88889% with 11 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@3d9d3d2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ddleformers/transformers/qwen2/auto_dist_config.py 33.33% 4 Missing ⚠️
paddleformers/transformers/configuration_utils.py 40.00% 3 Missing ⚠️
paddleformers/transformers/qwen2/modeling.py 50.00% 2 Missing ⚠️
...addleformers/transformers/tensor_parallel_utils.py 33.33% 2 Missing ⚠️

❌ Your patch status has failed because the patch coverage (38.88%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #2912   +/-   ##
==========================================
  Coverage           ?   31.31%           
==========================================
  Files              ?      421           
  Lines              ?    68601           
  Branches           ?        0           
==========================================
  Hits               ?    21481           
  Misses             ?    47120           
  Partials           ?        0           

☔ 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.

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.

2 participants