facebookresearch / facebookresearch/fairscale

Question in offload.py: Moving activation to CPU does NOT reduce GPU memory.

Open
#948 14 comments 0 reactions 0 assignees View on GitHub
bug help wanted offload_model triaged
Dominant language
Python
Stars
3.4k
Forks
293
PR merge metrics
No merged PRs in 30d

Description

I use my `cuda_active_bytes` function to measure the GPU memory before and after the code line below. I find moving activation to CPU does NOT reduce GPU memory.
https://github.com/facebookresearch/fairscale/blob/9f347f373e32ee5cad11a40b70b8e28a74b5e2d4/fairscale/experimental/nn/offload.py#L524
```python
def cuda_active_bytes():
torch.cuda.synchronize()
stats = torch.cuda.memory_stats()
current_active_byte = stats['active_bytes.all.current']
return current_active_byte
```
So actually all the activations generated by forward is still in GPU memory? If so, I think the code line above is redundant.

Contributor guide

Open the contributing guide

Research direction

Start at fairscale/experimental/nn/offload.py#L524 and reproduce the report with the provided cuda_active_bytes function, including torch.cuda.synchronize() and torch.cuda.memory_stats(). Read the surrounding activation-offload path and determine whether the observed active_bytes.all.current value reflects the expected behavior. Done means explaining the discrepancy and whether the line is redundant, with evidence from the reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.