add-sgl-kernel

Implement and integrate CUDA/C++ kernels with tests and benchmarks.

Updated Jun 29, 2026
One-click install
npx skills add https://github.com/hey-kong/sglang --skill add-sgl-kernel-hey-kong
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-sgl-kernel
Source: https://github.com/hey-kong/sglang/tree/main/.claude/skills/add-sgl-kernel
Command: npx skills add https://github.com/hey-kong/sglang --skill add-sgl-kernel-hey-kong

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a complete end-to-end guide to implement and integrate a heavyweight CUDA/C++ kernel into sgl-kernel, including tests and benchmarks, to streamline kernel deployment.

Core Features & Use Cases

  • End-to-end kernel integration: from C++ kernel code (sgl-kernel/csrc) through PyTorch Torch extension and Python API.
  • Registration and build: declare, register, and build the op so it works with Torch and Python.
  • Tests and benchmarks: include unit tests and performance benchmarks to validate correctness and speed.
  • Use Case: Add a new kernel like a high-performance scale operation and verify it across CUDA devices.

Quick Start

Follow these steps to implement, register, test, and benchmark a new heavyweight CUDA/C++ kernel in sgl-kernel.

Frequently Asked Questions about add-sgl-kernel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new CUDA kernel to sgl-kernel?

To add a new CUDA kernel to sgl-kernel, write the C++ kernel code, register it as a Torch extension, expose the Python API, and integrate it into the build pipeline for compilation and testing.

What does integrating a C++ kernel into a PyTorch Torch extension involve?

Integrating a C++ kernel involves declaring and registering the operation so it works with PyTorch, exposing the functionality through a Python API, and ensuring the build system compiles the extension correctly.

How do I test and benchmark a custom CUDA kernel in CI?

You test and benchmark a custom CUDA kernel by adding unit tests for correctness and performance benchmarks to verify speed, enforcing device validation and compilation checks within the CI pipeline.

Does sgl-kernel enforce device validation for new PyTorch extensions?

Yes, sgl-kernel enforces device validation for new PyTorch extensions. The workflow includes compilation checks and performance verification within CI to ensure operations run correctly across CUDA devices.

What is the best way to deploy a heavyweight C++ kernel for PyTorch?

The best way to deploy a heavyweight C++ kernel is using an end-to-end integration workflow that covers C++ code, Torch extension registration, Python API exposure, and automated build, test, and benchmark pipelines.

Why does my new Torch extension fail compilation checks in sgl-kernel?

Your Torch extension may fail compilation checks if the C++ kernel code is not properly registered or if device validation fails. The workflow enforces these checks within CI to prevent integration errors.