Skip to content
Open
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
23 changes: 18 additions & 5 deletions flashinfer/gemm/gemm_bf16_fp4_cudnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,9 @@ def execute_cudnn_bf16_fp4_graph_override_shape(
)


def _cudnn_bf16_fp4_runner(tuning_config):
"""Build a ``CudnnBf16Fp4Runner`` bound to the active tuning config."""
m_bucket_mapper = AutoTuner.get().get_effective_map_to_tuning_buckets(
tuning_config, spec_idx=0
)
@functools.lru_cache(maxsize=1024)
def _cudnn_bf16_fp4_runner_for_mapper(m_bucket_mapper):
"""Build a ``CudnnBf16Fp4Runner`` bound to the given M-bucket mapper."""

class CudnnBf16Fp4Runner(TunableRunner):
def __init__(self):
Expand Down Expand Up @@ -487,6 +485,21 @@ def forward(
return CudnnBf16Fp4Runner()


def _cudnn_bf16_fp4_runner(tuning_config):
"""Return the runner for the currently effective M-bucket mapper.

Cached per effective mapper rather than per ``tuning_config``: the mapper
reflects any thread-local ``autotune(tuning_buckets=..., round_up=...)``
override, and a runner built under one bucket scheme must not be reused
under another (its override-shape graphs would be keyed on stale
``cache_m`` buckets).
"""
m_bucket_mapper = AutoTuner.get().get_effective_map_to_tuning_buckets(
tuning_config, spec_idx=0
)
return _cudnn_bf16_fp4_runner_for_mapper(m_bucket_mapper)


def _prepare_cudnn(
b: torch.Tensor,
b_descale: torch.Tensor,
Expand Down
2 changes: 2 additions & 0 deletions flashinfer/gemm/gemm_bf16_fp4_cute_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
"""CuTe-DSL backend for the bf16 x fp4 GEMM (weight repack / kernel launch)."""

import functools
from typing import List, Optional, Tuple, cast

import torch
Expand Down Expand Up @@ -365,6 +366,7 @@ def add(tile_m, atom, pdepth, fp16, tile_n=64, tk=None, swz=1):
)


@functools.lru_cache(maxsize=1024)
def _cute_dsl_bf16_fp4_runner(enable_pdl: bool = True) -> TunableRunner:
"""Build a ``CuteDslBf16Fp4Runner`` for the cute-DSL bf16 x fp4 GEMM."""

Expand Down
Loading