claude-opus-4-1-20250805 / cuda6fecc6
claude-opus-4-1-20250805_cuda_6fecc6 · claude-opus-4-1-20250805 · cuda · Apache-2.0
Use it
Vendorable · source mirrored · Apache-2.0View source →
No package. Vendor the mirrored source: 90 lines, Apache-2.0, pinned at da91508.
main.cpp
curl "https://kernelindex.com/api/v1/implementations/flashinfer-claude-opus-4-1-20250805-cuda-6fecc6?include=source"interfacecuda
revisionda915083d4c7
symbolrun
pathmain.cpp
Compatibility
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp16
Benchmark evidence
No published measurement for this revision.
No evidence · How evidence levels are derived →
Source and license
sourcehttps://huggingface.co/datasets/flashinfer-ai/flashinfer-trace
commitda915083d4c7c5e61aa3005e3d17ae488e0fc71c
revision digestsha256:c64aec36baa9489add7b03318069fe18755d76144788241e071968fc9c302a72
license declaredApache-2.0
license concludedApache-2.0
authorsclaude-opus-4-1-20250805
imported2026-08-20
Kernel source
main.cpp90 lines
#include <torch/extension.h>
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include "kernel.h"
#include <vector>
#include <stdexcept>
// Helper function to check tensor properties
void check_cuda_tensor(const torch::Tensor& tensor, const std::string& name) {
if (!tensor.is_cuda()) {
throw std::runtime_error(name + " must be a CUDA tensor");
}
if (!tensor.is_contiguous()) {
throw std::runtime_error(name + " must be contiguous");
}
}
// Main run function
torch::Tensor run(torch::Tensor A, torch::Tensor B) {
// Input validation
check_cuda_tensor(A, "A");
check_cuda_tensor(B, "B");
// Check dtypes - handle both Half and Float16
if (A.scalar_type() != torch::ScalarType::Half) {
throw std::runtime_error("A must be float16");
}
if (B.scalar_type() != torch::ScalarType::Half) {
throw std::runtime_error("B must be float16");
}
// Check dimensions
if (A.dim() != 2) {
throw std::runtime_error("A must be 2-dimensional");
}
if (B.dim() != 2) {
throw std::runtime_error("B must be 2-dimensional");
}
int M = A.size(0);
int K_A = A.size(1);
int N = B.size(0);
int K_B = B.size(1);
// Verify dimensions match specification
if (N != N_FIXED) {
throw std::runtime_error("B dimension 0 must be " + std::to_string(N_FIXED) +
", got " + std::to_string(N));
}
if (K_A != K_FIXED) {
throw std::runtime_error("A dimension 1 must be " + std::to_string(K_FIXED) +
", got " + std::to_string(K_A));
}
if (K_B != K_FIXED) {
throw std::runtime_error("B dimension 1 must be " + std::to_string(K_FIXED) +
", got " + std::to_string(K_B));
}
// Allocate output tensor
auto options = torch::TensorOptions()
.dtype(torch::ScalarType::Half)
.device(A.device())
.requires_grad(false);
torch::Tensor C = torch::empty({M, N_FIXED}, options);
// Get CUDA stream
cudaStream_t stream = at::cuda::getCurrentCUDAStream();
// Get raw pointers - cast to half*
const half* A_ptr = reinterpret_cast<const half*>(A.data_ptr<torch::Half>());
const half* B_ptr = reinterpret_cast<const half*>(B.data_ptr<torch::Half>());
half* C_ptr = reinterpret_cast<half*>(C.data_ptr<torch::Half>());
// Launch kernel
launch_gemm_kernel(A_ptr, B_ptr, C_ptr, M, stream);
// Ensure kernel completion for correctness
cudaError_t err = cudaGetLastError();
if (err != cudaSuccess) {
throw std::runtime_error(std::string("CUDA kernel launch failed: ") + cudaGetErrorString(err));
}
return C;
}
// Python binding
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("run", &run, "Optimized GEMM kernel for N=256, K=7168 (C = A @ B.T)",
py::arg("A"), py::arg("B"));
}scrolls · 90 lines total
Source code from the importing source · Apache-2.0
No published measurement for this revision
JSON