add-sgl-kernel

Add AOT CUDA or C++ kernels to sgl-kernel with CMake and pytest.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a complete, repeatable workflow for adding heavyweight AOT CUDA or C++ kernels to sgl-kernel without missing the integration, testing, benchmarking, or build steps.

Core Features & Use Cases

  • Kernel Implementation: Guides CUDA kernel development with PyTorch tensor validation, dtype dispatch, stream handling, and launch error checks.
  • Framework Integration: Covers C++ declarations, torch operator registration, CMake source inclusion, and Python API exposure.
  • Validation and Performance: Adds pytest correctness tests, error-condition coverage, and Triton benchmarking against PyTorch.
  • Use Case: Use this Skill when implementing a new CUTLASS-dependent or heavyweight CUDA operation that must ship as part of the sgl-kernel AOT wheel.

Quick Start

Use the add-sgl-kernel skill to implement, register, build, test, and benchmark a new CUDA 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 integrate a new CUDA kernel into sgl-kernel and register it with PyTorch?

To integrate a CUDA kernel into sgl-kernel, you need C++ declarations, torch operator registration, CMake source inclusion, and Python API exposure. This ensures the kernel is properly built into the AOT wheel and callable from Python.

What does AOT compilation mean for CUDA kernels in sgl-kernel?

AOT compilation in sgl-kernel means heavyweight CUDA or C++ kernels are pre-compiled into the wheel, avoiding runtime compilation overhead. This approach is required for complex operations like those dependent on CUTLASS.

How do I write pytest tests for a custom CUDA kernel?

Writing pytest tests for a custom CUDA kernel involves adding correctness checks and error-condition coverage. You should validate PyTorch tensor dtypes, device placement, and kernel launch errors to ensure robust integration.

What is the best way to benchmark a CUDA kernel against PyTorch?

The best way to benchmark a CUDA kernel against PyTorch is using Triton benchmarking. This allows you to measure performance gains and validate that the AOT kernel provides a speedup over native PyTorch operations.

Can I use CUTLASS-dependent operations with sgl-kernel?

Yes, you can use CUTLASS-dependent operations with sgl-kernel. The integration workflow specifically supports these heavyweight C++ kernels by handling the necessary CMake configuration and torch operator registration.

What PyTorch tensor validations are needed for a new CUDA kernel?

Required PyTorch tensor validations for a new CUDA kernel include checking tensor dtypes, verifying device placement, and handling stream execution. These checks prevent runtime errors during kernel launches.