add-sgl-kernel

Add CUDA/C++ kernels to sgl-kernel with Torch extension and CMake integration.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and scripts (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, streamlining the development of high-performance GPU operations.

Core Features & Use Cases

  • Kernel Implementation: Step-by-step instructions for writing CUDA kernels for element-wise operations.
  • Integration Workflow: Details on updating C++ declarations, Torch extension registration, CMake build files, and Python APIs.
  • Testing & Benchmarking: Guidance on creating robust tests and performance benchmarks for new kernels.
  • Use Case: A developer needs to add a custom tensor scaling operation to sgl-kernel that leverages CUTLASS for maximum performance. This Skill guides them through the entire process from kernel implementation to testing.

Quick Start

Follow the tutorial to implement a new scale 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 custom CUDA kernels to a PyTorch C++ extension library?

Adding custom CUDA kernels to a PyTorch C++ extension involves writing the kernel in C++, registering it via Torch extension, updating CMake build files, exposing the Python API, and creating unit tests and performance benchmarks.

What is the process for integrating AOT compiled GPU operations into sgl-kernel?

Integrating AOT compiled GPU operations into sgl-kernel requires updating C++ declarations, configuring the CMake build system, registering the Torch extension, and exposing the functionality through Python APIs for immediate use.

Does sgl-kernel support dtype dispatching for FP16, BF16, and FP32 in CUDA programming?

Yes, sgl-kernel supports dtype dispatching for FP16, BF16, and FP32 in CUDA programming, allowing custom kernels to integrate seamlessly with PyTorch's CUDA backend across multiple precision formats.

What's the best way to write benchmarks for custom CUDA kernels in a PyTorch library?

The best way to write benchmarks for custom CUDA kernels in a PyTorch library is to follow the sgl-kernel integration workflow, which guides you through creating robust performance benchmarks alongside unit tests for new operations.

Do I need to update CMake build files when adding new C++ kernels to sgl-kernel?

Yes, you need to update CMake build files when adding new C++ kernels to sgl-kernel, as the build system must be configured to compile and link the new AOT CUDA operations with the PyTorch backend.

Can I use CUTLASS for element-wise tensor scaling operations in sgl-kernel?

Yes, you can use CUTLASS for element-wise tensor scaling operations in sgl-kernel, leveraging it for maximum performance while following the guided workflow from kernel implementation to testing and benchmarking.