Skip to content

Move bmm calls to use PyTorch bmm_out via the stable op dispatcher API - #220

Merged
vbharadwaj-bk merged 27 commits into
mainfrom
move-bmm-calls-to-stable-cshim
Nov 11, 2026
Merged

vbharadwaj-bk merged 27 commits into
mainfrom
move-bmm-calls-to-stable-cshim

Conversation

@asglover

@asglover asglover commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

This PR removes our dependency on BLAS. Instead we move to calling PyTorch's bmm_out through the dispatcher. It makes it so that we can support SYCL for symmetric contractions.

It has a slight performance regression when the amount of work done per BMM is very small, however it is not significant during our benchmark / expected workloads.

This PR contributes to enabling multi device support

@asglover asglover mentioned this pull request Sep 14, 2026
@asglover
asglover marked this pull request as ready for review September 15, 2026 04:12
@asglover asglover added the ci-ready Triggers CI checks for a pull request label Sep 15, 2026

@vbharadwaj-bk vbharadwaj-bk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code looks fine, just one or two questions. Perf-wise, do you know how this compares to the original CUDA version?

@vbharadwaj-bk

Copy link
Copy Markdown
Member

And this is a great change, thanks - good to get the dependence on BLAS eliminated.

@asglover
asglover marked this pull request as draft September 23, 2026 05:46
@asglover
asglover force-pushed the move-bmm-calls-to-stable-cshim branch from 64af319 to 4b89132 Compare October 25, 2026 06:07
@asglover asglover changed the title Move bmm calls to stable cshim Move bmm calls to use PyTorch bmm_out via the stable op dispatcher API Nov 2, 2026
@asglover

asglover commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Code looks fine, just one or two questions. Perf-wise, do you know how this compares to the original CUDA version?

It introduces more CPU overhead. On expected workloads, it's not measurable in overall model execution time. For really small models, with ~30 atoms, it can be ~3% slower. With only ~8 atoms, the worse case was ~5% slower. But this is somewhat expected. I think because the performance difference is negligible during large workloads it should be acceptable? It also enables SYCL support for symmetric contractions and they use MACE. And so they will be very happy about this.

Please weigh in on this. If the performance impact is unacceptable, then I'm blocked for a little bit. The ways out would be:

  • Leave CUDA / ROCM on the stable abi c shim for lower CPU performance
  • Roll the operations currently being performed by the GEMM in a new custom kernel
  • wait for pytorch to have a real grouped gemm op
    These are roughly ordered in how long they would take

@vbharadwaj-bk

Copy link
Copy Markdown
Member

Ok, that overhead seems minimal, continuing with this strategy should be fine.

@vbharadwaj-bk vbharadwaj-bk removed the ci-ready Triggers CI checks for a pull request label Nov 2, 2026
@asglover
asglover force-pushed the move-bmm-calls-to-stable-cshim branch from 69e4728 to fe75c96 Compare November 2, 2026 06:59
@asglover

asglover commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Okay, all the tests on cuda and on sycl have come back green. I'm going to go over this in detail, probably polish a few things up. I'll be out of town traveling for two days, will pick it up on Wednesday.

@asglover
asglover marked this pull request as ready for review November 10, 2026 06:31
@asglover

Copy link
Copy Markdown
Collaborator Author

Okay, I ran this on CUDA, HIP and SYCL and it's looking good. I'm ready for a review @vbharadwaj-bk. Thank you for your patience on this one.

@vbharadwaj-bk vbharadwaj-bk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cool, thanks!

@vbharadwaj-bk vbharadwaj-bk added the ci-ready Triggers CI checks for a pull request label Nov 11, 2026
@vbharadwaj-bk
vbharadwaj-bk merged commit 6378589 into main Nov 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-ready Triggers CI checks for a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants