Skip to content
KernelIndex
Search⌘K

submission 544956

rajesh0042 · 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.

matmul_v5.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-matmul-v2-544956?include=source"
interfacepython
Compatibility
measured onNVIDIA L4
declared hardwareNVIDIA L4
architecturessm_89
dtypesfp16

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
FP16 matmulsuite of 8 cases
NVIDIA L4
2.26ms
#4 of 12
2026-03-13

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:112c9b740dff4847c0b9b518893b941ea4fb3fa3af8c4e78cb92d75bffe9e81e
license declaredunknown
license concludedunknown
authorsrajesh0042
imported2026-08-15

Kernel source

matmul_v5.py38 lines
import os
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"

import torch
from task import input_t, output_t

torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = True

# Try FP32 accumulation with cuBLAS - this uses different tensor core paths
# torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction controls this
torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = True

# Pre-allocate and warm cuBLAS for benchmark shapes
_cache = {}

def _warmup():
    sizes = [
        (128, 128, 128), (256, 256, 256), (512, 512, 512),
        (1024, 1024, 1024), (2048, 2048, 2048),
        (1024, 1536, 1024), (2048, 3072, 2048), (4096, 5120, 4096),
    ]
    for m, n, k in sizes:
        a = torch.randn(m, k, device='cuda', dtype=torch.float16)
        b = torch.randn(k, n, device='cuda', dtype=torch.float16)
        c = torch.empty(m, n, device='cuda', dtype=torch.float16)
        # Run twice to warm cuBLAS handle caching
        torch.mm(a, b, out=c)
        torch.mm(a, b, out=c)
    torch.cuda.synchronize()

_warmup()

def custom_kernel(data: input_t) -> output_t:
    a, b, c = data
    torch.mm(a, b, out=c)
    return c
scrolls · 38 lines total

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

Changes from previous submission

Against this author's previous submission submission 544953.

Best evidence level for this revision: reported

JSON