已开启
[Feature] HyperParallel integration follow-up: CP/TP/EP/activation/HSDP #179
cuiyushi创建于 6月1日
6月1日 修改标题为 “[Feature] HyperParallel integration follow-up: CP/TP/EP/activation/HSDP”,原标题为“[Feature] HyperParallel integration follow-up: CP/TP/EP/activation /HSDP”
6月1日 修改标题为 “[Feature] HyperParallel integration follow-up: CP/TP/EP/activation/HSDP”,原标题为“[Feature] HyperParallel integration follow-up: CP/TP/EP/activation /HSDP”
Reminder
Description
【动机】
#10289 已经把 MindSpore HyperParallel 作为 FSDP2 后端接入 LlamaFactory。在此基础上补齐五项能力,让长序列、大 MoE、显存紧张以及多副本 DP 场景也能复用同一后端:
fsdp_size):在 1D FSDP 之外支持 2D(dp_size, fsdp_size)mesh —— 每fsdp_size个 rank 组成一个 shard 组,组与组之间做 DP 复制,避免shape[0] % world_size != 0的参数 fallback 到 replicate 路径导致 OOM。HyperParallel 侧已实现并提供集成接口,本 issue 只负责 LlamaFactory 侧的接入与开关暴露。
【架构目标】
use_hyper_parallel时不触发任何 HP 代码;新增字段全部默认 off /None。use_hyper_parallel+hyper_parallel_args(JSON 路径或 dict),并行 / 显存策略字段全部经 JSON 注入到HyperParallelArguments。pt+sft两个 stage。【建议的方案】
启动方式与 #10289 一致,yaml 中开启 HP 后端:
use_hyper_parallel: true hyper_parallel_args: examples/hyper_parallel/example.jsonexample.json描述并行 / 显存策略:{ "cp_size": 2, "tp_size": 2, "ep_size": 4, "ep_style": "ep", "expert_module_cls": "Qwen3VLMoeTextSparseMoeBlock", "activation_mode": "swap", "activation_swap_inputs": true, "fsdp_size": 4 }LlamaFactory 侧改动:
tuner.py._training_function:use_hyper_parallel分支条件由stage == "sft"扩到stage in {"pt", "sft"}。train/hyper_parallel/trainer.py:新增HyperParallelTrainer,继承CustomSeq2SeqTrainer,复用 LF 既有的 loss / metric / save_predictions。train/hyper_parallel/workflow.py:新增run_pt,与已有run_sft共享 HP arguments 解析与HyperParallelTrainer构造。组件关系:
flowchart TD ARGS[FinetuningArguments<br/>use_hyper_parallel + hyper_parallel_args] TUNER[_training_function] WORKFLOW[run_pt / run_sft] TRAINER[HyperParallelTrainer<br/>extends CustomSeq2SeqTrainer] subgraph HP [HyperParallel integration] FSDP[FSDP2 / HSDP] CP[Context Parallel] TP[Tensor Parallel] EP[Expert Parallel] ACT[Activation Swap / Recompute] end ARGS --> TUNER -->|use_hyper_parallel=True<br/>stage ∈ pt, sft| WORKFLOW --> TRAINER TRAINER --> FSDP TRAINER --> CP TRAINER --> TP TRAINER --> EP TRAINER --> ACT【约束】