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
Show all 14 measurements ›Showing all 14 measurements ⌄
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