Skip to content

Add BF16 routing support to CUDA MoE - #32659

Merged
kunal-vaishnavi merged 2 commits into
mainfrom
kvaishnavi/moe-bf16-cuda
Sep 17, 2026
Merged

kunal-vaishnavi merged 2 commits into
mainfrom
kvaishnavi/moe-bf16-cuda

Conversation

@kunal-vaishnavi

Copy link
Copy Markdown
Contributor

Description

This pull request adds support for the bfloat16 (BF16) data type in the Mixture of Experts (MoE) CUDA kernel implementation. The main changes ensure that both the sparse mixer and softmax top-k operations can now handle BF16 input tensors, improving compatibility and performance on hardware supporting BF16.

Support for BF16 data type:

  • Added a check for BF16 input tensors using IsDataType<BFloat16>() in the MoE kernel (moe.cc).
  • Updated the sparse mixer path to call LaunchSparseMixerTop2 with BF16 data when appropriate.
  • Updated the softmax top-k path to call LaunchSoftmaxTopK with BF16 data when appropriate.

Motivation and Context

BF16 routing support was missing in the CUDA MoE kernel.

Copilot AI balanced review requested due to automatic review settings September 16, 2026 21:51

Copilot AI 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.

🟡 Changes recommended

Add end-to-end BF16 sparse-mixer test coverage, including the CUDA capability guard.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds BF16 routing support to the CUDA MoE sparse mixer and softmax top-k paths.

Changes:

  • Detects BF16 inputs.
  • Routes BF16 tensors to the appropriate CUDA kernels.
File summaries
File Description
onnxruntime/contrib_ops/cuda/moe/moe.cc Adds BF16 routing dispatch.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread onnxruntime/contrib_ops/cuda/moe/moe.cc
@kunal-vaishnavi
kunal-vaishnavi enabled auto-merge (squash) September 16, 2026 23:42
@kunal-vaishnavi
kunal-vaishnavi merged commit e266b17 into main Sep 17, 2026
93 of 94 checks passed
@kunal-vaishnavi
kunal-vaishnavi deleted the kvaishnavi/moe-bf16-cuda branch September 17, 2026 03:03
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