add-jit-kernel

Implement a lightweight JIT CUDA kernel for SGLang's jit_kernel module.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a guided approach to add a new lightweight JIT CUDA kernel to SGLang's jit_kernel module, enabling rapid iteration and deployment of custom GPU kernels.

Core Features & Use Cases

  • Step-by-step tutorial for implementing a minimal element-wise scale operation as a JIT kernel.
  • Demonstrates validation via TensorMatcher, vectorized loads via AlignedVector, and a LaunchKernel-based launcher.
  • Includes a Python wrapper to expose the JIT kernel to PyTorch workflows for quick experiments.

Quick Start

Follow the tutorial to implement a new element-wise scale JIT kernel and wire it into the Python wrapper, then run the included tests.

Frequently Asked Questions about add-jit-kernel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a custom CUDA kernel to SGLang for element-wise tensor operations?

To add a custom CUDA kernel to SGLang, you implement a lightweight JIT kernel within the jit_kernel module, utilizing TensorMatcher for validation and vectorized memory access via AlignedVector, then expose it through a Python wrapper for PyTorch workflows.

What is the best way to validate tensor inputs when writing a JIT CUDA kernel?

The best way to validate tensor inputs for a JIT CUDA kernel is using TensorMatcher-based validation, which ensures safe runtime checks and enforces correct tensor dimensions and types before the LaunchKernel-based launcher executes the GPU operation.

Can I use PyTorch workflows with custom SGLang JIT kernels?

Yes, you can use PyTorch workflows with custom SGLang JIT kernels by implementing a Python wrapper that exposes the underlying CUDA JIT kernel, enabling rapid iteration and quick experiments directly within your PyTorch environment.

How does vectorized memory access work in SGLang JIT kernels?

Vectorized memory access in SGLang JIT kernels works by utilizing AlignedVector for memory loads, which optimizes data reading patterns during fast element-wise operations and improves overall GPU kernel throughput.

Does SGLang support JIT compilation for rapid GPU kernel iteration?

SGLang supports JIT compilation to enable rapid iteration and deployment of custom GPU kernels, allowing developers to quickly build and test minimal element-wise scale operations through its dedicated jit_kernel module.

What are the limitations of building element-wise operations as JIT kernels in SGLang?

Building element-wise operations as JIT kernels in SGLang requires strict adherence to TensorMatcher validation and AlignedVector constraints, meaning non-aligned memory access patterns may not benefit from the vectorized loads and safe runtime checks provided.