deepspeedai / deepspeedai/DeepSpeed
[BUG] Partitioned activation checkpointing does not reduce memory usage
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Hi, I have an issue with partitioned activation checkpointing.
This is my github repo:
https://github.com/andrasiani/deepspeed_lightning_gpt_partition_activations_checkpointing/tree/master
When I run activation_checkpointing without partitioning I get the same memory usage as in the case when partitioning is enabled.
deepspeed/runtime/activation_checkpoing/checkpointing.py
I checked and partition_activations() method shards the tensor correctly,
the backward all_gather method also seems to work correctly https://github.com/andrasiani/deepspeed_lightning_gpt_partition_activations_checkpointing/blob/master/checkpointing_.py#L663,
the get_partitioned_activations_for_backward() seems to only save partitions.
Somewhere I suspect that the whole checkpointed layer is stored in memory after forward until backward pass, instead of just a partition of it.
This is the checkpointing script I use:
https://github.com/andrasiani/deepspeed_lightning_gpt_partition_activations_checkpointing/blob/master/checkpointing_.py#L521
checkpointing_ custom.txt
and I call it like this:
deepspeed.checkpointing.configure(
mpu_=None,
partition_activations=True,
contiguous_checkpointing=False,
checkpoint_in_cpu=False,
profile=checkpoint_config.get("profile"),
)
mpu object is set to None in pytorch lightning - this is a pytorch lightning bug I think - to address this inside my custom script I initialize an mpu object, so there should be no problem.
https://github.com/andrasiani/deepspeed_lightning_gpt_partition_activations_checkpointing/blob/master/checkpointing_.py#L521
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported comparison with the linked checkpointing script and configuration, then inspect deepspeed/runtime/activation_checkpoing/checkpointing.py, especially partition_activations(), get_partitioned_activations_for_backward(), and the backward all_gather path. Done means partitioned activation checkpointing demonstrably uses less memory than the unpartitioned configuration while preserving backward behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems, machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100