Skip to content

Add fused triton kernel for swiglu - #8244

Open
hwchen2017 wants to merge 4 commits into
masterfrom
hongwei/swiglu
Open

Add fused triton kernel for swiglu#8244
hwchen2017 wants to merge 4 commits into
masterfrom
hongwei/swiglu

Conversation

@hwchen2017

Copy link
Copy Markdown
Contributor

Performance:

SwiGLU Benchmark

Configuration: hidden=1024, dtype=bf16

Tokens Variant Forward (µs) Forward + Backward (µs) Backward (µs)
8,192 triton_fused 13.05 36.29 23.24
8,192 eager 22.53 61.47 38.94
16,384 triton_fused 26.25 67.65 41.40
16,384 eager 44.97 120.95 75.98
65,536 triton_fused 94.71 251.60 156.89
65,536 eager 163.12 444.64 281.52

@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: 570831af74

ℹ️ 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".

w3.to(cast_dtype).transpose(-2, -1),
offs=offsets,
)
h = swiglu(gate, up)

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 the native grouped-MM path off Triton

When GroupedExperts selects the native torch._grouped_mm path, including when callers pass disable_triton_grouped_mm=True to avoid the Triton grouped-GEMM path, this line still dispatches the new Triton SwiGLU kernel whenever the triton package is importable. In environments where Triton imports but kernels are unsupported or intentionally disabled, the supposed native path can now fail or JIT Triton anyway; keep this path on the eager F.silu(gate) * up expression or plumb an explicit opt-in for the fused activation.

Useful? React with 👍 / 👎.

_TRITON_AVAILABLE = False

__all__ = ["group_gemm_triton", "is_available"]
from deepspeed.ops.triton_ops._triton import _TRITON_AVAILABLE, triton, tl

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 Preserve the old group_gemm_triton import path

Moving the module without a compatibility shim breaks existing users that import the previously exposed deepspeed.moe.group_gemm_triton module or its is_available helper, even though the implementation still exists under the new package. Please leave a thin deepspeed/moe/group_gemm_triton.py re-export, including an is_available alias to is_triton_available, so downstream code does not start failing at import time.

Useful? React with 👍 / 👎.

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.

1 participant