deepspeedai / deepspeedai/DeepSpeed
[BUG] Patch and reload tensor methods in flops_profiler
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
Hi, I am using the FLOPs profiler as a standalone package. I found two issues in deepspeed/profiling/flops_profiler/profiler.py:
- In
_patch_tensor_methods, should this line wraptorch.Tensor.bmminstead oftorch.bmm? - In
_reload_tensor_methods, onlytorch.matmulis reset to the old function. Should we also reload other methods that are patched before? Otherwise, the other code in this script will be affected. For example, if we callget_model_profilemultiple times in a script, the flops and macs can be different even for the same model. https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/profiling/flops_profiler/profiler.py#L914
To Reproduce
Steps to reproduce the behavior:
- Go to code
- Scroll down to the two functions:
_patch_tensor_methodsand_reload_tensor_methods - See error as described above
Expected behavior
The patched methods should be reloaded after profiling. Otherwise, it will affect other code.
ds_report output
--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
runtime if needed. Op compatibility means that your system
meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
cpu_adam ............... [NO] ....... [OKAY]
cpu_adagrad ............ [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
fused_lamb ............. [NO] ....... [OKAY]
[WARNING] please install triton==1.0.0 if you want to use sparse attention
sparse_attn ............ [NO] ....... [NO]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
[WARNING] async_io requires the dev libaio .so object and headers but these were not found.
[WARNING] async_io: please install the libaio-dev package with apt
[WARNING] If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.
async_io ............... [NO] ....... [NO]
utils .................. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
transformer_inference .. [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ...............
torch version .................... 1.11.0
torch cuda version ............... 11.3
torch hip version ................ None
nvcc version ..................... [FAIL] cannot find CUDA_HOME via torch.utils.cpp_extension.CUDA_HOME=None
deepspeed install path ...........
deepspeed info ................... 0.6.7, unknown, unknown
deepspeed wheel compiled w. ...... torch 1.11, cuda 11.3
Screenshots
No
System info (please complete the following information):
- OS: Ubuntu 18.04
- GPU count and types: 10 A6000s
- Interconnects (if applicable)
- Python version: 3.9.12
- Any other relevant info about your setup: No
Launcher context
No, it's a general question about the code itself.
Docker context
No
Additional context
No
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 in deepspeed/profiling/flops_profiler/profiler.py by reading _patch_tensor_methods and _reload_tensor_methods, then trace how get_model_profile invokes them. Reproduce repeated profiling of the same model and verify that every patched tensor method is restored afterward and that the bmm patch targets the intended method.
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
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100