Skip to content
KernelIndex
Search⌘K

submission 555563

kitrak_rev. · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-gated-deltanet-recompute-w-u-555563?include=source"
interfacepython
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp32

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
NVIDIA B200
6.54µs
#1 of 28
2026-03-15

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:b9a4d7b087e8b3b0c4bfd875aff04bdeb1793b04ce920ca302c853162a0fa84a
license declaredunknown
license concludedunknown
authorskitrak_rev.
imported2026-08-15

Techniques

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

num-warps = 4(1, 64, 2, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
stages = 2(1, 64, 2, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),

Kernel source

submission.py69 lines
#!POPCORN leaderboard gated_deltanet_recompute_w_u
#!POPCORN gpu B200_Nebius

# TileIR + TF32 + exp2. Use ieee for test shapes (leaderboard stability).
import os
os.environ["ENABLE_TILE"] = "1"
os.environ["HELION_BACKEND"] = "tileir"

from task import input_t, output_t

import torch
import helion
import helion.language as hl

LOG2_E = 1.4426950408889634

# Test shapes: ieee for stability; benchmarks: tf32 for speed
SHAPES_USE_IEEE = {(1, 64, 2, 64, 64), (2, 128, 4, 64, 64), (1, 256, 4, 64, 128)}

# num_warps=8 for K/V=128 (larger blocks)
SHAPE_CONFIGS = {
    (1, 64, 2, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
    (2, 128, 4, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
    (1, 256, 4, 64, 128): helion.Config(block_sizes=[], num_warps=8, num_stages=2),
    (1, 64, 1, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
    (2, 512, 3, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
    (2, 1024, 3, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
    (3, 1024, 4, 100, 100): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
    (4, 1024, 4, 128, 128): helion.Config(block_sizes=[], num_warps=8, num_stages=2),
    (2, 1536, 4, 128, 128): helion.Config(block_sizes=[], num_warps=8, num_stages=2),
    (4, 2048, 8, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
}


def _make_kernel(config, dot_precision: str = "tf32"):
    @helion.kernel(static_shapes=True, dot_precision=dot_precision, config=config)
    def kernel(k, v, beta, A, g):
        B, T, H, K = k.shape
        V = v.shape[-1]
        C = hl.specialize(A.shape[-1])
        K, V = hl.specialize(K), hl.specialize(V)
        w_out, u_out = torch.empty_like(k), torch.empty_like(v)
        BH = B * H
        for flat_bh, rt in hl.tile([BH, T], block_size=[1, C]):
            b_idx, h_idx = flat_bh.begin // H, flat_bh.begin % H
            A_chunk = A[b_idx, rt, h_idx, :]
            k_chunk = k[b_idx, rt, h_idx, :]
            v_chunk = v[b_idx, rt, h_idx, :]
            beta_chunk = beta[b_idx, rt, h_idx]
            g_chunk = g[b_idx, rt, h_idx]
            decay = torch.exp2(g_chunk * LOG2_E)
            scaled_k = k_chunk * (beta_chunk * decay)[:, None]
            scaled_v = v_chunk * beta_chunk[:, None]
            w_out[b_idx, rt, h_idx, :] = hl.dot(A_chunk, scaled_k, out_dtype=torch.float32).to(k.dtype)
            u_out[b_idx, rt, h_idx, :] = hl.dot(A_chunk, scaled_v, out_dtype=torch.float32).to(v.dtype)
        return w_out, u_out
    return kernel


_KERNELS = {
    shape: _make_kernel(cfg, "ieee" if shape in SHAPES_USE_IEEE else "tf32")
    for shape, cfg in SHAPE_CONFIGS.items()
}


def custom_kernel(data: input_t) -> output_t:
    k, v, beta, A, g = data
    return _KERNELS[(k.shape[0], k.shape[1], k.shape[2], k.shape[3], v.shape[-1])](k, v, beta, A, g)
scrolls · 69 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 554405.

#!POPCORN leaderboard gated_deltanet_recompute_w_u
#!POPCORN gpu B200_Nebius
- # TileIR backend (faster than Triton+ACF for this kernel). ACFs not compatible with TileIR.
+ # TileIR + TF32 + exp2. Use ieee for test shapes (leaderboard stability).
import os
os.environ["ENABLE_TILE"] = "1"
os.environ["HELION_BACKEND"] = "tileir"
⋯ 4 unchanged lines
import helion
import helion.language as hl
- SHAPE_CONFIGS: dict[tuple, helion.Config] = {
+ LOG2_E = 1.4426950408889634
+
+ # Test shapes: ieee for stability; benchmarks: tf32 for speed
+ SHAPES_USE_IEEE = {(1, 64, 2, 64, 64), (2, 128, 4, 64, 64), (1, 256, 4, 64, 128)}
+
+ # num_warps=8 for K/V=128 (larger blocks)
+ SHAPE_CONFIGS = {
(1, 64, 2, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
(2, 128, 4, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
- (1, 256, 4, 64, 128): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
+ (1, 256, 4, 64, 128): helion.Config(block_sizes=[], num_warps=8, num_stages=2),
(1, 64, 1, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
(2, 512, 3, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
(2, 1024, 3, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
(3, 1024, 4, 100, 100): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
- (4, 1024, 4, 128, 128): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
- (2, 1536, 4, 128, 128): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
+ (4, 1024, 4, 128, 128): helion.Config(block_sizes=[], num_warps=8, num_stages=2),
+ (2, 1536, 4, 128, 128): helion.Config(block_sizes=[], num_warps=8, num_stages=2),
(4, 2048, 8, 64, 64): helion.Config(block_sizes=[], num_warps=4, num_stages=2),
}
- def _make_kernel(config: helion.Config):
- @helion.kernel(static_shapes=True, dot_precision="ieee", config=config)
+ def _make_kernel(config, dot_precision: str = "tf32"):
+ @helion.kernel(static_shapes=True, dot_precision=dot_precision, config=config)
def kernel(k, v, beta, A, g):
B, T, H, K = k.shape
V = v.shape[-1]
C = hl.specialize(A.shape[-1])
- K = hl.specialize(K)
- V = hl.specialize(V)
- w_out = torch.empty_like(k)
- u_out = torch.empty_like(v)
+ K, V = hl.specialize(K), hl.specialize(V)
+ w_out, u_out = torch.empty_like(k), torch.empty_like(v)
BH = B * H
for flat_bh, rt in hl.tile([BH, T], block_size=[1, C]):
- b_idx = flat_bh.begin // H
- h_idx = flat_bh.begin % H
- A_chunk = A[b_idx, rt, h_idx, :].to(torch.float32)
- k_chunk = k[b_idx, rt, h_idx, :].to(torch.float32)
- v_chunk = v[b_idx, rt, h_idx, :].to(torch.float32)
- beta_chunk = beta[b_idx, rt, h_idx].to(torch.float32)
- g_chunk = g[b_idx, rt, h_idx].to(torch.float32)
- scaled_k = k_chunk * (beta_chunk * torch.exp(g_chunk))[:, None]
+ b_idx, h_idx = flat_bh.begin // H, flat_bh.begin % H
+ A_chunk = A[b_idx, rt, h_idx, :]
+ k_chunk = k[b_idx, rt, h_idx, :]
+ v_chunk = v[b_idx, rt, h_idx, :]
+ beta_chunk = beta[b_idx, rt, h_idx]
+ g_chunk = g[b_idx, rt, h_idx]
+ decay = torch.exp2(g_chunk * LOG2_E)
+ scaled_k = k_chunk * (beta_chunk * decay)[:, None]
scaled_v = v_chunk * beta_chunk[:, None]
- w_chunk = hl.dot(A_chunk, scaled_k, out_dtype=torch.float32)
- u_chunk = hl.dot(A_chunk, scaled_v, out_dtype=torch.float32)
- w_out[b_idx, rt, h_idx, :] = w_chunk.to(k.dtype)
- u_out[b_idx, rt, h_idx, :] = u_chunk.to(v.dtype)
+ w_out[b_idx, rt, h_idx, :] = hl.dot(A_chunk, scaled_k, out_dtype=torch.float32).to(k.dtype)
+ u_out[b_idx, rt, h_idx, :] = hl.dot(A_chunk, scaled_v, out_dtype=torch.float32).to(v.dtype)
return w_out, u_out
return kernel
- _KERNELS = {shape: _make_kernel(cfg) for shape, cfg in SHAPE_CONFIGS.items()}
+ _KERNELS = {
+ shape: _make_kernel(cfg, "ieee" if shape in SHAPES_USE_IEEE else "tf32")
+ for shape, cfg in SHAPE_CONFIGS.items()
+ }
def custom_kernel(data: input_t) -> output_t:
k, v, beta, A, g = data
- B, T, H, K = k.shape
- V = v.shape[-1]
- return _KERNELS[(B, T, H, K, V)](k, v, beta, A, g)
+ return _KERNELS[(k.shape[0], k.shape[1], k.shape[2], k.shape[3], v.shape[-1])](k, v, beta, A, g)
scrolls · 92 diff lines total

Best evidence level for this revision: reported

JSON