Skip to content
KernelIndex
Search⌘K

submission 101021

Siazed · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-nvfp4-gemv-101021?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 GEMVsuite of 3 cases
NVIDIA B200
64.4µs
#308 of 678
2025-11-24

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:099be5bfb911a376aea329d00612203f7e487e574acf73bdbf832e5d7e374c21
license declaredunknown
license concludedunknown
authorsSiazed
imported2026-08-26

Techniques

Extracted from the mirrored source by pattern, never inferred. Each row cites its line.

fp4Optimized NVFP4 GEMV using torch._scaled_mm with hardware acceleration.

Kernel source

submission.py38 lines
import torch
from task import input_t, output_t


@torch.no_grad()
def custom_kernel(data: input_t) -> output_t:
    """
    Optimized NVFP4 GEMV using torch._scaled_mm with hardware acceleration.
    
    Key optimizations:
    1. Uses pre-permuted scale factors (avoids CPU to_blocked computation)
    2. Makes scale factors contiguous for better memory access
    3. torch.no_grad() eliminates autograd overhead
    """
    a_ref, b_ref, _, _, sfa_permuted, sfb_permuted, c_ref = data
    
    # Get dimensions
    _, _, l = c_ref.shape
    
    # Pre-compute flattened scale factors for all batches
    # sfa_permuted: (32, 4, mn_blocks, 4, k_blocks, l)
    # Target: (l, flattened) matching to_blocked output
    scale_a_all = sfa_permuted.permute(5, 2, 4, 0, 1, 3).reshape(l, -1).contiguous()
    scale_b_all = sfb_permuted.permute(5, 2, 4, 0, 1, 3).reshape(l, -1).contiguous()
    
    # Process each batch
    for l_idx in range(l):
        res = torch._scaled_mm(
            a_ref[:, :, l_idx],
            b_ref[:, :, l_idx].t(),
            scale_a_all[l_idx],
            scale_b_all[l_idx],
            bias=None,
            out_dtype=torch.float16,
        )
        c_ref[:, 0, l_idx] = res[:, 0]
    
    return c_ref
scrolls · 38 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