Skip to content
KernelIndex
Search⌘K

claude-opus-4-1 / cuda7a69e8

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

Use it

Vendorable · source mirrored · Apache-2.0View source →

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

main.cpp
curl "https://kernelindex.com/api/v1/implementations/flashinfer-claude-opus-4-1-cuda-7a69e8?include=source"
interfacecuda
revisionda915083d4c7
symbolrun
pathmain.cpp
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesbf16

Benchmark evidence

8 measurements across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
RMSNorm h1536bf16 · [1536] · batch_size=18
NVIDIA B200
8.45µs
#4 of 8
2025-10-16
RMSNorm h1536bf16 · [1536] · batch_size=7
NVIDIA B200
8.49µs
#4 of 8
2025-10-16
RMSNorm h1536bf16 · [1536] · batch_size=32
NVIDIA B200
8.74µs
#4 of 8
2025-10-16
RMSNorm h1536bf16 · [1536] · batch_size=1
NVIDIA B200
9.39µs
#4 of 8
2025-10-16
RMSNorm h1536bf16 · [1536] · batch_size=64
NVIDIA B200
9.67µs
#4 of 8
2025-10-16
RMSNorm h1536bf16 · [1536] · batch_size=539
NVIDIA B200
10.3µs
#4 of 8
2025-10-16
RMSNorm h1536bf16 · [1536] · batch_size=11949
NVIDIA B200
130.6µs
#7 of 8
2025-10-16
RMSNorm h1536bf16 · [1536] · batch_size=14521
NVIDIA B200
155.5µs
#7 of 8
2025-10-16

Reproduction-ready · How evidence levels are derived →

Source and license

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

Kernel source

main.cpp76 lines
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include "kernel.h"

// Helper function to check CUDA errors
#define CHECK_CUDA(x) TORCH_CHECK(x == cudaSuccess, "CUDA error: ", cudaGetErrorString(x))

// Helper function to check tensor properties
void check_input(torch::Tensor tensor, const std::string& name, 
                 c10::ScalarType expected_dtype, 
                 c10::IntArrayRef expected_shape) {
    TORCH_CHECK(tensor.is_cuda(), name, " must be a CUDA tensor");
    TORCH_CHECK(tensor.is_contiguous(), name, " must be contiguous");
    TORCH_CHECK(tensor.dtype() == expected_dtype, 
                name, " must have dtype ", expected_dtype);
    
    if (expected_shape.size() > 0) {
        auto shape = tensor.sizes();
        for (size_t i = 0; i < expected_shape.size(); i++) {
            if (expected_shape[i] >= 0) {
                TORCH_CHECK(shape[i] == expected_shape[i],
                           name, " dimension ", i, " must be ", expected_shape[i],
                           " but got ", shape[i]);
            }
        }
    }
}

torch::Tensor run(torch::Tensor hidden_states, torch::Tensor weight) {
    // Set CUDA device
    c10::cuda::CUDAGuard device_guard(hidden_states.device());
    
    // Check inputs
    TORCH_CHECK(hidden_states.dim() == 2, "hidden_states must be 2-dimensional");
    TORCH_CHECK(weight.dim() == 1, "weight must be 1-dimensional");
    
    int batch_size = hidden_states.size(0);
    int hidden_size = hidden_states.size(1);
    
    TORCH_CHECK(hidden_size == HIDDEN_SIZE, 
                "hidden_size must be ", HIDDEN_SIZE, " but got ", hidden_size);
    TORCH_CHECK(weight.size(0) == HIDDEN_SIZE,
                "weight size must be ", HIDDEN_SIZE, " but got ", weight.size(0));
    
    // Check dtypes
    check_input(hidden_states, "hidden_states", torch::kBFloat16, {-1, HIDDEN_SIZE});
    check_input(weight, "weight", torch::kBFloat16, {HIDDEN_SIZE});
    
    // Allocate output tensor
    auto output = torch::empty_like(hidden_states);
    
    // Get CUDA stream
    cudaStream_t stream = at::cuda::getCurrentCUDAStream();
    
    // Launch kernel
    CHECK_CUDA(launch_rmsnorm_h1536(
        hidden_states.data_ptr(),
        weight.data_ptr(),
        output.data_ptr(),
        batch_size,
        stream
    ));
    
    // Synchronize if needed (PyTorch handles this automatically in most cases)
    // cudaStreamSynchronize(stream);
    
    return output;
}

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

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

Best evidence level for this revision: reproducible

JSON