Skip to content

[AdvancedCompiler]bmm(cpp wrapper) - #735

Merged
iclementine merged 2 commits into
flagos-ai:masterfrom
AdvancedCompiler:bmm(cpp-wrapper)
Jul 7, 2025
Merged

[AdvancedCompiler]bmm(cpp wrapper)#735
iclementine merged 2 commits into
flagos-ai:masterfrom
AdvancedCompiler:bmm(cpp-wrapper)

Conversation

@AdvancedCompiler

Copy link
Copy Markdown
Collaborator

PR Category

Operator

Type of Change

New Feature

Description

CPP wrapper packaging for bmm op.

Issue

Progress

  • Change is properly reviewed (1 reviewer required, 2 recommended).
  • Change is responded to an issue.
  • Change is fully covered by a UT.

Performance

image

Comment thread lib/bmm.cpp Outdated
namespace flag_gems {
using namespace triton_jit;

at::Tensor bmm(at::Tensor& A, at::Tensor& B) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use constant reference to values that does not need mutation.

Comment thread src/flag_gems/csrc/cstub.cpp Outdated
m.def(
"rotary_embedding(Tensor q, Tensor k, Tensor cos, Tensor sin, Tensor? position_ids=None, "
"bool rotary_interleaved=False) -> (Tensor, Tensor)"); // q and k may be view to other size
m.def("bmm(Tensor A, Tensor B) -> Tensor");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please refer to torch's op schema lang for more details about relation of the schema here and the function signature of c++ function.

@iclementine iclementine left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use const reference for Tensors that do not need mutation.

@iclementine iclementine left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Bowen12992 Bowen12992 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@iclementine
iclementine merged commit 28acd7b into flagos-ai:master Jul 7, 2025
9 of 14 checks passed
nicelynice pushed a commit to nicelynice/FlagGems that referenced this pull request Feb 24, 2026
* Update the C++ wrapper for bmm
* Modify the BMM code according to the review comments

---------

Co-authored-by: “ph0375” <“ph0375@163.com”>
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.

3 participants