Kernel creator

From wenyi-li/awesome-agent-kernel-skills · View interactive version

Kernel creator is an AI agent skill from the GitHub repository wenyi-li/awesome-agent-kernel-skills. Guides writing and refactoring GPU kernels across CUDA and DSLs. Invoke when implementing kernel files that must stay importable, independently testable, profileable, and optimizable.

How to use this skill

Skill file

Kernel Creator

Use this skill whenever the user wants to write, edit, refactor, or organize GPU

kernel code in CUDA or any GPU DSL, including Triton, TileLang, CuteDSL, and

similar systems. This skill is about authoring kernels as reusable implementation

units rather than one-off notebook snippets or tightly coupled benchmark scripts.

Core Goal

Write kernel code so each kernel implementation is:

  1. Importable with a simple statement such as from ... import some_kernel_impl
  2. Testable with a small correctness-focused script
  3. Profileable with a small benchmarking script
  4. Optimizable in isolation without entangling unrelated kernels or host logic

The implementation file and the scripts around it should be decoupled on purpose.

Do not bury kernel logic inside large demo programs, training loops, or ad hoc

benchmark files.

Non-Negotiable Rules

1. Keep kernel implementations decoupled

or factory needed by callers.

benchmarking, allocate giant tensors, JIT dozens of variants, or parse CLI args.

2. Separate implementation from verification and profiling

For a kernel named some_kernel_impl, prefer a structure like:

some_kernel_impl.py / .cu / .cc
test_some_kernel_impl.py
profile_some_kernel_impl.py
debug_some_kernel_impl.py      # optional

The exact suffix and language may vary, but the separation of concerns should not.

wrapper or launcher.

sizes, or launch parameters.

instrumentation or reduced repro cases.

3. Design for isolated optimization

parameters explicit.

4. Preserve a clean operator contract

Before writing the kernel, define:

masking semantics, or tolerated error

If these constraints are unclear, clarify them before optimizing.

Recommended Workflow

1. Start from the operation contract

Write down the mathematical operation first. For any nontrivial kernel, also write

a trusted reference implementation in PyTorch, NumPy, plain CUDA host code, or

another obviously correct baseline.

2. Pick the smallest reusable implementation unit

Choose the narrowest kernel boundary that still makes sense to import and test.

Good examples:

Bad examples:

3. Write the implementation file first

The implementation file should usually contain:

Avoid packing it with:

4. Add a small correctness script

The test script should:

Keep the script small enough that it becomes the default repro for future edits.

5. Add a small profiling script

The profiling script should:

The goal is to answer "is this kernel faster?" without rewriting the harness each

time.

File Design Guidelines

Implementation modules

Implementation files should favor:

attention_block_kernel.py

Implementation files should avoid:

Host wrappers

Thin wrappers are good when they:

Thin wrappers are bad when they:

DSL-Agnostic Guidance

Apply the same structure whether the kernel is written in:

The syntax differs, but the engineering rules stay the same:

Do not overfit the structure to one DSL's tutorial style if it makes the module

harder to reuse elsewhere.

Refactor Rules

When refactoring existing kernel code:

  1. Extract the kernel definition out of monolithic scripts first.
  2. Preserve behavior before attempting performance changes.
  3. Move correctness checks into a dedicated test script.
  4. Move timing code into a dedicated profiling script.
  5. Reduce duplication between sibling kernels, but do not create a giant shared

abstraction that obscures kernel-specific logic.

Prefer clear duplication over premature framework-building. Share helpers only when

the shared boundary is stable and genuinely improves maintainability.

Review Checklist

Before finishing a kernel authoring task, check:

variants?

If the answer to any of these is no, restructure before polishing.

What To Avoid

Output Style For This Skill

When using this skill to help the user:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.