Skip to content
KernelIndex
Search⌘K

claude-opus-4-1 / cuda8b7225

claude-opus-4-1_cuda_8b7225 · claude-opus-4-1-20250805 · cuda · Apache-2.0

Use it

Vendorable · source mirrored · Apache-2.0View source →

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

main.cpp
curl "https://kernelindex.com/api/v1/implementations/flashinfer-claude-opus-4-1-cuda-8b7225?include=source"
interfacecuda
revisionda915083d4c7
symbolrun
pathmain.cpp
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=32
NVIDIA B200
6.20µs
#4 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=24
NVIDIA B200
6.20µs
#3 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=256
NVIDIA B200
6.21µs
#5 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=316
NVIDIA B200
6.22µs
#5 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=136
NVIDIA B200
6.23µs
#4 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=192
NVIDIA B200
6.24µs
#5 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=4
NVIDIA B200
6.27µs
#5 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=1088
NVIDIA B200
7.14µs
#8 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=2048
NVIDIA B200
8.18µs
#7 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=2528
NVIDIA B200
8.22µs
#8 of 9
2025-10-16
Show all 14 measurements ›
RMSNorm h128bf16 · [128] · batch_size=49532
NVIDIA B200
32.8µs
#7 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=65016
NVIDIA B200
40.9µs
#8 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=396256
NVIDIA B200
210.9µs
#3 of 9
2025-10-16
RMSNorm h128bf16 · [128] · batch_size=520128
NVIDIA B200
274.4µs
#2 of 9
2025-10-16

Reproduction-ready · How evidence levels are derived →

Source and license

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

Kernel source

main.cpp78 lines
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include <stdexcept>

#include "kernel.h"

// Error checking macro
#define CHECK_CUDA(x) TORCH_CHECK(x.device().is_cuda(), #x " must be a CUDA tensor")
#define CHECK_CONTIGUOUS(x) TORCH_CHECK(x.is_contiguous(), #x " must be contiguous")
#define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)

// Main run function
torch::Tensor run(
    torch::Tensor hidden_states,
    torch::Tensor weight
) {
    // Validate inputs
    CHECK_INPUT(hidden_states);
    CHECK_INPUT(weight);
    
    // Check dimensions
    TORCH_CHECK(hidden_states.dim() == 2, 
                "hidden_states must be 2D tensor, got ", hidden_states.dim(), "D");
    TORCH_CHECK(weight.dim() == 1, 
                "weight must be 1D tensor, got ", weight.dim(), "D");
    
    const int64_t batch_size = hidden_states.size(0);
    const int64_t hidden_size = hidden_states.size(1);
    
    TORCH_CHECK(hidden_size == HIDDEN_SIZE, 
                "hidden_size must be 128, got ", hidden_size);
    TORCH_CHECK(weight.size(0) == HIDDEN_SIZE, 
                "weight size must be 128, got ", weight.size(0));
    
    // Check data types
    TORCH_CHECK(hidden_states.scalar_type() == torch::kBFloat16, 
                "hidden_states must be bfloat16, got ", hidden_states.scalar_type());
    TORCH_CHECK(weight.scalar_type() == torch::kBFloat16, 
                "weight must be bfloat16, got ", weight.scalar_type());
    
    // Ensure same device
    TORCH_CHECK(hidden_states.device() == weight.device(),
                "hidden_states and weight must be on the same device");
    
    // Set device guard
    c10::cuda::CUDAGuard device_guard(hidden_states.device());
    
    // Allocate output tensor
    auto output = torch::empty_like(hidden_states);
    
    // Get CUDA stream
    cudaStream_t stream = at::cuda::getCurrentCUDAStream();
    
    // Launch kernel
    launch_rmsnorm_h128(
        hidden_states.data_ptr(),
        weight.data_ptr(),
        output.data_ptr(),
        static_cast<int>(batch_size),
        stream
    );
    
    // Check for errors
    auto error = cudaGetLastError();
    TORCH_CHECK(error == cudaSuccess, 
                "CUDA kernel launch failed: ", cudaGetErrorString(error));
    
    return output;
}

// Python module binding
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
    m.def("run", &run, "RMSNorm forward pass (CUDA)",
          py::arg("hidden_states"),
          py::arg("weight"));
}
scrolls · 78 lines total

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

Best evidence level for this revision: reproducible

JSON