add-sgl-kernel

Guide adding AOT CUDA/C++ kernels to the sgl-kernel library.

31.6k|7.8k|Updated Jan 8, 2024
One-click install
npx skills add https://github.com/sgl-project/sglang --skill add-sgl-kernel-sgl-project
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-sgl-kernel
Source: https://github.com/sgl-project/sglang/tree/main/.claude/skills/add-sgl-kernel
Command: npx skills add https://github.com/sgl-project/sglang --skill add-sgl-kernel-sgl-project

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill provides a comprehensive guide to integrating 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 for element-wise operations.
  • Integration Workflow: Details on modifying C++ declarations, Torch extension registration, CMake build files, and Python APIs.
  • Testing & Benchmarking: Guidance on creating unit tests and performance benchmarks using pytest and Triton.
  • Use Case: A developer needs to add a new, performance-critical tensor scaling operation to sgl-kernel that relies on CUTLASS. This Skill guides them through the entire process from kernel code to Python exposure.

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 add a custom CUDA kernel to a PyTorch C++ extension?

To add a custom CUDA kernel to a PyTorch C++ extension, you write the kernel in C++, modify C++ declarations, register the Torch extension, update CMake build files, and expose the Python API to complete the integration.

What is the process for integrating AOT C++ kernels into the sgl-kernel library?

Integrating AOT C++ kernels into sgl-kernel requires implementing the kernel code, updating C++ declarations, registering the Torch extension, configuring the CMake build system, exposing the Python API, and writing tests and benchmarks.

How do I benchmark custom CUDA kernels using pytest and Triton?

You benchmark custom CUDA kernels using pytest and Triton by creating dedicated performance benchmark suites alongside unit tests. This ensures the newly integrated operations meet performance requirements within the library.

Do I need to modify the CMake build system to expose new Python APIs for sgl-kernel?

Yes, modifying the CMake build system is required to expose new Python APIs for sgl-kernel. The integration workflow dictates updating CMake build files to correctly compile and link the custom C++ operations into the PyTorch extension.

Can I use CUTLASS for performance-critical tensor operations in sgl-kernel?

Yes, you can use CUTLASS for performance-critical tensor operations in sgl-kernel. The Skill specifically guides developers through implementing heavy-weight operations that rely on CUTLASS from kernel code to final Python API exposure.