Skip to content
KernelIndex
Search⌘K

cublaslt_nvfp4_scaled_mm_n2048_k2048

FlashInfer-Bench baselines · python · Apache-2.0

Use it

Vendorable · source mirrored · Apache-2.0View source →

No package. Vendor the mirrored source: 29 lines, Apache-2.0, pinned at da91508.

main.py
curl "https://kernelindex.com/api/v1/implementations/flashinfer-cublaslt-nvfp4-scaled-mm-n2048-k2048?include=source"
interfacepython
revisionda915083d4c7
symbolrun
pathmain.py
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp32, int8

Benchmark evidence

3 measurements across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
GEMM NVFP4 n2048 k2048int8 · [128, 1024]
NVIDIA B200
101.8µs
#4 of 6
2026-06-06
GEMM NVFP4 n2048 k2048int8 · [256, 1024]
NVIDIA B200
105.9µs
#3 of 6
2026-06-06
GEMM NVFP4 n2048 k2048int8 · [1024, 1024]
NVIDIA B200
108.8µs
#4 of 6
2026-06-06

Reported · How evidence levels are derived →

Source and license

sourcehttps://huggingface.co/datasets/flashinfer-ai/flashinfer-trace
commitda915083d4c7c5e61aa3005e3d17ae488e0fc71c
revision digestsha256:59a1441ae725c733b628532dc83ab21d17745100f8e1175f106de1650f697888
license declaredApache-2.0
license concludedApache-2.0
authorsbaseline
imported2026-08-16

Kernel source

main.py29 lines
import torch
from torchao.prototype.mx_formats.utils import to_blocked


def _unswizzle_sf(sf, row, col, vec=16):
    f = vec * 4
    nmt = (row + 127) // 128
    nkt = (col + f - 1) // f
    r = sf.view(nmt, nkt, 32, 4, 4).transpose(1, 3).reshape(nmt * 32 * 4, nkt * 4)
    return r[:row, : col // vec].contiguous()


def run(A_fp4, A_scale, B_fp4, B_scale, alpha):
    # cuBLASLt NVFP4 GEMM via torch._scaled_mm. Stored UE4M3 block scales are in the
    # flashinfer 128x4 swizzle; un-swizzle to logical [*, K/16] then re-block for cuBLAS.
    m = A_fp4.shape[0]
    k = A_fp4.shape[1] * 2
    n = B_fp4.shape[0]
    a_sc = _unswizzle_sf(A_scale.view(torch.uint8), m, k, 16).view(torch.float8_e4m3fn).reshape(m, k // 16)
    b_sc = _unswizzle_sf(B_scale.view(torch.uint8), n, k, 16).view(torch.float8_e4m3fn).reshape(n, k // 16)
    a_blk = to_blocked(a_sc)
    b_blk = to_blocked(b_sc)
    out = torch._scaled_mm(
        A_fp4.view(torch.float4_e2m1fn_x2),
        B_fp4.view(torch.float4_e2m1fn_x2).T,
        a_blk, b_blk, out_dtype=torch.bfloat16,
    )
    return (out.float() * alpha).to(torch.bfloat16)
scrolls · 29 lines total

Source code from FlashInfer-Bench (flashinfer-ai/flashinfer-trace) · Apache-2.0

Best evidence level for this revision: reported

JSON