submission 552497
dpang · python · License unknown
Use it
Vendorable · source mirrored · license unknownView source →
No package. Vendor the mirrored source: 68 lines, June 9 Researcher Reciprocity License v1.0.
submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-fp8-quant-552497?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
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:c28e5cd1dd568c83c9770d7199a66e81f2beab8ce63244507ccd82517040322c
license declaredunknown
license concludedunknown
authorsdpang
imported2026-08-15
Techniques
Extracted from the mirrored source by pattern, never inferred. Each row cites its line.
num-warps = 4
OPTIMIZED = helion.Config(block_sizes=[32], num_warps=4, num_stages=2)stages = 2
OPTIMIZED = helion.Config(block_sizes=[32], num_warps=4, num_stages=2)Kernel source
submission.py68 lines
from task import input_t, output_t
import torch
import helion
import helion.language as hl
FP8_MAX = 448.0
FP8_MIN = -448.0
FP8_EPS = 1e-10
OPTIMIZED = helion.Config(block_sizes=[32], num_warps=4, num_stages=2)
SHAPE_CONFIGS: dict[tuple, helion.Config] = {
(1, 256, 64): OPTIMIZED,
(4, 512, 128): OPTIMIZED,
(16, 1024, 64): OPTIMIZED,
(1, 4096, 128): OPTIMIZED,
(8, 4096, 128): OPTIMIZED,
(16, 4096, 128): OPTIMIZED,
(256, 4096, 128): OPTIMIZED,
(256, 8192, 128): OPTIMIZED,
(4096, 7168, 128): OPTIMIZED,
}
def _make_kernel(config: helion.Config):
@helion.kernel(static_shapes=True, config=config)
def kernel(
data: torch.Tensor,
scales_out: torch.Tensor,
) -> torch.Tensor:
nrows = data.size(0)
ncols = hl.specialize(data.size(1))
qout = torch.empty(nrows, ncols, dtype=torch.float32, device=data.device)
for rr in hl.tile(nrows):
row = data[rr, :].to(torch.float32)
amax = torch.amax(torch.abs(row), dim=-1).clamp(min=FP8_EPS)
scale = amax / FP8_MAX
qout[rr, :] = (row / scale[:, None]).clamp(FP8_MIN, FP8_MAX)
scales_out[rr] = scale
return qout
return kernel
_KERNELS = {shape: _make_kernel(cfg) for shape, cfg in SHAPE_CONFIGS.items()}
def custom_kernel(data: input_t) -> output_t:
x, x_q, x_s = data
T, H = x.shape
G = x_s.shape[1]
gsz = H // G
N = T * G
kernel = _KERNELS[(T, H, gsz)]
flat_in = x.reshape(N, gsz)
flat_s = x_s.reshape(N)
flat_q = kernel(flat_in, flat_s)
x_q[...] = flat_q.reshape(T, H)
x_s[...] = flat_s.reshape(T, G)
return x_q, x_s
scrolls · 68 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