Skip to content
KernelIndex
Search⌘K

claude-opus-4-1 / tritonbf2710

claude-opus-4-1_triton_bf2710 · claude-opus-4-1-20250805 · triton · Apache-2.0

Use it

Vendorable · source mirrored · Apache-2.0View source →

No package. Vendor the mirrored source: 91 lines, Apache-2.0, pinned at da91508.

main.py
curl "https://kernelindex.com/api/v1/implementations/flashinfer-claude-opus-4-1-triton-bf2710?include=source"
interfacetriton
revisionda915083d4c7
symbolrun
pathmain.py
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesbf16

Benchmark evidence

14 measurements across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
RMSNorm h128bf16 · [128] · batch_size=256
NVIDIA B200
6.26µs
#6 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=32
NVIDIA B200
6.26µs
#6 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=4
NVIDIA B200
6.28µs
#7 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=316
NVIDIA B200
6.28µs
#7 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=136
NVIDIA B200
6.29µs
#7 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=192
NVIDIA B200
6.29µs
#7 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=24
NVIDIA B200
6.30µs
#6 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=1088
NVIDIA B200
6.55µs
#6 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=2048
NVIDIA B200
8.06µs
#4 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=2528
NVIDIA B200
8.13µs
#4 of 9
2025-10-16
Show all 14 measurements ›
RMSNorm h128bf16 · [128] · batch_size=49532
NVIDIA B200
32.7µs
#4 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=65016
NVIDIA B200
40.8µs
#6 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=396256
NVIDIA B200
212.4µs
#7 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=520128
NVIDIA B200
276.3µs
#6 of 9
2025-10-16

Reported · How evidence levels are derived →

Source and license

sourcehttps://huggingface.co/datasets/flashinfer-ai/flashinfer-trace
commitda915083d4c7c5e61aa3005e3d17ae488e0fc71c
revision digestsha256:8a7c7c4bd3830dc1c2271267d9eb2a5d8fd2964c3a60e9e8bb9754ea95220143
license declaredApache-2.0
license concludedApache-2.0
authorsclaude-opus-4-1-20250805
imported2026-08-20

Kernel source

main.py91 lines
import torch
import triton
import triton.language as tl

@triton.jit
def rmsnorm_h128_kernel(
    hidden_states_ptr,
    weight_ptr,
    output_ptr,
    batch_size,
    HIDDEN_SIZE: tl.constexpr,
    EPS: tl.constexpr,
):
    # Process one row per program
    row_idx = tl.program_id(0)
    
    if row_idx >= batch_size:
        return
    
    # Load the entire row (hidden_size = 128)
    row_start = row_idx * HIDDEN_SIZE
    offsets = tl.arange(0, HIDDEN_SIZE)
    
    # Load hidden states for this row
    hidden_states = tl.load(hidden_states_ptr + row_start + offsets).to(tl.float32)
    
    # Compute RMS normalization
    # Calculate mean of squares
    squared = hidden_states * hidden_states
    mean_squared = tl.sum(squared, axis=0) / HIDDEN_SIZE
    
    # Compute inverse RMS
    inv_rms = tl.rsqrt(mean_squared + EPS)
    
    # Load weights
    weights = tl.load(weight_ptr + offsets).to(tl.float32)
    
    # Apply normalization and scaling
    normalized = hidden_states * inv_rms
    output = normalized * weights
    
    # Store result
    tl.store(output_ptr + row_start + offsets, output.to(tl.bfloat16))

def run(hidden_states, weight):
    # Handle device management
    original_device = hidden_states.device
    
    # Move to GPU if needed
    if not hidden_states.is_cuda:
        if not torch.cuda.is_available():
            raise RuntimeError("CUDA is not available but GPU execution is required")
        hidden_states = hidden_states.cuda()
    
    if not weight.is_cuda:
        if not torch.cuda.is_available():
            raise RuntimeError("CUDA is not available but GPU execution is required")
        weight = weight.cuda()
    
    # Validate shapes and dtypes
    batch_size, hidden_size = hidden_states.shape
    assert hidden_size == 128, f"hidden_size must be 128, got {hidden_size}"
    assert weight.shape == (128,), f"weight shape must be [128], got {weight.shape}"
    
    # Convert to bfloat16 if needed
    if hidden_states.dtype != torch.bfloat16:
        hidden_states = hidden_states.to(torch.bfloat16)
    if weight.dtype != torch.bfloat16:
        weight = weight.to(torch.bfloat16)
    
    # Allocate output tensor
    output = torch.empty_like(hidden_states, device=hidden_states.device, dtype=torch.bfloat16)
    
    # Configure grid
    grid = (batch_size,)
    
    # Launch kernel
    rmsnorm_h128_kernel[grid](
        hidden_states,
        weight,
        output,
        batch_size,
        HIDDEN_SIZE=128,
        EPS=1e-6,
    )
    
    # Move result back to original device if needed
    if original_device != output.device:
        output = output.to(original_device)
    
    return output
scrolls · 91 lines total

Source code from FlashInfer-Bench (flashinfer-ai/flashinfer-trace) · Apache-2.0

Best evidence level for this revision: reported

JSON