deepspeedai / deepspeedai/DeepSpeed

[BUG] FlopsProfiler upsample flops compute bug

Open Beginner friendly
#5,537 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug training
Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

Describe the bug
the upsample flops compute code :
`def _upsample_flops_compute(*args, **kwargs):

scale_factor = kwargs.get('scale_factor', None)
if scale_factor is None and len(args) > 2:
    scale_factor = args[2]
assert scale_factor is not None, "either size or scale_factor should be defined"

flops = input.numel()
if isinstance(scale_factor, tuple) and len(scale_factor) == len(input):
    flops *= int(_prod(scale_factor))
else:
    flops *= scale_factor**len(input)
return flops, 0`

len(scale_factor) == len(input) -> len(scale_factor) == len(input.size())
flops *= scale_factor ** len(input) -> flops *= scale_factor ** (len(input.size())-1)

upsample flops compute in torchstat: https://github.com/Swall0w/torchstat/blob/master/torchstat/compute_flops.py#L83

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the _upsample_flops_compute entry point used by FlopsProfiler, then compare its argument and dimensionality handling with torchstat's torchstat/compute_flops.py at the referenced section. Verify the calculation for tuple and scalar scale_factor cases, including spatial dimensions, and add or run the relevant profiler checks if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.