Write tensorrt plugin integration plan

From tensormux/kernel-skills · View interactive version

Write tensorrt plugin integration plan is an AI agent skill from the GitHub repository tensormux/kernel-skills. Guide the agent through planning how a custom CUDA kernel will be wrapped as a TensorRT plugin so it can be invoked from inside a TensorRT engine — covering API choice (IPluginV3 vs IPluginV2DynamicEx

How to use this skill

Skill file

Skill: Write a TensorRT Plugin Integration Plan

Purpose

Guide the agent through planning how a custom CUDA kernel will be wrapped as a TensorRT plugin so it can be invoked from inside a TensorRT engine — covering API choice (IPluginV3 vs IPluginV2DynamicExt), the plugin lifecycle, dynamic shape handling, serialization, mixed precision (FP16/INT8/FP8), workspace management, CUDA graph compatibility, and the C++/Python binding strategy. The output is an integration plan with explicit decisions, not the plugin source code itself.

Use this when

Do not use this when

Inputs the agent should gather first

Required reasoning process

  1. Choose the plugin API. This is the first decision and constrains everything downstream:

| API | TRT version | Recommended for | Notes |

|---|---|---|---|

| IPluginV3 | 9.x+, required in 10.x | New plugins, long-term codebases | Splits responsibilities across IPluginV3OneCore, IPluginV3OneBuild, IPluginV3OneRuntime. Cleaner lifecycle, better forward compatibility. |

| IPluginV2DynamicExt | 8.x, 9.x (deprecated path) | Matching an existing codebase that uses it (TRT-LLM 0.x, NVIDIA samples) | Single-class API. Still functional in 9.x but flagged for removal. |

| IPluginV2Ext / IPluginV2 | Legacy | Static-shape-only inference, almost never appropriate | No dynamic shape support; do not use for transformer or vision-with-variable-resolution workloads. |

Default for a greenfield plugin on TRT ≥ 9.3: IPluginV3. Default when extending a codebase already on IPluginV2DynamicExt: match the convention; do not mix APIs in one project.

  1. Map the plugin lifecycle to your kernel. For IPluginV3OneBuild + IPluginV3OneRuntime, every method has a specific role and serializing the wrong state into the wrong method is the most common bug class:
  1. Design the dynamic-shape contract. TRT engines are built against optimization profiles, each with min/opt/max shapes. The plugin must:
  1. Design the serialization contract. Engines are built once and loaded N times in production:
  1. Plan the format combination table. This is a table of (input_dtype, input_format, output_dtype, output_format) tuples the plugin advertises as supported. Decisions:
  1. Plan workspace memory. TRT owns workspace; the plugin requests it:
  1. Plan for CUDA graph capture. Production TRT inference uses enqueueV3 with CUDA graphs to amortize launch overhead:
  1. Plan the build and binding artifacts.
  1. Validate the plan against existing alternatives. Before committing:

Kernel design rules

Correctness requirements

Performance requirements

Output format

The final response must include:

  1. API decision: IPluginV3 vs IPluginV2DynamicExt with explicit justification (TRT version, codebase convention, forward compatibility).
  2. Lifecycle table: each lifecycle method mapped to what the plugin does in it, including which attributes are read/written.
  3. Format combination table: the exact (input_dtype, format, output_dtype, format) tuples the plugin advertises, with a precision support row for FP32, FP16, BF16, INT8, FP8 as applicable.
  4. Dynamic shape contract: which input dims are dynamic, the symbolic output shape expression, and any alignment constraints declared in supportsFormatCombination.
  5. Serialization spec: the full list of fields serialized, with sizes; explicit confirmation that no runtime state is serialized.
  6. Workspace plan: upper-bound formula for getWorkspaceSize, with the layout of how the workspace is partitioned inside enqueue.
  7. CUDA graph compatibility checklist: confirmation that no host alloc, no sync, all launches on the provided stream.
  8. Build/binding plan: shared library name, link line, registration mechanism, and Python loading path if applicable.
  9. Risk register: list of known failure modes for this specific plugin (precision edge cases, profile boundary shapes, version compatibility).

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.