Skip to content
KernelIndex
Search⌘K

submission 189837

dandanaka_hitman · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

No package. Vendor the mirrored source: 42 lines, June 9 Researcher Reciprocity License v1.0.

mrk2.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-nvfp4-dual-gemm-189837?include=source"
interfacepython
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp8_e4m3, nvfp4

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
NVFP4 dual GEMMsuite of 4 cases
NVIDIA B200
38.2µs
#272 of 420
2025-12-22

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:e9725b659a8347e8986fee993d787f2883b3b99e182d6180e7ce4161f0e038b1
license declaredunknown
license concludedunknown
authorsdandanaka_hitman
imported2026-08-26

Kernel source

mrk2.py42 lines
import torch
from task import input_t, output_t

_tmp1 = None
_tmp2 = None


def custom_kernel(data: input_t) -> output_t:
    a, b1, b2, _, _, _, sfa_p, sfb1_p, sfb2_p, c = data
    m, n, L = c.shape
    device = c.device

    global _tmp1, _tmp2
    if _tmp1 is None or _tmp1.shape != (m, n) or _tmp1.device != device:
        _tmp1 = torch.empty((m, n), device=device, dtype=torch.float16)
        _tmp2 = torch.empty((m, n), device=device, dtype=torch.float16)

    for l_idx in range(L):

        torch._scaled_mm(
            a[:, :, l_idx],
            b1[:, :, l_idx].transpose(0, 1),
            sfa_p[..., l_idx].permute(2, 4, 0, 1, 3).contiguous().view(-1),
            sfb1_p[..., l_idx].permute(2, 4, 0, 1, 3).contiguous().view(-1),
            bias=None,
            out_dtype=torch.float16,
            out=_tmp1,
        )
        torch._scaled_mm(
            a[:, :, l_idx],
            b2[:, :, l_idx].transpose(0, 1),
            sfa_p[..., l_idx].permute(2, 4, 0, 1, 3).contiguous().view(-1),
            sfb2_p[..., l_idx].permute(2, 4, 0, 1, 3).contiguous().view(-1),
            bias=None,
            out_dtype=torch.float16,
            out=_tmp2,
        )

        c[:, :, l_idx] = (torch.nn.functional.silu(_tmp1) * _tmp2)

    return c
scrolls · 42 lines total

Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0

Best evidence level for this revision: reported

JSON