Skip to content

Commit a094647

Browse files
HuangJoJoPanAndy
authored andcommitted
(docs): add QA doc.
1 parent d65d0ef commit a094647

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

docs/qa.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# 常见 Q&A
2+
3+
0. **Megatron 模型如何转成 HF**
4+
5+
使用如下命令进行格式转换
6+
7+
```bash
8+
python mcore_adapter/tools/convert.py --checkpoint_path path_to_megatron_model --output_path path_to_output_hf_model
9+
```
10+
11+
0. **什么是colocate模式**
12+
13+
actor_train、actor_infer、reference多个角色之间的device_mapping可以复用,比如actor_train配置device_mapping: list(range(0,8)), actor_infer配置device_mapping: list(range(0,8)), reference配置device_mapping: list(range(0,8)) , 框架底层通过对保证了多个角色间GPU的复用
14+
15+
16+
0. **什么是分离模式**
17+
18+
actor_train、actor_infer、reference多个角色之间的device_mapping 之间没有交集,每个角色持有一组独立的GPU device资源,比如actor_train配置device_mapping: list(range(0,8)), actor_infer配置device_mapping: list(range(8,16)), reference配置device_mapping: list(range(16,24))
19+
20+
21+
0. **rollout_batch_size/num_return_sequences_in_group是什么意思**
22+
23+
rollout_batch_size: 一个batch中的prompt数量
24+
25+
num_return_sequences_in_group: 针对每条prompt采样数,也就是vllm/sglang推理中通常意义上的n参数
26+
27+
也就是实际一个batch内样本数 = rollout_batch_size * num_return_sequences_in_group
28+
29+
对于Megatron Backend, 需要注意:
30+
31+
rollout_batch_size * num_return_sequences_in_group 整数倍于
32+
gradient_accumulation_steps * per_device_train_batch_size * (world_size/tensor_model_parallel_size/pipeline_model_parallel_size/context_parallel_size)
33+
34+
35+
0. **如何设置gradient_accumulation_steps/per_device_train_batch_size**
36+
37+
***对于DeepSpeed Backend***
38+
39+
global_batch_size = per_device_train_batch_size * gradient_accumulation_steps * world_size
40+
41+
world_size 即actor_train/critic的device_mapping长度
42+
43+
***对于Megatron Backend***
44+
45+
global_batch_size = per_device_train_batch_size * gradient_accumulation_steps * world_size / tensor_model_parallel_size / pipeline_model_parallel_size / context_parallel_size
46+
47+
world_size 即actor_train/critic的device_mapping长度
48+
49+
注意: 不需要除以expert_model_parallel_size
50+
51+
52+
0. **如何获取训练的timeline**
53+
54+
可以尝试在yaml中开启profile
55+
56+
```yaml
57+
system_envs:
58+
RAY_PROFILING: "1"
59+
profiler_output_dir: /data/oss_bucket_0/yali/llm/profile/${exp_name}
60+
```
61+
62+
然后利用https://ui.perfetto.dev/ 工具进行分析
63+
64+
0. **如何debug代码**
65+
66+
在RayUtils的env中设置 "RAY_DEBUG": "legacy" , 就可以采用pdb进行单步调试
67+
68+
69+
0. **如果出现这种错误: self.node2pg[node_rank] KeyError: 1**
70+
71+
检查申请的GPU总数和device_mapping的配置,出现该错误一般是max(device_mapping) < 或者 > total_gpu_nums
72+
73+
0. **如果出现这种错误:assert self.lr_decay_steps > 0**
74+
75+
roll数据分配的时候,会将rollout_batch_size的样本,按dp size 分发到每个actor_train worker上,然后再按gradient_accumulation_steps计算每次梯度更新的样本。配置一除就是0;
76+
77+
详细配置逻辑可以参考手册:https://alibaba.github.io/ROLL/docs/English/QuickStart/config_guide#training-arguments-training_args
78+
79+
80+
0. **如果出现这种错误:AssertionError: batch_size 32 < chunks 64**
81+
82+
batch_size 小于reference/actor_train 的DP size,导致dispatch时数据不够切分,可以调整rollout_batch_size解决
83+
84+
85+
0. **如果出现这种错误:TypeError: BackendCompilerFailed.__init__() missing 1 required positional argument**
86+
87+
可以尝试在yaml增加配置项解决:
88+
89+
```yaml
90+
system_envs:
91+
NVTE_TORCH_COMPILE: '0'
92+
```
93+

0 commit comments

Comments
 (0)