Skip to content
KernelIndex
Search⌘K

submission 153640

olibartfast · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

vectorsum_v2_160000.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-vectorsum-v2-153640?include=source"
interfacepython
Compatibility
measured onNVIDIA A100
declared hardwareNVIDIA A100
architecturessm_80
dtypesfp32

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
Vector sum reductionsuite of 6 cases
NVIDIA A100
39.3ms
#93 of 96
2025-12-13

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:9e97a0036eb05c1560995862e912a55497f8903ec2a03047c1bbbd3772b4c6bd
license declaredunknown
license concludedunknown
authorsolibartfast
imported2026-08-15

Kernel source

vectorsum_v2_160000.py30 lines
import torch
import triton
import triton.language as tl

@triton.jit
def sum_kernel(x_ptr, output_ptr, n_elements, BLOCK_SIZE: tl.constexpr):
    pid = tl.program_id(0)
    offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
    mask = offsets < n_elements
    x = tl.load(x_ptr + offsets, mask=mask, other=0.0)
    tl.atomic_add(output_ptr, tl.sum(x))

def custom_kernel(data):
    x = data[0].flatten()
    
    # Kahan summation for numerical stability
    total = torch.tensor(0.0, dtype=torch.float64, device=x.device)
    c = torch.tensor(0.0, dtype=torch.float64, device=x.device)
    
    # Process in chunks to reduce error accumulation
    chunk_size = 65536
    for i in range(0, x.numel(), chunk_size):
        chunk = x[i:i+chunk_size].to(torch.float64)
        y = chunk.sum() - c
        t = total + y
        c = (t - total) - y
        total = t
    
    return total.to(x.dtype)
scrolls · 30 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