submission 66199
vinu1729 · python · License unknown
Use it
Vendorable · source mirrored · license unknownView source →
No package. Vendor the mirrored source: 66 lines, June 9 Researcher Reciprocity License v1.0.
test.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-vectoradd-v2-66199?include=source"interfacepython
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp16
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:a649990770109c1a8f20140b2dcaab8e70bb282c0311a5aafd881a5e2b200b3c
license declaredunknown
license concludedunknown
authorsvinu1729
imported2026-08-15
Techniques
Extracted from the mirrored source by pattern, never inferred. Each row cites its line.
autotune
@triton.autotune(num-warps = 2
triton.Config({'BLOCK_SIZE': 256}, num_warps=2, num_stages=2),stages = 2
triton.Config({'BLOCK_SIZE': 256}, num_warps=2, num_stages=2),Kernel source
test.py66 lines
import torch
import triton
import triton.language as tl
@triton.autotune(
configs=[
triton.Config({'BLOCK_SIZE': 256}, num_warps=2, num_stages=2),
triton.Config({'BLOCK_SIZE': 512}, num_warps=2, num_stages=2),
triton.Config({'BLOCK_SIZE': 1024}, num_warps=4, num_stages=2),
triton.Config({'BLOCK_SIZE': 2048}, num_warps=4, num_stages=2),
triton.Config({'BLOCK_SIZE': 2048}, num_warps=8, num_stages=2),
triton.Config({'BLOCK_SIZE': 4096}, num_warps=8, num_stages=2),
triton.Config({'BLOCK_SIZE': 4096}, num_warps=8, num_stages=3),
],
key=['N'],
)
@triton.jit
def vectoradd_kernel(
a_ptr,
b_ptr,
c_ptr,
N,
BLOCK_SIZE: tl.constexpr,
):
"""
Ultra-optimized float16 vector addition for B200.
Uses autotuning for optimal configuration.
"""
pid = tl.program_id(0)
block_start = pid * BLOCK_SIZE
offsets = block_start + tl.arange(0, BLOCK_SIZE)
mask = offsets < N
# Load with cache eviction hints optimized for B200
a = tl.load(a_ptr + offsets, mask=mask, other=0.0, eviction_policy='evict_last')
b = tl.load(b_ptr + offsets, mask=mask, other=0.0, eviction_policy='evict_last')
# Perform addition
c = a + b
# Store with write-back policy
tl.store(c_ptr + offsets, c, mask=mask, eviction_policy='evict_last')
def custom_kernel(data):
"""
Main kernel with autotuning for peak B200 performance.
"""
A, B, C = data
# Ensure contiguous layout
A = A.contiguous()
B = B.contiguous()
C = C.contiguous()
N = A.numel()
# Grid configuration - will be optimized by autotune
grid = lambda meta: (triton.cdiv(N, meta['BLOCK_SIZE']),)
# Launch autotuned kernel
vectoradd_kernel[grid](A, B, C, N)
return C
scrolls · 66 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 66197.
⋯ 1 unchanged linesimport tritonimport triton.language as tl++ @triton.autotune(+ configs=[+ triton.Config({'BLOCK_SIZE': 256}, num_warps=2, num_stages=2),+ triton.Config({'BLOCK_SIZE': 512}, num_warps=2, num_stages=2),+ triton.Config({'BLOCK_SIZE': 1024}, num_warps=4, num_stages=2),+ triton.Config({'BLOCK_SIZE': 2048}, num_warps=4, num_stages=2),+ triton.Config({'BLOCK_SIZE': 2048}, num_warps=8, num_stages=2),+ triton.Config({'BLOCK_SIZE': 4096}, num_warps=8, num_stages=2),+ triton.Config({'BLOCK_SIZE': 4096}, num_warps=8, num_stages=3),+ ],+ key=['N'],+ )@triton.jitdef vectoradd_kernel(- a_ptr, # Pointer to first input tensor- b_ptr, # Pointer to second input tensor- c_ptr, # Pointer to output tensor- N, # Total number of elements- BLOCK_SIZE: tl.constexpr, # Number of elements per block+ a_ptr,+ b_ptr,+ c_ptr,+ N,+ BLOCK_SIZE: tl.constexpr,):"""- Optimized float16 vector addition kernel.- Each program processes BLOCK_SIZE elements.+ Ultra-optimized float16 vector addition for B200.+ Uses autotuning for optimal configuration."""- # Get program IDpid = tl.program_id(0)-- # Compute block start offsetblock_start = pid * BLOCK_SIZE-- # Generate offsets for this blockoffsets = block_start + tl.arange(0, BLOCK_SIZE)-- # Create mask for boundary checking (handles non-multiple of BLOCK_SIZE)mask = offsets < N- # Load data with vectorized operations (float16)- # Use eviction policy for better cache utilization- a = tl.load(a_ptr + offsets, mask=mask, other=0.0, eviction_policy='evict_first')- b = tl.load(b_ptr + offsets, mask=mask, other=0.0, eviction_policy='evict_first')+ # Load with cache eviction hints optimized for B200+ a = tl.load(a_ptr + offsets, mask=mask, other=0.0, eviction_policy='evict_last')+ b = tl.load(b_ptr + offsets, mask=mask, other=0.0, eviction_policy='evict_last')# Perform additionc = a + b- # Store result with vectorized write- tl.store(c_ptr + offsets, c, mask=mask)+ # Store with write-back policy+ tl.store(c_ptr + offsets, c, mask=mask, eviction_policy='evict_last')def custom_kernel(data):"""- Main kernel function that launches the Triton kernel.-- Args:- data: Tuple of (A, B, C) where A and B are input tensors,- and C is the pre-allocated output tensor.-- Returns:- C: Output tensor containing element-wise sum+ Main kernel with autotuning for peak B200 performance."""A, B, C = data- # Ensure inputs are contiguous for optimal memory access+ # Ensure contiguous layoutA = A.contiguous()B = B.contiguous()+ C = C.contiguous()- # Get tensor dimensionsN = A.numel()- # Choose optimal block size based on GPU architecture- # Larger block sizes for better memory coalescing and fewer kernel launches- # Powers of 2 work best for GPU memory systems- BLOCK_SIZE = 1024 # Optimal for most modern GPUs (A100, H100, B200)-- # Calculate grid size (number of programs to launch)+ # Grid configuration - will be optimized by autotunegrid = lambda meta: (triton.cdiv(N, meta['BLOCK_SIZE']),)- # Launch kernel- vectoradd_kernel[grid](- A, B, C, N,- BLOCK_SIZE=BLOCK_SIZE,- )+ # Launch autotuned kernel+ vectoradd_kernel[grid](A, B, C, N)return C
scrolls · 106 diff lines total
Best evidence level for this revision: reported
JSON