diffusion-kernel

Build, test, and profile JIT CUDA and Triton kernels for SGLang diffusion models.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, triton, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Index and coordinate diffusion kernel development across CUDA, Triton, and CuTe DSL, providing a structured, end-to-end reference for building, testing, and profiling high-performance diffusion kernels within SGLang Diffusion.

Core Features & Use Cases

  • Comprehensive kernel templates: Reusable CUDA/Triton/CuTe patterns for common diffusion operations (RMSNorm, AdaLN, RoPE, GEGLU, SiLU gate) with ready-to-adapt templates.
  • Integration & testing guidance: Step-by-step instructions to wrap kernels with JIT loaders, patch diffusion models before torch.compile, and validate correctness with unit tests.
  • Performance & profiling workflows: Detailed guidance for benchmarking, Nsight Compute profiling, and occupancy/throughput analysis to drive kernel optimization.
  • Use Case: A developer adds a new CUDA kernel, wraps it with the Python JIT, validates against PyTorch baselines, and iterates with profiling to maximize end-to-end denoise throughput.

Quick Start

Author a CUDA kernel using the provided templates, wrap it with the Python launcher, and patch it into the Denoising stage before torch.compile.

Frequently Asked Questions about diffusion-kernel

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

FAQPage Schema
How do I build and test custom CUDA kernels for diffusion models?

To build and test custom CUDA kernels for diffusion models, use battle-tested templates for operations like RMSNorm and RoPE, wrap them with JIT loaders, and validate correctness against PyTorch baselines using provided unit tests.

How does torch.compile work with custom Triton kernels?

torch.compile integrates with custom Triton kernels by patching the diffusion model before compilation, ensuring PyTorch compatibility and allowing the JIT CUDA launchers to function correctly within the compiled execution graph.

What is the best way to profile Triton kernels for diffusion throughput?

The best way to profile Triton kernels for diffusion throughput is using Nsight Compute to analyze occupancy and vectorized memory access, enabling iterative performance optimization to maximize end-to-end denoise speed.

Can I use CuTe DSL patterns for common diffusion operations?

Yes, you can use CuTe DSL patterns for common diffusion operations. The Skill provides reusable kernel templates for operations like AdaLN, GEGLU, and SiLU gate that are ready to adapt for CuTe DSL integration.

Do I need Triton and PyTorch to develop JIT CUDA kernels?

Yes, you need Triton and PyTorch to develop JIT CUDA kernels using this workflow, as the templates enforce PyTorch compatibility through torch.compile wrap_triton and rely on Triton for JIT compilation.

Why are my custom CUDA kernels failing the diffusion model integration?

Custom CUDA kernels may fail diffusion model integration if they lack vectorized memory access, warp reductions, or proper wrapping with Python JIT launchers before applying torch.compile to the denoising stage.