add-sgl-kernel

Add heavyweight AOT CUDA/C++ kernels to sgl-kernel with tests and benchmarks.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide helps developers add heavyweight AOT CUDA/C++ kernels to the sgl-kernel project, including end-to-end steps for testing and benchmarking.

Core Features & Use Cases

  • Provides a complete integration flow for adding a new kernel to sgl-kernel (C++, CUDA, PyTorch extension, and Python API).
  • Covers declaration, registration, building, and validation with unit tests and performance benchmarks.
  • Use Case: A developer needs to add a new matrix-scaling kernel to accelerate custom workloads in an AI inference pipeline.

Quick Start

Follow this guide to implement a new heavyweight AOT CUDA/C++ kernel in sgl-kernel, including tests and benchmarks.

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 a PyTorch extension?

To add a new CUDA kernel to a PyTorch extension, implement the kernel in csrc, declare and register the op with the Torch extension, update build scripts, and expose a Python API for testing and benchmarking.

What is AOT compilation for CUDA kernels?

AOT compilation for CUDA kernels involves Ahead-Of-Time compiling C++ and CUDA code into heavyweight extensions before runtime, requiring build script updates and Torch extension registration to integrate with Python APIs.

How do I benchmark and test a custom CUDA kernel?

Benchmark and test a custom CUDA kernel by exposing a Python API that enforces validation, device and dtype dispatch, and performance measurement through integrated unit tests and benchmarks.

Does adding a heavyweight CUDA kernel require updating build scripts?

Adding a heavyweight CUDA kernel requires updating build scripts to compile the AOT C++ and CUDA code, alongside declaring the op and registering it with the Torch extension for successful integration.

Can I use this workflow to accelerate an AI inference pipeline?

You can use this workflow to accelerate an AI inference pipeline by adding custom matrix-scaling kernels, providing a complete integration flow from C++ implementation to Python API testing and performance benchmarking.

Why do I need device and dtype dispatch when integrating a CUDA kernel?

Device and dtype dispatch is needed when integrating a CUDA kernel to enforce complete validation patterns, ensuring the PyTorch extension correctly handles diverse tensor types and hardware targets during execution.