Skip to content
KernelIndex
Search⌘K

submission 513510

elainewy · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-vectorsum-v2-513510?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
38.2ms
#92 of 96
2026-03-06

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:339f33de6ad986dbb685e143781385f84538dab0e21bb0b1787f32ee75518bcf
license declaredunknown
license concludedunknown
authorselainewy
imported2026-08-15

Kernel source

submission.py29 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 · 29 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