Skip to content
KernelIndex
Search⌘K

claude-opus-4-1 / cuda8eba35

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

Use it

Vendorable · source mirrored · Apache-2.0View source →

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

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

Benchmark evidence

7 measurements across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
Fused add RMSNorm h2048bf16 · [2048] · batch_size=6
NVIDIA B200
7.11µs
#4 of 8
2025-10-16
Fused add RMSNorm h2048bf16 · [2048] · batch_size=64
NVIDIA B200
8.03µs
#5 of 8
2025-10-16
Fused add RMSNorm h2048bf16 · [2048] · batch_size=34
NVIDIA B200
8.04µs
#5 of 8
2025-10-16
Fused add RMSNorm h2048bf16 · [2048] · batch_size=1
NVIDIA B200
8.04µs
#5 of 8
2025-10-16
Fused add RMSNorm h2048bf16 · [2048] · batch_size=79
NVIDIA B200
8.10µs
#6 of 8
2025-10-16
Fused add RMSNorm h2048bf16 · [2048] · batch_size=12383
NVIDIA B200
51.2µs
#5 of 8
2025-10-16
Fused add RMSNorm h2048bf16 · [2048] · batch_size=16254
NVIDIA B200
63.8µs
#5 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:a543ad0cff7785996cca0a9c98023a4177e0d678142d79748f663c0059de2fe4
license declaredApache-2.0
license concludedApache-2.0
authorsclaude-opus-4-1-20250805
imported2026-08-20

Kernel source

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

// Main run function
torch::Tensor run(
    torch::Tensor hidden_states,
    torch::Tensor residual,
    torch::Tensor weight
) {
    // Validate inputs
    TORCH_CHECK(hidden_states.is_cuda(), "hidden_states must be a CUDA tensor");
    TORCH_CHECK(residual.is_cuda(), "residual must be a CUDA tensor");
    TORCH_CHECK(weight.is_cuda(), "weight must be a CUDA tensor");
    
    TORCH_CHECK(hidden_states.dtype() == torch::kBFloat16, "hidden_states must be bfloat16");
    TORCH_CHECK(residual.dtype() == torch::kBFloat16, "residual must be bfloat16");
    TORCH_CHECK(weight.dtype() == torch::kBFloat16, "weight must be bfloat16");
    
    // Check dimensions
    auto hidden_shape = hidden_states.sizes();
    auto residual_shape = residual.sizes();
    auto weight_shape = weight.sizes();
    
    TORCH_CHECK(hidden_shape.size() == 2, "hidden_states must be 2D");
    TORCH_CHECK(residual_shape.size() == 2, "residual must be 2D");
    TORCH_CHECK(weight_shape.size() == 1, "weight must be 1D");
    
    int batch_size = hidden_shape[0];
    int hidden_size = hidden_shape[1];
    
    TORCH_CHECK(hidden_size == HIDDEN_SIZE, "hidden_size must be 2048");
    TORCH_CHECK(residual_shape[0] == batch_size, "residual batch size mismatch");
    TORCH_CHECK(residual_shape[1] == hidden_size, "residual hidden size mismatch");
    TORCH_CHECK(weight_shape[0] == hidden_size, "weight size mismatch");
    
    // Ensure contiguous tensors
    hidden_states = hidden_states.contiguous();
    residual = residual.contiguous();
    weight = weight.contiguous();
    
    // 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_h2048(
        hidden_states.data_ptr(),
        residual.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 bindings
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
    m.def("run", &run, "Fused Add RMSNorm H2048",
          py::arg("hidden_states"),
          py::arg("residual"),
          py::arg("weight"));
}
scrolls · 71 lines total

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

Best evidence level for this revision: reproducible

JSON