安裝部署
CTCCL-0.4.0版本及以上。安裝方式可參考CTCCL 使用指南。
安裝慢節點工具套件
· 安裝ctccm
下載合適版本的ctccm whl安裝包,使用以下命令安裝:
pip install ctccm-xxx
通過pip show可以查看安裝包的位置,并配置環境變量:
pip show ctccmexport 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_groupsfrom megatron.core.parallel_state import get_tensor_model_parallel_groupfrom megatron.core.parallel_state import get_data_model_parallel_grouptp_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 CtcclProfilerprofiler = 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-netexport PATH="/usr/local/python3/bin:$PATH"
啟動命令:ctccl-profiler-net --log-level=info
下載地址
| 組件 | 下載地址 |
|---|---|
| ctccm | //jiangsu-10.zos.daliqc.cn/ctccl-n/ctccl-slowdetect/cuda12.2/ubuntu20.04/ctccl-slowdetect1.0.0/ctccm-1.0.0-cp39-cp39-linux_x86_64.whl |
| ctccl-profiler-comm | //jiangsu-10.zos.daliqc.cn/ctccl-n/ctccl-slowdetect/cuda12.2/ubuntu20.04/ctccl-slowdetect1.0.0/ctccl_profiler_comm-1.0.0-cp39-cp39-linux_x86_64.whl |
| ctccl-profiler-net | //jiangsu-10.zos.daliqc.cn/ctccl-n/ctccl-slowdetect/cuda12.2/ubuntu20.04/ctccl-slowdetect1.0.0/ctccl_profiler_net-1.0.0-cp39-cp39-linux_x86_64.whl |
使用流程
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=“//’ctccm-slowdetect-ip’:’ctccm-slowdetect-port’”,export CTCCL_PROFILER_NETADDR=“//127.0.0.1:8001”
3. 啟動訓練任務和ctccl-profiler
在同一目錄下啟動ctccl-profiler-net服務和執行訓練任務。ctccl-profiler-net --log-level=infobash run_llama2_7b_morenode.sh #執行訓練任務腳本示例
4. 日志查看
當日志級別設置為debug時,所有組件的日志均會以文件形式保存。否則,可以查看控制臺輸出的INFO日志。
使用提示
· 安裝基礎環境,必須帶有2.2.0以上torch和megatron框架。
· 目前暫不支持MOE模型。默認TP在機內。
· 默認訓練任務拉起時集群狀態健康,僅負責檢測訓練中間過程中出現的慢節點。
· 在啟動訓練任務之前,先啟動ctccm和ctccl-profiler-net服務。
· 請確保所有環境變量配置可用。