deepspeed参数设置
·
- https://www.deepspeed.ai/docs/config-json/
Batch Size 相关的参数
train_batch_size 必须等于 train_micro_batch_size_per_gpu * gradient_accumulation * gpu数量
train_batch_size
train_micro_batch_size_per_gpu
gradient_accumulation_steps
在平均和应用梯度之前进行累积梯度的训练step数。
此功能有时对于提高可扩展性很有用,因为它会降低step之间梯度通信的频率。
此功能的另一个影响是能够在每个 GPU 上使用更大的批量大小进行训练。
Optimizer 参数
- type:优化器名称。 DeepSpeed 原生支持 Adam、AdamW、OneBitAdam、Lamb 和 OneBitLamb 优化器,同时,也可以从 torch 中导入其他优化器。
- https://deepspeed.readthedocs.io/en/latest/optimizers.html#optimizers
- https://pytorch.org/docs/stable/optim.html
- params:用于实例化优化器的参数字典。参数名称必须与优化器构造函数签名匹配(例如,Adam)。
- https://pytorch.org/docs/stable/optim.html#algorithms
- https://pytorch.org/docs/stable/generated/torch.optim.Adam.html
Adam 优化器示例:
"optimizer": {
"type": "Adam",
"params": {
"lr": 0.001,
"betas": [
0.8,
0.999
],
"eps": 1e-8,
"weight_decay": 3e-7
}
}
参数:
- torch_adam: Use torch’s implementation of adam instead of our fused adam implementation , 默认为false
Scheduler 参数
当执行 model_engine.step() 时,DeepSpeed 在每个训练步骤调用 scheduler 的 step() 方法。
- type:学习率调度器名,DeepSpeed 提供了 LRRangeTest、OneCycle、WarmupLR、WarmupDecayLR 学习率调度器的实现。
- https://deepspeed.readthedocs.io/en/latest/schedulers.html
- params:用于实例化调度器的参数字典。参数名称应与调度程序构造函数签名匹配。
scheduler 示例:
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": 0.001,
"warmup_num_steps": 1000
}
}
通讯选项
communication_data_type
prescale_gradients
gradient_predivide_factor
sparse_gradients
FP16 训练选项
- 注意:此模式不能与下述 amp 模式结合使用。
更多推荐


所有评论(0)