Write vllm custom op integration plan

From tensormux/kernel-skills · View interactive version

Write vllm custom op integration plan is an AI agent skill from the GitHub repository tensormux/kernel-skills. Guide the agent through planning the integration of a custom CUDA or Triton kernel into the vLLM inference engine before any integration code is written — covering where the op plugs into the engine,

How to use this skill

Skill file

Skill: Write a vLLM Custom Op Integration Plan

Purpose

Guide the agent through planning the integration of a custom CUDA or Triton kernel into the vLLM inference engine before any integration code is written — covering where the op plugs into the engine, paged KV cache and continuous batching compatibility, CUDA graph capture constraints, tensor parallelism implications, and the testing and benchmarking strategy. This skill produces an integration plan, not a kernel implementation.

Use this when

Do not use this when

Inputs the agent should gather first

Required reasoning process

  1. Orient to vLLM's call stack. Before placing the op anywhere, the plan must state where it plugs in. The relevant layers, top-down:
  1. Decide where the op plugs in (decision tree).
  1. Verify paged KV cache compatibility. vLLM's KV cache is paged: physical layout is roughly [num_blocks, block_size, num_kv_heads, head_dim] (with variants per backend). Any kernel that reads or writes K/V must:
  1. Plan for continuous batching. Within one batch, every request can be at a different position in its generation. The kernel will see a flattened representation:
  1. Audit CUDA graph capture compatibility. vLLM defaults to enforce_eager=False and captures CUDA graphs for a bucketed set of batch sizes (typically 1, 2, 4, 8, 16, 24, 32, ...; configurable). Each bucket produces one captured graph. Inside a captured region, the kernel must satisfy:
  1. Analyze tensor parallelism behavior. vLLM shards weights across TP ranks at the layer level:
  1. Acknowledge pipeline parallelism. PP is less common in vLLM v0 and is more central in v1. For most custom ops, the plan only needs to confirm that the op does not break PP — i.e., it operates on per-rank tensors and does not assume the entire model is on one device. If the op crosses pipeline boundaries (rare), the plan must be explicit about it.
  1. Define the testing strategy. Two layers, both required:
  1. Define the benchmarking strategy. All numbers must be measured against the un-customized vLLM baseline, not against a non-vLLM reference (the engine overhead changes the picture entirely). Use the in-tree harnesses:

Kernel design rules

Correctness requirements

Performance requirements

Output format

The integration plan must include:

  1. Op summary: what is being added or replaced, target phase, dtypes, hardware.
  2. Plug-in point: which file(s) under csrc/, vllm/model_executor/layers/, vllm/attention/backends/, or vllm/model_executor/models/ will be touched, with the rationale for each.
  3. KV cache compatibility analysis: confirms paged layout assumptions (or states the op does not touch K/V).
  4. Continuous batching analysis: prefill, decode, chunked prefill behavior; cu_seqlens handling.
  5. CUDA graph compatibility audit: each constraint (no dynamic shapes, no host alloc, no JIT-during-capture, stable workspace) addressed point by point.
  6. Tensor parallelism analysis: TP-trivial vs. TP-sensitive classification, sharding rules for weights and auxiliary tensors.
  7. Testing plan: unit tests under tests/kernels/, integration tests under tests/models/, both eager and captured-graph modes, tolerance rationale.
  8. Benchmarking plan: harnesses used, hardware, model, baseline, target metrics.
  9. Risk register: known risks (TP edge cases, dtype gaps, graph capture pitfalls) with mitigations.
  10. Out-of-scope statement: what the integration explicitly does not cover (e.g., AMD support deferred, fp8 deferred), so reviewers do not expect it.

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.