[BUG]Activation recomputation does not support undividable recompute_num_layers
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 4.5k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 271
Description
**Describe the bug**
List of out range error when `self.num_layers_per_pipeline_rank % self.config.recompute_num_layers!=0`
**To Reproduce**
Set self.config.recompute_num_layers to a non factor of self.num_layers_per_pipeline_rank
**Expected behavior**
List out of range
**Stack trace/logs**
If applicable, add the stack trace or logs from the time of the error.
**Environment (please complete the following information):**
- Megatron-LM commit ID
- PyTorch version
- CUDA version
- NCCL version
**Proposed fix**
Change [line ](https://github.com/NVIDIA/Megatron-LM/blob/1584dca28bc302102ecc07648f8c286213625c5c/megatron/core/transformer/transformer_block.py#L473) from
`custom(layer_idx, layer_idx + self.config.recompute_num_layers)`
to
`custom(layer_idx, min(self.num_layers_per_pipeline_rank, layer_idx + self.config.recompute_num_layers))
**Additional context**
Add any other context about the problem here.
Contributor guide
Assessment
This issue has not been assessed yet.