Skip to content

Commit 9c1e299

Browse files
committed
fix: build against TensorRT older than 10.15
Building Torch-TensorRT against TensorRT 10.13 or older fails to compile: core/runtime/TRTEngine.cpp:298: error: 'class nvinfer1::ICudaEngine' has no member named 'getAliasedInputTensor' That API was added in TensorRT 10.15, together with the IKVCacheUpdateLayer that produces the aliasing it reports. The runtime calls it unconditionally, while the package declares a bare tensorrt dependency with no minimum version, so an older TensorRT produces a compile error rather than a clear message. The call is only used to reconcile the build-time aliased I/O map against what the engine reports. On older TensorRT there is nothing to reconcile against, so the build-time map stands on its own and the reconciliation is skipped. Guard it with a named feature macro, following the existing TRT_HAS_NATIVE_NCCL convention in the same header.
1 parent 3141ff3 commit 9c1e299

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

core/runtime/TRTEngine.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ TRTEngine::TRTEngine(
292292
// engines built outside Torch-TensorRT). User-declared aliases (kind=kUser)
293293
// are preserved as-is since TRT doesn't know about them.
294294
this->aliased_io = aliased_io;
295+
#ifdef TRT_HAS_ENGINE_ALIASED_IO
295296
for (const auto& out_name : this->out_binding_names) {
296297
// TRT returns nullptr / empty string for non-aliased outputs; any thrown
297298
// exception is a real error in the engine state and propagates.
@@ -315,6 +316,10 @@ TRTEngine::TRTEngine(
315316
it->second = AliasedIOSpec{std::string(aliased_in), AliasKind::kKVCacheUpdate};
316317
}
317318
}
319+
#else
320+
// Older TensorRT cannot report an engine's aliasing, so the build-time map is
321+
// the only source of truth and there is nothing to reconcile against.
322+
#endif
318323

319324
// Precompute the set of input binding names that are the alias source of some
320325
// output (for the O(1) per-call membership test) and validate every aliased

core/runtime/TRTEngine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
#define TRT_HAS_NATIVE_NCCL 1
2828
#endif
2929

30+
// TensorRT 10.15+ can report an engine's aliased I/O via
31+
// ICudaEngine::getAliasedInputTensor, alongside IKVCacheUpdateLayer that produces it.
32+
#if NV_TENSORRT_MAJOR > 10 || (NV_TENSORRT_MAJOR == 10 && NV_TENSORRT_MINOR >= 15)
33+
#define TRT_HAS_ENGINE_ALIASED_IO 1
34+
#endif
35+
3036
// Full TRT NCCL collectives support requires both:
3137
// 1. PyTorch built with NCCL (USE_C10D_NCCL defined via Bazel)
3238
// 2. TensorRT 10.16+ (TRT_HAS_NATIVE_NCCL defined above)

0 commit comments

Comments
 (0)