Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions csrc/moe_utils_binding.cu
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,14 @@ TVM_FFI_DLL_EXPORT_TYPED_FUNC(flashinfer_moe_activation_bf16, moe_activation_bf1
// - total_num_padded_tokens: [1], total number of padded tokens
// - num_non_exiting_tiles: [1], number of non-exiting tiles

// Batch size from which the cooperative routing kernel switches to contiguous
// per-CTA route windows (see DataBase::mUseContiguousRouteWindows). The gather
// locality it buys only pays off once a grouped-GEMM tile's slice of the
// activation tensor outgrows the uTLB: measured on B200 it is neutral at or
// below 32K tokens, roughly break-even at 64K, and worth 1.15-1.17x end to end
// on the fused MoE pipeline at 128K.
static constexpr int32_t kContiguousRouteWindowMinTokens = 65536;

void moe_sort(
// Inputs
int64_t token_selected_experts_ptr, // [num_tokens, top_k], int32
Expand All @@ -365,6 +373,7 @@ void moe_sort(
// Configure dtypes
routingData.mDtypeOutput = batchedGemm::trtllm::gen::Dtype::Bfloat16;
routingData.mUsePdl = use_pdl;
routingData.mUseContiguousRouteWindows = num_tokens >= kContiguousRouteWindowMinTokens;

// Input tensors (pre-computed expert selections)
routingData.mPtrTopKIds = reinterpret_cast<int32_t*>(token_selected_experts_ptr);
Expand Down
8 changes: 8 additions & 0 deletions docs/api/fused_moe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ The CuteDSL backends are conditionally available when the
:toctree: ../generated

cute_dsl_fused_moe_nvfp4
cute_dsl_fused_moe_mxfp8_mxfp4
b12x_fused_moe

.. autoclass:: CuteDslMoEWrapper
Expand All @@ -105,6 +106,13 @@ The CuteDSL backends are conditionally available when the

.. automethod:: __init__

.. autoclass:: CuteDslMxfp8Mxfp4MoEWrapper
:members:
:inherited-members:
:show-inheritance:

.. automethod:: __init__

.. autoclass:: B12xMoEWrapper
:members:
:inherited-members:
Expand Down
2 changes: 2 additions & 0 deletions flashinfer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
from .fused_moe import (
cute_dsl_fused_moe_nvfp4 as cute_dsl_fused_moe_nvfp4,
CuteDslMoEWrapper as CuteDslMoEWrapper,
cute_dsl_fused_moe_mxfp8_mxfp4 as cute_dsl_fused_moe_mxfp8_mxfp4,
CuteDslMxfp8Mxfp4MoEWrapper as CuteDslMxfp8Mxfp4MoEWrapper,
b12x_fused_moe as b12x_fused_moe,
B12xMoEWrapper as B12xMoEWrapper,
)
Expand Down
4 changes: 4 additions & 0 deletions flashinfer/fused_moe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
from .cute_dsl import (
cute_dsl_fused_moe_nvfp4,
CuteDslMoEWrapper,
cute_dsl_fused_moe_mxfp8_mxfp4,
CuteDslMxfp8Mxfp4MoEWrapper,
b12x_fused_moe,
B12xMoEWrapper,
)
Expand Down Expand Up @@ -210,6 +212,8 @@
__all__ += [
"cute_dsl_fused_moe_nvfp4",
"CuteDslMoEWrapper",
"cute_dsl_fused_moe_mxfp8_mxfp4",
"CuteDslMxfp8Mxfp4MoEWrapper",
"b12x_fused_moe",
"B12xMoEWrapper",
]
8 changes: 7 additions & 1 deletion flashinfer/fused_moe/cute_dsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
CuteDSL-based Fused MoE Kernels for NVFP4 on Blackwell GPUs.
CuteDSL-based Fused MoE Kernels for NVFP4 and MXFP8 x MXFP4 on Blackwell GPUs.
"""

from ...cute_dsl.utils import is_cute_dsl_available
Expand All @@ -23,6 +23,10 @@
cute_dsl_fused_moe_nvfp4,
CuteDslMoEWrapper,
)
from .fused_moe_mxfp8_mxfp4 import (
cute_dsl_fused_moe_mxfp8_mxfp4,
CuteDslMxfp8Mxfp4MoEWrapper,
)
from .b12x_moe import (
b12x_fused_moe,
B12xMoEWrapper,
Expand All @@ -36,6 +40,8 @@
__all__ += [
"cute_dsl_fused_moe_nvfp4",
"CuteDslMoEWrapper",
"cute_dsl_fused_moe_mxfp8_mxfp4",
"CuteDslMxfp8Mxfp4MoEWrapper",
"b12x_fused_moe",
"B12xMoEWrapper",
]
Loading
Loading