Skip to content
KernelIndex
Search⌘K

submission 612908

dannywillowliu-uchi · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

No package. Vendor the mirrored source: 53 lines, June 9 Researcher Reciprocity License v1.0.

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-sort-v2-612908?include=source"
interfacepython
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp32

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
Sortsuite of 5 cases
NVIDIA B200
1.69ms
#3 of 23
2026-03-23

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:059d68904c0f774f20d3f272c314b509b041df262875b35e595f4dfdc5e803c4
license declaredunknown
license concludedunknown
authorsdannywillowliu-uchi
imported2026-08-15

Kernel source

submission.py53 lines
import os
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"

import torch
from torch.utils.cpp_extension import load_inline
from task import input_t, output_t

cuda_source = r"""
#include <torch/extension.h>
#include <cub/cub.cuh>

static void* g_temp = nullptr;
static size_t g_temp_bytes = 0;

torch::Tensor cub_radix_sort(torch::Tensor input, torch::Tensor output) {
	const int n = input.numel();
	int* d_in = reinterpret_cast<int*>(input.data_ptr<float>());
	int* d_out = reinterpret_cast<int*>(output.data_ptr<float>());

	void* d_temp = nullptr;
	size_t temp_bytes = 0;
	cub::DeviceRadixSort::SortKeys(d_temp, temp_bytes, d_in, d_out, n);

	if (temp_bytes > g_temp_bytes) {
		if (g_temp) cudaFree(g_temp);
		cudaMalloc(&g_temp, temp_bytes);
		g_temp_bytes = temp_bytes;
	}

	cub::DeviceRadixSort::SortKeys(g_temp, g_temp_bytes, d_in, d_out, n);
	return output;
}
"""

cpp_source = """
torch::Tensor cub_radix_sort(torch::Tensor input, torch::Tensor output);
"""

module = load_inline(
	name="cub_radix_sort_fast",
	cpp_sources=[cpp_source],
	cuda_sources=[cuda_source],
	functions=["cub_radix_sort"],
	extra_cuda_cflags=["-O3", "--use_fast_math", "-std=c++17"],
	verbose=False,
)


def custom_kernel(data: input_t) -> output_t:
	inp, out = data
	module.cub_radix_sort(inp, out)
	return out
scrolls · 53 lines total

Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0

Changes from previous submission

Against this author's previous submission submission 612537.

⋯ 13 unchanged lines
torch::Tensor cub_radix_sort(torch::Tensor input, torch::Tensor output) {
const int n = input.numel();
- unsigned int* d_in = reinterpret_cast<unsigned int*>(input.data_ptr<float>());
- unsigned int* d_out = reinterpret_cast<unsigned int*>(output.data_ptr<float>());
+ int* d_in = reinterpret_cast<int*>(input.data_ptr<float>());
+ int* d_out = reinterpret_cast<int*>(output.data_ptr<float>());
void* d_temp = nullptr;
size_t temp_bytes = 0;

Best evidence level for this revision: reported

JSON