brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
compilation-and-exportUse this sub-skill for Torch-TensorRT model compilation, dynamic input planning, torch.export workflows, save/load formats, raw TensorRT engines, and compile-time troubleshooting.
Independent GitHub snapshot · Automated classification · Original documentation governs
Use this sub-skill when the user wants to turn a PyTorch model into a TensorRT-backed callable module or deployable artifact.
| User situation | Recommended route |
|---|---|
| Wants a one-line experiment or easy integration with PyTorch 2.x | torch.compile(model, backend="torch_tensorrt") or backend="tensorrt" with options. |
| Wants ahead-of-time control, explicit inputs, and a Python-callable compiled module | torch_tensorrt.compile(model, ir="dynamo", inputs=[...]). |
Already uses torch.export, needs dynamic shape control, or wants raw engine export | torch.export.export(...) then torch_tensorrt.dynamo.compile(...) or convert_exported_program_to_serialized_trt_engine(...). |
Needs legacy TorchScript or C++ .ts artifacts | Use only if ENABLED_FEATURES.torchscript_frontend and runtime libraries are present; otherwise route to deployment/build guidance. |
| Needs to understand coverage before compiling | Use dryrun, require_full_compilation, torch_executed_ops, and min_block_size; route debugging details to extensibility/debugging. |
Read references/workflows.md for full recipes and route selection.
torch_tensorrt.Input(min_shape=..., opt_shape=..., max_shape=..., dtype=...) and align any torch.export dynamic dimensions.torch.testing.assert_close at task-appropriate tolerances..ep, .ts, .pt2, .engine, or .pte from the artifact matrix.references/api-reference.md for public signatures and setting categories.references/dynamic-shapes-and-inputs.md for Input, Device, torch.export dynamic shapes, shared_dims, and multiple optimization profiles.references/serialization-and-engines.md before saving/loading, extracting raw engines, cross-compiling for Windows, or choosing deployment artifacts.references/troubleshooting.md for compile errors, graph breaks, unsupported ops, dynamic-shape errors, precision mismatches, and runtime library surprises.scripts/compile_probe.py --help to inspect the bundled tiny compile/dryrun helper. Run it with --compile only when a compatible CUDA/TensorRT environment is available.torch.compileimport torch
import torch_tensorrt
model = MyModel().eval().cuda()
optimized = torch.compile(
model,
backend="torch_tensorrt",
options={"enabled_precisions": {torch.float16}, "min_block_size": 3},
)
out = optimized(torch.randn(1, 3, 224, 224, device="cuda")) # first call compiles
Use this when the user wants to keep PyTorch calling semantics and does not need a saved artifact immediately.
import torch
import torch_tensorrt
model = MyModel().eval().cuda()
inputs = [torch_tensorrt.Input((1, 3, 224, 224), dtype=torch.float32)]
compiled = torch_tensorrt.compile(model, ir="dynamo", inputs=inputs)
Use explicit Input objects for reusable code and dynamic shapes; use real tensors when the model is static and simple.
import torch
import torch_tensorrt
model = MyModel().eval().cuda()
example = (torch.randn(4, 128, device="cuda"),)
batch = torch.export.Dim("batch", min=1, max=16)
exported = torch.export.export(model, example, dynamic_shapes={"x": {0: batch}})
compiled = torch_tensorrt.dynamo.compile(
exported,
inputs=[torch_tensorrt.Input(min_shape=(1, 128), opt_shape=(4, 128), max_shape=(16, 128))],
)
Use this when export constraints, dynamic shape names, or artifact packaging matter.
../extensibility-and-debugging/SKILL.md after collecting a dryrun/debugger result.../runtime-optimization/SKILL.md after compile correctness is established.../deployment-and-distributed/SKILL.md before choosing save format.