安装部署
CTCCL-0.4.0版本及以上。安装方式可参考CTCCL 使用指南。
安装慢节点工具套件
· 安装ctccm
下载合适版本的ctccm whl安装包,使用以下命令安装:
pip install ctccm-xxx
通过pip show可以查看安装包的位置,并配置环境变量:
pip show ctccm
export PATH="/usr/local/python3/bin:$PATH"
启动命令:
ctccm --nodes 4 --port 8000 --debug(可选)
· 安装ctccl-profiler-comm
下载合适版本的ctccl-profiler-comm安装包,使用以下命令安装:
pip install ctccl-profiler-comm-xxx
通过import ctccl profiler comm,在训练任务中调用ctccl-profiler-comm提供的API使用。ctccl-profiler-comm包括以下可用API:
save_tp_dp_groups(tp_group, dp_group):
保存任务拓扑信息到本地文件。
•tp_group (ProcessGroup):张量并行组(由`megatron内置函数get_tensor_model_parallel_group()` 获取)
•dp_group (ProcessGroup):数据并行组(由`megatron内置函数get_data_parallel_group()` 获取)
•返回:无
使用示例:from ctccl_profiler_comm.get_tp_dp_groups import save_tp_dp_groups
from megatron.core.parallel_state import get_tensor_model_parallel_group
from megatron.core.parallel_state import get_data_model_parallel_group
tp_group = get_tensor_model_parallel_group()
dp_group = get_data_model_parallel_group()
save_tp_dp_groups(tp_group, dp_group)
CtcclProfiler(train_iters):
初始化CtcclProfiler类,创建CtcclProfiler对象。
•train_iters (int):训练任务迭代总数
•返回:CtcclProfiler对象
CtcclProfiler.get_time():
时间打点,用于每个迭代前后,获得每次迭代的时间。
•返回:当前时间点
CtcclProfiler.update_step(start_time, end_time, iteration):
根据当前的训练迭代数,以及迭代时间,判断是否要开启、继续收集、停止profiler。
•start_time (float):当前迭代开始时间(由 `CtcclProfiler.get_time()` 获取)
•end_time (float):当前迭代结束时间(由 `CtcclProfiler.get_time()` 获取)
•iteration (int):当前执行到的迭代步数
•返回:无
使用示例:from ctccl_profiler_comm.ctccl_profiler import CtcclProfiler
profiler = CtcclProfiler(args.train_iters)
...
while iteration < args.train_iters:
...
start_time = profiler.get_time()
train_step() #自写训练一个step对应的代码
end_time = profiler.get_time()
profiler.update_step(start_time, end_time, iteration)
iteration += 1
...
...
· 安装ctccl-profiler-net
下载合适版本的ctccl-profiler whl安装包,使用以下命令安装:pip install ctccl-profiler-net-xxx.whl
通过pip show可以查看安装包的位置,并配置环境变量:pip show ctccl-profiler-net
export PATH="/usr/local/python3/bin:$PATH"
启动命令:ctccl-profiler-net --log-level=info
使用流程
1. ctccm启动
在和所有训练任务节点网络互通的节点上,部署1个ctccm服务,并配置好环境变量。使用以下启动命令拉起ctccm服务,根据训练任务节点数实际和需要配置nodes和port。ctccm --nodes “nnodes” --port “ctccm-slowdetect-port”
2. 提前配置ctccl-profiler所需环境变量
配置以下环境变量:export CTCCL_QPTIME_REPORT=1,
export CTCCL_SLOWDETECT_SERVERADDR=“http://’ctccm-slowdetect-ip’:’ctccm-slowdetect-port’”,
export CTCCL_PROFILER_NETADDR=“http://127.0.0.1:8001”
3. 启动训练任务和ctccl-profiler
在同一目录下启动ctccl-profiler-net服务和执行训练任务。ctccl-profiler-net --log-level=info
bash run_llama2_7b_morenode.sh #执行训练任务脚本示例
4. 日志查看
当日志级别设置为debug时,所有组件的日志均会以文件形式保存。否则,可以查看控制台输出的INFO日志。
使用提示
· 安装基础环境,必须带有2.2.0以上torch和megatron框架。
· 目前暂不支持MOE模型。默认TP在机内。
· 默认训练任务拉起时集群状态健康,仅负责检测训练中间过程中出现的慢节点。
· 在启动训练任务之前,先启动ctccm和ctccl-profiler-net服务。
· 请确保所有环境变量配置可用。