add-sgl-kernel

Add custom CUDA/C++ kernels to the sgl-kernel library with CMake and Python API integration.

105|9|Updated Feb 10, 2026
One-click install
npx skills add https://github.com/guqiong96/Lsglang --skill add-sgl-kernel-guqiong96
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-sgl-kernel
Source: https://github.com/guqiong96/Lsglang/tree/main/.claude/skills/add-sgl-kernel
Command: npx skills add https://github.com/guqiong96/Lsglang --skill add-sgl-kernel-guqiong96

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 properly 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 updating C++ declarations, Torch extension registration, CMake build files, and Python APIs.
  • Testing & Benchmarking: Guidance on creating robust unit tests and performance benchmarks using pytest and Triton.
  • Use Case: A developer needs to add a highly optimized custom matrix multiplication kernel to sgl-kernel to accelerate a specific model inference task.

Quick Start

Follow the tutorial to implement a new CUDA kernel, add its C++ declaration, register it in common_extension.cc, update CMakeLists.txt, expose a Python API, write tests in tests/, and add a benchmark in benchmark/.

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 the sgl-kernel library?

To add custom CUDA kernels to the sgl-kernel library, implement the kernel in C++, declare it, register it in the Torch extension, update the CMake build system, expose the Python API, and create tests and benchmarks.

What is the process for integrating heavyweight AOT C++ operations into sgl-kernel?

Integrating heavyweight AOT C++ operations into sgl-kernel involves writing the kernel, updating C++ declarations, registering the operation in common_extension.cc, modifying CMakeLists.txt, and exposing the functionality through a Python API.

Does sgl-kernel support benchmarking custom PyTorch CUDA extensions against Triton?

Yes, sgl-kernel supports benchmarking custom PyTorch CUDA extensions against Triton, providing guidance on creating performance benchmarks in the benchmark directory to evaluate your kernel's efficiency.

How do I test newly added CUDA kernels in the sgl-kernel ecosystem?

You test newly added CUDA kernels in the sgl-kernel ecosystem by creating robust unit tests using pytest within the tests directory to ensure the correctness of your custom operations.

Can I use sgl-kernel to optimize specific model inference tasks with custom matrix multiplication?

Yes, you can use sgl-kernel to optimize specific model inference tasks by adding highly optimized custom matrix multiplication kernels to accelerate your specific workloads.

What are the limitations when writing element-wise operations for sgl-kernel?

When writing element-wise operations for sgl-kernel, you must follow the strict integration workflow, which requires manual C++ declarations, Torch extension registration, and CMake build updates to function properly.