gemini-2.5-pro / cudafc4885
gemini-2.5-pro_cuda_fc4885 · gemini-2.5-pro · cuda · Apache-2.0
Use it
Vendorable · source mirrored · Apache-2.0View source →
No package. Vendor the mirrored source: 46 lines, Apache-2.0, pinned at da91508.
main.cpp
curl "https://kernelindex.com/api/v1/implementations/flashinfer-gemini-2-5-pro-cuda-fc4885?include=source"interfacecuda
revisionda915083d4c7
symbolrun
pathmain.cpp
Compatibility
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp32, int32
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:93974a26fad1b88a9373aebf0f39d9edf6ea2794da698a934e132f47b36e499c
license declaredApache-2.0
license concludedApache-2.0
authorsgemini-2.5-pro
imported2026-08-20
Kernel source
main.cpp46 lines
#include "kernel.h"
#include <torch/extension.h>
#include <vector>
// The "run" function is the entry point exposed to Python.
// It handles tensor validation and calls the CUDA implementation.
torch::Tensor run(torch::Tensor probs, torch::Tensor top_k, torch::Tensor top_p) {
// Input validation: Device
TORCH_CHECK(probs.is_cuda(), "probs tensor must be on a CUDA device");
TORCH_CHECK(top_k.device() == probs.device(), "top_k must be on the same device as probs");
TORCH_CHECK(top_p.device() == probs.device(), "top_p must be on the same device as probs");
// Input validation: Dtypes
TORCH_CHECK(probs.scalar_type() == torch::kFloat32, "probs must be of type float32");
TORCH_CHECK(top_k.scalar_type() == torch::kInt32, "top_k must be of type int32");
TORCH_CHECK(top_p.scalar_type() == torch::kFloat32, "top_p must be of type float32");
// Input validation: Shapes
TORCH_CHECK(probs.dim() == 2, "probs must be a 2D tensor");
const int batch_size = probs.size(0);
const int vocab_size = probs.size(1);
const int required_vocab_size = 151936;
TORCH_CHECK(vocab_size == required_vocab_size, "vocab_size must be ", required_vocab_size);
TORCH_CHECK(top_k.dim() == 1 && top_k.size(0) == batch_size, "top_k must be a 1D tensor of size batch_size");
TORCH_CHECK(top_p.dim() == 1 && top_p.size(0) == batch_size, "top_p must be a 1D tensor of size batch_size");
// Ensure tensors are contiguous for safe data_ptr access
probs = probs.contiguous();
top_k = top_k.contiguous();
top_p = top_p.contiguous();
// Create the output tensor
auto samples = torch::empty({(long)batch_size}, torch::TensorOptions().dtype(torch::kInt64).device(probs.device()));
// Call the CUDA kernel launcher
top_k_top_p_sampling_from_probs_v151936_cuda(probs, top_k, top_p, samples);
return samples;
}
// PYBIND11 module definition to expose the 'run' function to Python
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("run", &run, "Top-K/Top-P sampling from probability distributions (CUDA implementation for v151936)");
}scrolls · 46 lines total
Source code from the importing source · Apache-2.0
No published measurement for this revision
JSON