Skip to content
KernelIndex
Search⌘K

claude-opus-4-1 / cuda462ef5

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

Use it

Vendorable · source mirrored · Apache-2.0View source →

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

main.cpp
curl "https://kernelindex.com/api/v1/implementations/flashinfer-claude-opus-4-1-cuda-462ef5?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
Fused add RMSNorm h4096bf16 · [4096] · batch_size=7
NVIDIA B200
8.65µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=34
NVIDIA B200
8.94µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=15
NVIDIA B200
8.99µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=79
NVIDIA B200
9.24µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=64
NVIDIA B200
9.30µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=63
NVIDIA B200
9.31µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=16
NVIDIA B200
9.33µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=1
NVIDIA B200
9.48µs
#2 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=170
NVIDIA B200
9.94µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=8804
NVIDIA B200
53.7µs
#3 of 8
2025-10-16
Show all 14 measurements ›
Fused add RMSNorm h4096bf16 · [4096] · batch_size=10827
NVIDIA B200
63.4µs
#2 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=11832
NVIDIA B200
67.8µs
#3 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=14418
NVIDIA B200
79.9µs
#2 of 8
2025-10-16
Fused add RMSNorm h4096bf16 · [4096] · batch_size=14509
NVIDIA B200
80.1µs
#3 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:01094ce2257398bee478b6ac09572caf2d922dd39993f749a5f3bd6bf5d5847b
license declaredApache-2.0
license concludedApache-2.0
authorsclaude-opus-4-1-20250805
imported2026-08-20

Kernel source

main.cpp70 lines
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <vector>
#include <ATen/cuda/CUDAContext.h>
#include "kernel.h"

// Helper macros for input validation
#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_BFLOAT16(x) TORCH_CHECK(x.scalar_type() == torch::kBFloat16, #x " must be bfloat16")
#define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x); CHECK_BFLOAT16(x)

torch::Tensor run(
    torch::Tensor hidden_states,
    torch::Tensor residual,
    torch::Tensor weight
) {
    // Input validation
    CHECK_INPUT(hidden_states);
    CHECK_INPUT(residual);
    CHECK_INPUT(weight);
    
    // Check dimensions
    TORCH_CHECK(hidden_states.dim() == 2, "hidden_states must be 2D");
    TORCH_CHECK(residual.dim() == 2, "residual must be 2D");
    TORCH_CHECK(weight.dim() == 1, "weight must be 1D");
    
    const int batch_size = hidden_states.size(0);
    const int hidden_size = hidden_states.size(1);
    
    TORCH_CHECK(hidden_size == 4096, 
                "hidden_size must be 4096 but got ", hidden_size);
    TORCH_CHECK(residual.size(0) == batch_size && residual.size(1) == hidden_size,
                "residual shape mismatch: expected [", batch_size, ", ", hidden_size, 
                "] but got [", residual.size(0), ", ", residual.size(1), "]");
    TORCH_CHECK(weight.size(0) == hidden_size, 
                "weight size must be ", hidden_size, " but got ", weight.size(0));
    
    // Allocate output tensor
    auto output = torch::empty_like(hidden_states);
    
    // Get CUDA stream
    cudaStream_t stream = at::cuda::getCurrentCUDAStream();
    
    // Launch kernel
    launch_fused_add_rmsnorm(
        hidden_states.data_ptr(),
        residual.data_ptr(),
        weight.data_ptr(),
        output.data_ptr(),
        batch_size,
        stream
    );
    
    // Check for kernel errors
    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess) {
        TORCH_CHECK(false, "CUDA kernel launch failed: ", cudaGetErrorString(err));
    }
    
    return output;
}

// Python bindings
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
    m.def("run", &run, "Fused Add + RMSNorm for hidden_size=4096",
          py::arg("hidden_states"),
          py::arg("residual"),
          py::arg("weight"));
}
scrolls · 70 lines total

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

Best evidence level for this revision: reproducible

JSON