add-sgl-kernel

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a complete, end-to-end workflow for adding a heavyweight AOT CUDA/C++ kernel to sgl-kernel, including tests and benchmarks, making it easier to extend and optimize the kernel ecosystem.

Core Features & Use Cases

  • Kernel implementation and placement: Create csrc/elementwise/xxx.cu and place the kernel with proper dispatch and CUDA stream usage.
  • Registration and bindings: Add C++ declarations, register with Torch extension, and expose a Python API and tests.
  • Performance benchmarking: Include a benchmark script to compare against PyTorch, ensuring performance parity or gains.
  • Use Case: You want to add a new elementwise operation or optimize an existing one for GPU acceleration within sgl-kernel.

Quick Start

Follow this guide to implement and register a new AOT CUDA kernel in sgl-kernel and execute the test suite 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 CUDA kernel to sgl-kernel with tests and benchmarks?

To add a CUDA kernel to sgl-kernel, you create a .cu file with proper dispatch, register it with the Torch extension, expose the Python API, and add unit tests and benchmarking scripts to validate GPU acceleration and performance gains against PyTorch.

What is the workflow for integrating an AOT C++ kernel into sgl-kernel?

Integrating an AOT C++ kernel into sgl-kernel involves implementing the kernel with CUDA stream usage, adding C++ declarations, registering with the Torch extension, exposing the Python API, and configuring build integration alongside unit tests and performance benchmarks.

How do I benchmark a PyTorch operation against a custom CUDA kernel?

You benchmark a PyTorch operation against a custom CUDA kernel by adding a benchmark script to the sgl-kernel workflow, which rigorously compares the GPU-accelerated kernel execution against the baseline PyTorch operation to ensure performance parity or gains.

Do I need to write my own Python API exposure when extending sgl-kernel?

You need to expose a Python API when extending sgl-kernel, because the workflow requires adding C++ declarations and registering the kernel with the Torch extension to make the new GPU-accelerated operation accessible and testable from Python.

When should I add a heavyweight kernel to sgl-kernel instead of using standard PyTorch operations?

You should add a heavyweight kernel to sgl-kernel when you need to implement a new elementwise operation or optimize an existing one for GPU acceleration, requiring rigorous validation and performance benchmarking that standard PyTorch operations do not provide.

Does sgl-kernel support build integration for AOT CUDA extensions?

sgl-kernel supports build integration for AOT CUDA extensions by automating the placement of .cu files, Torch extension registration, and Python API exposure, enabling seamless GPU-accelerated workflow extensions with proper testing.