Skip to content

add flagos.te_general_grouped_gemm#47

Closed
chai-xiaonan wants to merge 0 commit into
flagos-ai:mainfrom
chai-xiaonan:te_group_gemm
Closed

add flagos.te_general_grouped_gemm#47
chai-xiaonan wants to merge 0 commit into
flagos-ai:mainfrom
chai-xiaonan:te_group_gemm

Conversation

@chai-xiaonan

Copy link
Copy Markdown

Based on the existing operators supported by flagGems, implement support for the te_general_grouped_gemm operator in the flagOS backend.Primarily addresses the operators involved in the DeepSeek V3 16_a3b model that are supported by CUDA but not by flagOS.

continue

# Transpose matrices if requested
a = A[i].t() if transa else A[i]

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.

use flag_gems transpose op ?

def gelu_backward(grad_output, x):
# Approximation of GELU derivative commonly used in Transformer Engine
cdf = 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))
pdf = flag_gems.exp(-0.5 * x * x) / math.sqrt(2.0 * math.pi)

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.

use flag_gems op?

beta,
)

def te_general_grouped_gemm(self, *args, **kwargs) -> Any:

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.

The te_general_grouped_gemm api interface in transformer_engine/plugin/core/ops.py is as follows, please keep consistent

def te_general_grouped_gemm(
        self,
        A: List[Any],
        transa: bool,
        B: List[Any],
        transb: bool,
        D: Optional[List[torch.Tensor]],
        D_type: DType,
        m_splits: List[int],
        bias: List[torch.Tensor],
        bias_type: DType,
        single_output: bool,
        pre_gelu_out: List[torch.Tensor],
        grad: bool,
        workspace: List[torch.Tensor],
        workspaceSizes: int,
        accumulate: bool,
        use_split_accumulator: bool,
        math_sm_count: int,
    ) -> Optional[List[torch.Tensor]]:
        raise NotImplementedError

@chai-xiaonan

chai-xiaonan commented Mar 19, 2026 via email

Copy link
Copy Markdown
Author

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