Write kernel test plan

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

Write kernel test plan is an AI agent skill from the GitHub repository wenyi-li/awesome-agent-kernel-skills. Guide the agent through constructing a systematic, coverage-complete test plan for a compute kernel, covering correctness, numerical precision, boundary conditions, layout variations, and performance

How to use this skill

Skill file

Skill: Write a Kernel Test Plan

Purpose

Guide the agent through constructing a systematic, coverage-complete test plan for a compute kernel, covering correctness, numerical precision, boundary conditions, layout variations, and performance regression.

Use this when

Do not use this when

Inputs the agent should gather first

Required reasoning process

  1. Define the reference implementation. Before writing any test, identify the ground truth:
  1. Choose numerical tolerances. Do not use a single tolerance for all dtypes:
  1. Design the shape coverage matrix. For every independent dimension of the kernel:
  1. Design the dtype coverage. Test every dtype the kernel claims to support:
  1. Design the layout coverage. Test all layout variants:
  1. Design the boundary coverage. These tests must verify that the partial tile handling is correct:
  1. Design stress and adversarial tests. The correctness tests above use controlled inputs. Adversarial inputs expose edge cases in numerical stability:
  1. Design the performance regression test. Correctness is necessary but not sufficient. Include:
  1. For CUDA kernels: integrate compute-sanitizer. Run the test suite under:
  1. For Triton kernels: use triton.testing. Use triton.testing.allclose for dtype-aware tolerance comparison. Use triton.testing.Benchmark for performance measurement.

Kernel design rules

Correctness requirements

Performance requirements

Output format

The agent should produce:

  1. Reference implementation: a standalone Python function implementing the kernel's mathematical specification in an obviously correct way.
  2. Shape/dtype/layout test matrix: a table or parameterized test listing all combinations of shapes, dtypes, and layouts to be tested.
  3. Adversarial input test cases: explicit list of adversarial input patterns with the expected behavior for each.
  4. Correctness test code: complete, runnable pytest or unittest code that compares kernel output to reference output with appropriate tolerances.
  5. Performance test code: complete, runnable timing harness with GB/s or TFLOPS reporting.
  6. compute-sanitizer invocation: the exact command to run the test suite under memcheck and racecheck.
  7. Coverage gaps statement: explicit enumeration of any test scenarios that are known to be missing and why.

Common failure modes

Review checklist

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.