gemini-2.5-pro / cudaaaf481
gemini-2.5-pro_cuda_aaf481 · gemini-2.5-pro · cuda · Apache-2.0
Kernel source · 65 lines ↓holds 7 records
Use it
Vendorable · source mirrored · Apache-2.0View source →
No package. Vendor the mirrored source: 65 lines, Apache-2.0, pinned at da91508.
main.cpp
curl "https://kernelindex.com/api/v1/implementations/flashinfer-gemini-2-5-pro-cuda-aaf481?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:534145266111b35c9d411ac81779fcdfc9591c6511e22e5f300744bc7b9de6aa
license declaredApache-2.0
license concludedApache-2.0
authorsgemini-2.5-pro
imported2026-08-20
Kernel source
main.cpp65 lines
#include <torch/extension.h>
#include <ATen/cuda/CUDAContext.h>
#include "kernel.h"
#include <string>
// Helper function to check common tensor properties
void check_tensor(const torch::Tensor& tensor, const std::string& name) {
TORCH_CHECK(tensor.is_cuda(), name, " must be a CUDA tensor");
TORCH_CHECK(tensor.dtype() == torch::kBFloat16, name, " must have bfloat16 dtype");
TORCH_CHECK(tensor.is_contiguous(), name, " must be contiguous");
}
/**
* @brief Python-bindable 'run' function for RMSNorm.
*
* This function serves as the entry point from Python. It performs extensive
* validation on the input tensors to ensure they meet the kernel's requirements.
* It then allocates the output tensor and calls the CUDA kernel launcher.
*
* @param hidden_states Input tensor of shape [batch_size, 4096] and dtype bfloat16.
* @param weight Weight tensor of shape [4096] and dtype bfloat16.
* @return The output tensor with the same shape and dtype as hidden_states.
*/
torch::Tensor run(
const torch::Tensor& hidden_states,
const torch::Tensor& weight) {
// --- Input Validation ---
TORCH_CHECK(hidden_states.dim() == 2, "hidden_states must be a 2D tensor, but got ", hidden_states.dim(), " dimensions");
TORCH_CHECK(weight.dim() == 1, "weight must be a 1D tensor, but got ", weight.dim(), " dimensions");
const int64_t hidden_size = hidden_states.size(1);
TORCH_CHECK(hidden_size == 4096, "hidden_size must be 4096, but got ", hidden_size);
TORCH_CHECK(weight.size(0) == hidden_size, "weight must have size ", hidden_size, ", but got ", weight.size(0));
check_tensor(hidden_states, "hidden_states");
check_tensor(weight, "weight");
// --- Output Tensor Allocation ---
auto output = torch::empty_like(hidden_states);
// --- Kernel Execution ---
const float eps = 1e-5f;
// Get current CUDA stream from PyTorch's context
cudaStream_t stream = at::cuda::getCurrentCUDAStream();
// Launch the kernel via the C++ wrapper function in the .cu file
rmsnorm_h4096_launcher(
output,
hidden_states,
weight,
eps,
stream
);
return output;
}
// --- Pybind11 Module Definition ---
// Exposes the 'run' function to Python, making it callable as a C++ extension.
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("run", &run, "RMSNorm kernel for hidden_size=4096 (BFloat16, CUDA, B200 Optimized)");
}scrolls · 65 lines total
Source code from FlashInfer-Bench (flashinfer-ai/flashinfer-trace) · Apache-2.0
Best evidence level for this revision: reproducible
JSON