deepspeedai / deepspeedai/DeepSpeed
Activation Checkpointing conflicts with Weight Sharing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Describe the bug
I implement multiple transformer layers with only one-layer parameter (e.g., recursively use one layer six times to construct a 6-layer transformer), when I use activation checkpointing, there will be an AssertionError in Line 631, stage2.py.
To Reproduce
This is the code that I used to call checkpoiting.
hidden_states = torch.utils.checkpoint.checkpoint(
custom(l, l + self.checkpoint_num_layers),
hidden_states, attention_mask, padding_mask, bias_encoder)
Expected behavior
I expect normal running.
Unexpected behavior
AssertionError: The parameter 97 has already been reduced. Gradient computed twice for this partition. Multiple gradient reduction is currently not supported
Additional context
deepspeed version: 0.3.16
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 with stage2.py around line 631 and reproduce the failure using the checkpoint call shown in the issue, with one transformer layer reused six times. Trace how the shared parameter is reduced during activation checkpointing and compare that path with the reported duplicate-gradient assertion. Done means the example runs without the assertion and gradient reduction remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100