[AutoParallel] Refactor qwen2 model in intermediate api #2912
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting
testsfolder. 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 逻辑如下:
在 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 在运行时是在单卡代码模式下,避免跑到动手通信的地方
添加 pretrain 文件,这里会读取运行脚本中的 TrainingArguments、构建 训练数据 和 Trainer,并调用 trainer.train 进行训练。这里当检测到 开启中层api 时,会将 run_single_model 设为 True,并关闭其他并行配置
在 modeling.py 添加中层api配置。新增文件 auto_dist_config.py,这是中层 api 的配置文件,记录每层在不同并行下的切分状态。给 Qwen2ForCausalLM 添加函数 auto_dist_config ,这个函数会在 trainer 初始化时去读取这个配置,并初始化中层api的环境