add-sgl-kernel

Adds custom CUDA/C++ kernels to the sgl-kernel library with PyTorch extension integration and CMake build system support.

3|Updated Jun 18, 2025
One-click install
npx skills add https://github.com/moirai-internal/sglang --skill add-sgl-kernel-moirai-internal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-sgl-kernel
Source: https://github.com/moirai-internal/sglang/tree/main/.claude/skills/add-sgl-kernel
Command: npx skills add https://github.com/moirai-internal/sglang --skill add-sgl-kernel-moirai-internal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to seamlessly integrate custom, heavyweight CUDA/C++ kernels into the sgl-kernel library, ensuring they are tested and benchmarked.

Core Features & Use Cases

  • Kernel Implementation: Step-by-step instructions for writing CUDA kernels (.cu files).
  • Integration: Guidance on declaring, registering, and building kernels within the sgl-kernel CMake and PyTorch extension framework.
  • Testing & Benchmarking: Requirements and examples for writing unit tests and performance benchmarks.
  • Use Case: A developer needs to add a highly optimized matrix multiplication kernel that relies on CUTLASS. This Skill guides them through the entire process from writing the CUDA code to making it available as a PyTorch op.

Quick Start

Follow the tutorial to implement, test, and build a new CUDA kernel for 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 custom CUDA kernel into a PyTorch extension library?

To integrate a custom CUDA kernel into a PyTorch extension, you must implement the C++ code, declare the functions, register the PyTorch extension, and update the CMake build system to expose the Python API.

What is the process for adding heavyweight AOT compilation for CUTLASS kernels?

Heavyweight AOT compilation for CUTLASS kernels involves writing the CUDA kernel, integrating it into the existing C++ project's CMake build system, and exposing it as a PyTorch op to ensure proper compilation and execution.

How do I write tests and benchmarks for new CUDA kernels?

Writing tests and benchmarks for new CUDA kernels requires creating specific unit tests to validate functionality and performance benchmarks to measure execution speed, ensuring the kernel operates correctly within the library.

Can I use sgl-kernel to add highly optimized matrix multiplication kernels?

Yes, you can use sgl-kernel to add highly optimized matrix multiplication kernels by following the step-by-step guide from writing the initial CUDA code to making it fully available as a tested and benchmarked PyTorch op.

Does integrating custom C++ kernels with sgl-kernel require CMake build system configuration?

Yes, integrating custom C++ kernels requires configuring the CMake build system to properly declare, register, and build the PyTorch extension components alongside the existing library framework.