mindspore-ai / mindspore-ai/hyper-parallel
【RFC】 自动并行策略搜索 Dense LLM 调优能力支持
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 53
- Forks
- 63
- Avg merge
- 23h 45m
- Merged PRs (30d)
- 63
Description
自动并行策略搜索 Dense LLM 调优能力支持
本文档描述 Dense LLM 场景下自动并行策略调优能力的设计需求。不包含具体代码实现,侧重配置读取、多维估算模块整合、候选策略生成、约束过滤、性能排序、top-k 策略输出、可视化图表与端到端可解释调优能力。
1. 背景
配置读取、DP/TP/PP/CP 等估算模块分别提供了自动并行策略搜索所需的输入和代价模型。对于 Dense LLM 场景,需要进一步将这些模块串联起来,形成端到端可用、可解释的并行策略寻优方案。
该能力需要完成候选策略枚举、约束过滤、内存估算、性能估算、候选排序、top-k 策略输出和可视化展示,使用户可以在给定模型、集群和约束条件下,直接获得可执行或可参考的并行策略,并通过图表理解不同策略之间的显存、性能和可行性差异。
2. 目标与非目标
2.1 目标
- 支持 Dense LLM 场景下的自动并行策略调优;
- 整合配置读取、多维内存估算和多维性能估算模块;
- 支持根据配置和用户限定搜索空间生成候选策略;
- 支持对候选策略做基础约束过滤;
- 支持调用 DP/TP/PP/CP 等估算模块;
- 支持汇总 memory cost 和 performance cost;
- 支持根据显存约束过滤不可行策略;
- 支持对可行策略排序;
- 支持输出 top-k 候选策略;
- 支持输出过滤原因、估算分解和可视化图表,辅助用户理解策略选择结果;
- 支持形成端到端可用、可解释的并行策略寻优方案;
- 补充端到端集成测试和文档说明。
2.2 非目标
- 本 issue 不实现具体维度的估算公式;
- 本 issue 不实现新的 runtime;
- 本 issue 不保证搜索算法全局最优;
- 本 issue 不负责策略实际执行和训练启动;
- 本 issue 不实现 profiling 自动闭环;
- 本 issue 不覆盖 MoE / EP 场景,EP 相关能力由 Expert Parallelism 估算子 issue 负责。
3. 主流程设计
Dense LLM 自动并行策略调优流程包括:
- 读取标准化配置和用户限定搜索空间;
- 根据 search_space_config 生成候选策略;
- 对候选策略进行整除约束过滤;
- 对候选策略进行设备数和资源约束过滤;
- 调用 DP/TP 估算模块;
- 调用 PP 建模模块,处理 stage_partition、micro_batch_num、layer_offset、layer_recompute;
- 调用 CP 建模模块;
- 汇总 memory cost;
- 汇总 performance cost;
- 根据 memory limit 标记 feasible / infeasible;
- 对可行策略排序;
- 输出 top-k 策略;
- 输出估算分解、过滤原因和可视化图表;
- 支持用户基于可视化结果理解策略差异,并据此调整约束或搜索空间进行重新寻优。
4. 策略表示
候选策略应至少包含:
| 字段 | 说明 |
|---|---|
| dp_degree | 数据并行度。 |
| tp_degree | 张量并行度。 |
| pp_degree | 流水并行度。 |
| cp_degree | Context Parallelism 并行度。 |
| micro_batch_num | micro batch 数量。 |
| stage_partition | PP stage 切分结果。 |
| layer_offset | PP stage 边界偏移策略。 |
| layer_recompute | layer recompute 策略。 |
| memory_cost | 总显存估算与分解。 |
| performance_cost | 总性能估算与分解。 |
| feasible | 是否可行。 |
| filter_reason | 不可行或被过滤原因。 |
5. 策略排序
策略排序应支持至少一种默认规则,例如:
- 先过滤显存不可行策略;
- 在可行策略中按 estimated step time 升序排序;
- 输出 top-k 候选策略。
后续可支持按照用户指定目标排序,例如显存优先、性能优先或综合评分优先。
6. 输出格式
Dense LLM 自动并行策略调优能力应输出:
| 输出 | 说明 |
|---|---|
| top_k_strategies | 排序后的 top-k 可行策略。 |
| all_candidate_summary | 所有候选策略的简要统计,可选。 |
| infeasible_summary | 被过滤策略数量和主要过滤原因,可选。 |
| memory_breakdown | 每个 top-k 策略的显存分解,可选。 |
| performance_breakdown | 每个 top-k 策略的性能分解,可选。 |
| stage_summary | PP 策略下每个 stage 的 memory、time、layer 范围,可选。 |
| visualization_report | 显存、性能、stage 负载、候选策略对比等可视化图表,可选。 |
| search_log | 可读日志,便于调试和复现,可选。 |
7. 可视化与可解释能力
可视化图表应至少支持展示以下信息:
- top-k 策略的 estimated step time 对比;
- top-k 策略的单卡显存占用对比;
- PP 策略下不同 stage 的 memory / time 分布;
- 候选策略 feasible / infeasible 分布;
- 不可行策略的主要过滤原因统计;
- 不同 dp_degree、tp_degree、pp_degree、cp_degree 下的性能和显存趋势。
可视化结果应辅助用户理解策略差异,并支持用户据此调整约束或搜索空间,例如:
- 固定某一并行维度;
- 调整显存上限;
- 调整 micro_batch_num 搜索范围;
- 调整是否启用 CP;
- 调整 PP layer offset 或 layer recompute 搜索范围。
8. 实现要点
- 调优主流程应与各 estimator 解耦,通过统一接口调用;
- 候选策略生成应支持逐步过滤,避免组合空间过大;
- 不可行策略应保留明确过滤原因;
- top-k 输出应包含完整策略字段,便于用户复现;
- 可视化图表应与 top-k 策略、显存分解、性能分解和过滤原因保持一致;
- 日志中应展示搜索空间大小、过滤数量、可行策略数量和 top-k 结果;
- 应支持只运行部分维度,便于调试和增量接入;
- 对暂不支持的组合,应返回 NotImplemented 或 infeasible,而不是静默忽略。
9. 测试设计
| 用例 ID | 描述 | 期望 |
|---|---|---|
| AP-DENSE-01 | Dense LLM 小搜索空间 DP/TP | 能生成候选策略并输出 top-k。 |
| AP-DENSE-02 | 搜索空间包含 PP 和 micro batch | 能调用 PP 建模模块并输出 stage summary。 |
| AP-DENSE-03 | 搜索空间包含 CP | 能调用 CP 建模模块并输出 CP 相关估算。 |
| AP-DENSE-04 | 存在显存超限策略 | 超限策略被过滤,并输出 filter_reason。 |
| AP-DENSE-05 | 存在整除约束不合法策略 | 策略被提前过滤。 |
| AP-DENSE-06 | top-k 输出检查 | 输出数量、排序顺序和策略字段符合预期。 |
| AP-DENSE-07 | 只启用部分维度 | 调优流程可在部分维度下正常运行。 |
| AP-DENSE-08 | 输出可视化图表 | 能生成显存、性能、stage summary 或过滤原因相关图表。 |
| AP-DENSE-09 | 用户调整约束后重新搜索 | 能基于新约束重新生成候选策略和 top-k 输出。 |
10. 验收标准
- Dense LLM 自动并行策略调优流程可串联配置读取和各维度估算模块;
- 能根据配置和用户限定搜索空间生成候选策略;
- 能对整除约束、设备约束和显存约束进行过滤;
- 能输出 memory cost、performance cost 和 feasible / infeasible 状态;
- 能输出 top-k 候选策略;
- 能输出不可行策略的 filter_reason;
- 能输出显存、性能、stage 负载或过滤原因相关可视化图表;
- 能支持用户基于可视化结果调整约束或搜索空间后重新寻优;
- AP-DENSE-01~AP-DENSE-09 测试通过;
- 文档中包含 Dense LLM 调优流程说明、策略字段说明、排序规则、可视化说明和输出示例。
11. 参考
- HyperParallel:自动并行策略搜索相关模块;
- HyperParallel:内存估算与性能估算模块;
- Megatron-LM:Dense LLM 多维并行策略组合;
- TorchTitan / PyTorch DTensor:DeviceMesh 与 parallelize_module 相关语义。
schema_version: 1
source: gitcode
gitcode_repo: mindspore/hyper-parallel
gitcode_issue: 130
source_url: https://gitcode.com/mindspore/hyper-parallel/issues/130
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation files or entry points are named. Start by locating the configuration reader and DP/TP/PP/CP estimator interfaces referenced in the issue, then use AP-DENSE-01 through AP-DENSE-09 as the test map; done means the integrated search flow, top-k outputs, filtering reasons, visualizations, and documentation meet the listed acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100