deepspeedai / deepspeedai/DeepSpeed
Flops profiler does not account for overloaded operators
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
I was getting some weird results with my profiling results, and dug a bit deeper to find out that overloaded python operators (e.g. *, +) were not getting properly evaluated by the get_model_profile method. The following is a simple script to reproduce my results.
import torch
from deepspeed.profiling.flops_profiler.profiler import get_model_profile
from torch import nn
class SimpleAdder(nn.Module):
def forward(self, x):
return x + x
class SimpleAdder2(nn.Module):
def forward(self, x):
return torch.add(x, x)
flops, macs, params = get_model_profile(SimpleAdder(), input_shape=(1, 2, 10), print_profile=False)
print(flops)
flops, macs, params = get_model_profile(SimpleAdder2(), input_shape=(1, 2, 10), print_profile=False)
print(flops)
Output
0
20 # this is what I would expect
Due to the improved readability of using the overloaded operators, it is likely that many different models (especially those with residual blocks) suffer from a similar problem.
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 the provided SimpleAdder and SimpleAdder2 reproducer and trace get_model_profile in deepspeed.profiling.flops_profiler.profiler. Compare how overloaded Python operators and torch.add are evaluated, then verify that both examples report the expected FLOPs and that existing profiler behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100