Skip to content

benchmark fix - #94

Merged
ClashLuke merged 3 commits into
HomebrewML:mainfrom
dlyr3:benchmark_fix
Jun 21, 2026
Merged

benchmark fix#94
ClashLuke merged 3 commits into
HomebrewML:mainfrom
dlyr3:benchmark_fix

Conversation

@dlyr3

@dlyr3 dlyr3 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Fixed the #93 issue

Current results :
python benchmarks/bench_optimizer_step.py

32 tensors, 134217728 total params
Median Time: 7156.257µs

Version

heavyball: main branch (latest)
PyTorch: 2.12.1+cu130
Python: 3.12
RTX 3090 24GB

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de233443db

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread benchmarks/bench_optimizer_step.py Outdated
torch.cuda.synchronize()
start = perf_counter()
for _ in range(steps):
set_grads()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep grad reset outside measured step

When users benchmark many small tensors (or increase the tensor count), this line times the Python set_grads() loop once per measured step, so the reported median scales with per-parameter attribute assignment before optimizer.step() even starts. Since HeavyBall exposes consume_grad=False to keep .grad attached, the no-op issue can be fixed without adding this assignment loop to the timed region; otherwise this benchmark no longer reports just optimizer-step latency.

Useful? React with 👍 / 👎.

@dlyr3

dlyr3 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Should be good :

Results with current fix :

root@C.41943479:~/HeavyBall$ python benchmarks/bench_optimizer_step.py
32 tensors, 134217728 total params
Median Time: 7150.130µs

@ClashLuke

Copy link
Copy Markdown
Member

looks good to me, thank you! does this meaningfully change the results compared to what's reported in the readme? -- i believe it was profiled before the bug was introduced

@ClashLuke
ClashLuke merged commit 07887bd into HomebrewML:main Jun 21, 2026
3 checks passed
@dlyr3

dlyr3 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

this fix gives about the same result as the previous working version (e387c8a commit)

32 tensors, 134217728 total params
Median Time: 7151.955µs

Results with current fix :

32 tensors, 134217728 total params
Median Time: 7150.130µs

There's a 1-2 us noise difference, both tests were made on the same hardware (RTX 3090)

@ClashLuke

Copy link
Copy Markdown
Member

awesome, thank you for pushing this through! that's reassuring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants