# Add CUDA Kernels to FlashInfer

Adding a FlashInfer kernel requires coordinated CUDA, TVM-FFI, Python, tracing, testing, AOT, and benchmark changes. This skill provides a complete implementation workflow with repository-specific examples.

## Install

```bash
npx skillstore add flashinfer-ai/add-cuda-kernel
```

## Metadata

- Status: approved
- Slug: flashinfer-ai-add-cuda-kernel
- Skillstore revision: r2
- Version status: missing
- Tree hash: f36db609f1f8e62e1b9c69a0a2b35b0ea4da116befdaa36eccca18da1341fdc3
- Author: flashinfer-ai
- GitHub username: flashinfer-ai
- License: MIT
- Repository: https://github.com/flashinfer-ai/flashinfer/tree/main/.claude/skills/add-cuda-kernel
- Ref: c43861a65bb95efcae259cd161c9d6f4dc7eec6f
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, filesystem
- Quality score: 77
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/flashinfer-ai-add-cuda-kernel
- Manifest: https://skillstore.pages.dev/api/skills/flashinfer-ai-add-cuda-kernel/manifest

## Capabilities

- Guides CUDA kernel and launcher creation using FlashInfer conventions.
- Shows TVM-FFI binding and runtime dtype dispatch patterns.
- Builds a cached Python API with device, shape, and dtype validation.
- Explains JIT architecture targeting and optional AOT registration.
- Adds trace templates and consistency-test registration.
- Provides correctness tests and GPU benchmark structure.

## Use Cases

- Implement a First FlashInfer Kernel: Follow an end-to-end example from CUDA device code through a tested Python API.
- Complete Kernel Integration: Add tracing, exports, architecture checks, JIT generation, and AOT registration to an existing kernel.
- Validate Kernel Performance: Create correctness coverage and representative GPU benchmarks before submitting a kernel change.

## Prompt Templates

### Add a Basic Kernel

```
Add an element-wise CUDA operation to this FlashInfer checkout. Include bindings, a Python API, tests, tracing, exports, and AOT registration.
```

### Add Architecture Constraints

```
Implement this kernel for {supported_sm_versions}. Configure JIT architecture flags and add pytest skips for unsupported GPUs.
```

### Complete Tracing and AOT

```
Complete tracing and AOT integration for {operation}. Register templates, consistency tests, public exports, and common precompiled dtype configurations.
```

### Optimize and Benchmark

```
Review {kernel_path} for correctness and performance. Add representative benchmarks, compare against {reference}, and report latency across dtypes and sizes.
```

## Limitations

- The workflow targets FlashInfer and does not directly apply to unrelated CUDA extension systems.
- The scale example does not cover advanced synchronization, memory layouts, or fused-kernel optimization.
- Compilation and runtime verification require a compatible CUDA toolchain and NVIDIA GPU.
- Generated changes still require maintainer review for current repository conventions and hardware support.

## Best Practices

- Confirm repository conventions and supported compute capabilities before choosing source files, dispatch macros, and architecture flags.
- Validate tensor device, shape, dtype, contiguity, and output buffers before launching the kernel.
- Add correctness tests, trace consistency checks, AOT registration, exports, and representative benchmarks before submission.

## Anti Patterns

- Do not write generated sources into package directories or use unbounded, user-controlled output paths.
- Do not bypass backend checks or use skip\_check until callers guarantee every required precondition.
- Do not claim performance gains without synchronized GPU measurements against a relevant reference implementation.

## Security Audit

- Audited at: 2026-07-23T17:39:08.985\+00:00
- Summary: All 150 static alerts are false positives caused by Markdown backticks, bounded local JIT staging examples, a relative documentation link, or ordinary function declarations. The tutorial contains no prompt injection, command execution mechanism, arbitrary traversal, reconnaissance behavior, or malicious intent.

## Stats

- Views: 342
- Downloads: 5
- Favorites: 0
- Popularity score: 0
