Skip to content
KernelIndex
Search⌘K

gemini-2.5-pro / cudaaaf481

gemini-2.5-pro_cuda_aaf481 · gemini-2.5-pro · cuda · Apache-2.0

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
RMSNorm h4096bf16 · [4096] · batch_size=16
NVIDIA B200
7.27µs
#1 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=7
NVIDIA B200
7.30µs
#1 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=1
NVIDIA B200
7.40µs
#1 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=34
NVIDIA B200
7.46µs
#1 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=15
NVIDIA B200
7.57µs
#1 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=63
NVIDIA B200
7.62µs
#1 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=64
NVIDIA B200
7.90µs
#1 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=79
NVIDIA B200
8.02µs
#2 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=170
NVIDIA B200
8.12µs
#2 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=8804
NVIDIA B200
63.4µs
#6 of 6
2025-10-16
Show all 14 measurements ›
RMSNorm h4096bf16 · [4096] · batch_size=10827
NVIDIA B200
76.0µs
#6 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=11832
NVIDIA B200
82.6µs
#6 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=14418
NVIDIA B200
98.6µs
#6 of 6
2025-10-16
RMSNorm h4096bf16 · [4096] · batch_size=14509
NVIDIA B200
99.3µs
#6 of 6
2025-10-16

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