diffusion-kernel

Integrate custom JIT CUDA and Triton kernels to accelerate diffusion model inference.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill accelerates the inference speed of diffusion models by optimizing critical kernel operations, reducing latency and improving throughput.

Core Features & Use Cases

  • JIT Kernel Integration: Seamlessly integrates custom CUDA and Triton kernels for fused operations (e.g., RMSNorm, AdaLN, RoPE).
  • Performance Profiling: Provides tools and workflows for identifying bottlenecks using torch.profiler, nsys, and ncu.
  • Use Case: Reduce the time it takes to generate an image from a diffusion model by replacing slow, unoptimized PyTorch operations with highly efficient, fused CUDA or Triton kernels.

Quick Start

Optimize the RMSNorm kernel for the FLUX.1-dev model and compare its performance against the baseline.

Frequently Asked Questions about diffusion-kernel

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

FAQPage Schema
How do I optimize diffusion model inference speed using custom kernels?

Optimize diffusion model inference speed by integrating custom JIT CUDA and Triton kernels to replace slow PyTorch operations. This reduces generation latency by fusing operations like RMSNorm, AdaLN, and RoPE into highly efficient kernels.

How does performance profiling identify bottlenecks in diffusion pipelines?

Performance profiling identifies bottlenecks in diffusion pipelines by analyzing execution flows using torch.profiler, nsys, and ncu. These tools expose slow operations, enabling structured workflows for targeted kernel optimization and integration.

Can I integrate Triton and CUDA kernels for fused operations like RMSNorm and AdaLN?

Yes, you can integrate custom Triton and CUDA kernels to execute fused operations like RMSNorm and AdaLN. This seamless integration accelerates high-throughput diffusion pipelines by replacing unoptimized operations with compiled kernels.

What is the best way to reduce image generation latency in diffusion models?

The best way to reduce image generation latency is replacing unoptimized PyTorch operations with fused JIT CUDA or Triton kernels. This structured kernel optimization directly targets and minimizes critical operation overhead during inference.

Do I need JIT compilation to accelerate high-throughput diffusion pipelines?

Yes, JIT compilation is needed to accelerate high-throughput diffusion pipelines. It enables the integration of custom CUDA and Triton kernels for fused operations, which significantly reduces inference latency compared to standard execution.

When should I use Triton kernels over standard PyTorch operations for diffusion models?

Use Triton kernels over standard PyTorch operations when optimizing critical diffusion model operations like RoPE. Triton facilitates kernel fusion and JIT compilation, delivering high-throughput inference that unoptimized operations cannot achieve.