Skip to content

Conversation

@cklxx
Copy link
Owner

@cklxx cklxx commented Nov 16, 2025

Summary

  • clear global FLOP/MAC collectors when resetting the profiler so each run starts from a clean state
  • ensure the collectors are also emptied when ending a profile to avoid leaking stale entries across sessions

Testing

  • python - <<'PY'
    import torch
    from torch import nn
    from deepspeed.profiling.flops_profiler import FlopsProfiler

class MyModel(nn.Module):
def init(self):
super().init()
self.lin1 = nn.Linear(4, 4)
self.lin2 = nn.Linear(4, 4)
def forward(self, x):
return self.lin2(torch.relu(self.lin1(x)))

model = MyModel()
inputs = torch.ones(2,4)
profiler = FlopsProfiler(model)
for i in range(3):
profiler.start_profile()
model(inputs)
profiler.stop_profile()
print('iter', i, profiler.get_total_macs(), profiler.get_total_flops())
profiler.end_profile()
PY


Codex Task

@cklxx cklxx merged commit 4071a91 into master Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants