SKY-GPU003 · Deployment and infrastructure
TensorRT engine shipped to GPUs it was not built for
A serialized TensorRT engine is a model compiled for one GPU model; by default it only runs on GPUs with the same compute capability. SKY-GPU003 reports an engine that is built, written to a file and copied into the release image when the contract lists GPUs with different compute capabilities.
- Languages
- Python, C++, Dockerfile, GPU target contract (YAML)
- Quality gate
- counted toward the gate limits (full and diff scans). Reported under reliability. It counts toward
max_reliability, which is 0 by default, so one finding fails--gate. - Needs
- A
.skylos/gpu-targets.ymlcontract in the repository. - Finding type
- review
- Catalog name
- TensorRT engine is not portable across target GPUs
Why it matters
On the other GPUs TensorRT refuses to load the engine, so the service starts but every inference fails. The mismatch is only visible on the hardware itself.
What Skylos flags
import tensorrt as trt logger = trt.Logger(trt.Logger.WARNING)builder = trt.Builder(logger)network = builder.create_network(0)parser = trt.OnnxParser(network, logger)with open("model.onnx", "rb") as model: parser.parse(model.read())config = builder.create_builder_config()serialized = builder.build_serialized_network(network, config)with open("model.engine", "wb") as output: output.write(serialized)FROM nvcr.io/nvidia/tensorrt:24.05-py3COPY model.engine /models/model.engineCOPY serve.py /app/serve.pyCMD ["python3", "/app/serve.py"]cmake_minimum_required(VERSION 3.24)project(trt_plugins LANGUAGES CXX CUDA)set(CMAKE_CUDA_ARCHITECTURES 80 86)add_library(trt_plugins SHARED plugins/nms.cu)version: 1targets: - name: a100 vendor: nvidia compute_capability: "8.0" - name: rtx-a6000 vendor: nvidia compute_capability: "8.6"What Skylos leaves alone
import tensorrt as trt logger = trt.Logger(trt.Logger.WARNING)builder = trt.Builder(logger)network = builder.create_network(0)parser = trt.OnnxParser(network, logger)with open("model.onnx", "rb") as model: parser.parse(model.read())config = builder.create_builder_config()config.hardware_compatibility_level = trt.HardwareCompatibilityLevel.AMPERE_PLUSserialized = builder.build_serialized_network(network, config)with open("model.engine", "wb") as output: output.write(serialized)Why Skylos leaves it alone
The builder sets the AMPERE_PLUS hardware compatibility level on this config before building, so the engine runs on every Ampere or newer GPU, including both targets.
How Skylos decides
- Runs with
--danger(or-a), and only when the repository has a GPU target contract:.skylos/gpu-targets.yml(or.yaml), version 1, listing each target'sname,vendor: nvidia, and itsdriver,compute_capabilityandplatform(linuxorwindows, optionally/amd64or/arm64). Without the file nothing is checked, unless anSKY-GPUrule is selected explicitly with--select. - Reads Dockerfiles, CMake files, Makefiles, Bazel files, shell scripts, Python, C/C++/CUDA sources and YAML as text, skipping
build,dist,node_modules, caches and virtual environments. It never runs a build or probes a GPU. - Needs a contract with targets of different compute capabilities.
- In Python, finds a
build_serialized_network(network, config)call, a later binary write of its result to a literal file path, and aCOPYorADDof that exact file in the final Docker stage. C++ builders usingNvInfer.hare matched the same way. - Does not report when that same config object gets
hardware_compatibility_level = AMPERE_PLUSbefore the build and every target is Ampere (8.0) or newer. - Reports HIGH on the build call.
How to fix it
Build the engine on the target GPU at deploy time, ship one engine per compute capability, or build with the AMPERE_PLUS hardware compatibility level when every target is Ampere or newer.
import tensorrt as trt logger = trt.Logger(trt.Logger.WARNING)builder = trt.Builder(logger)network = builder.create_network(0)parser = trt.OnnxParser(network, logger)with open("model.onnx", "rb") as model: parser.parse(model.read())config = builder.create_builder_config()Added: config.hardware_compatibility_level = trt.HardwareCompatibilityLevel.AMPERE_PLUSserialized = builder.build_serialized_network(network, config)with open("model.engine", "wb") as output: output.write(serialized)When it can be wrong
AMPERE_PLUSdoes not make an engine portable across operating systems or CPU architectures, and is not counted as covering pre-Ampere GPUs such as a T4.- An engine that is built but not copied into the final Docker stage is not reported.
- The compatibility level must be assigned as written in the example. Setting it through a variable (
level = trt.HardwareCompatibilityLevel.AMPERE_PLUS, thenconfig.hardware_compatibility_level = level) is not recognised, so a portable engine is still reported.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put the marker on the build call line, or in a comment on the line above it.
Python # skylos: ignore[SKY-GPU003] fleet is being moved to A100 onlyserialized = builder.build_serialized_network(network, config)[tool.skylos] ignore = ["SKY-GPU003"]turns the rule off for the project.A baseline (
skylos baseline ., then--baseline) accepts the findings that exist today and reports new ones.