diff --git a/core/runtime/TRTEngine.cpp b/core/runtime/TRTEngine.cpp index fb96628ec5..b8b711375e 100644 --- a/core/runtime/TRTEngine.cpp +++ b/core/runtime/TRTEngine.cpp @@ -292,6 +292,10 @@ TRTEngine::TRTEngine( // engines built outside Torch-TensorRT). User-declared aliases (kind=kUser) // are preserved as-is since TRT doesn't know about them. this->aliased_io = aliased_io; +// ICudaEngine::getAliasedInputTensor is not available before TRT 10.15 (e.g. Jetpack +// L4T builds), where an engine cannot report its aliasing and the build-time map is +// the only source of truth. +#if NV_TENSORRT_MAJOR > 10 || (NV_TENSORRT_MAJOR == 10 && NV_TENSORRT_MINOR >= 15) for (const auto& out_name : this->out_binding_names) { // TRT returns nullptr / empty string for non-aliased outputs; any thrown // exception is a real error in the engine state and propagates. @@ -315,6 +319,7 @@ TRTEngine::TRTEngine( it->second = AliasedIOSpec{std::string(aliased_in), AliasKind::kKVCacheUpdate}; } } +#endif // Precompute the set of input binding names that are the alias source of some // output (for the O(1) per-call membership test) and validate every aliased diff --git a/py/torch_tensorrt/dynamo/conversion/impl/slice_scatter.py b/py/torch_tensorrt/dynamo/conversion/impl/slice_scatter.py index c277a4ca6b..579fee0429 100644 --- a/py/torch_tensorrt/dynamo/conversion/impl/slice_scatter.py +++ b/py/torch_tensorrt/dynamo/conversion/impl/slice_scatter.py @@ -97,6 +97,16 @@ def emit_kv_cache_update_layer( logger.debug("KV cache update: skipped — input is not a direct network input") return None + # add_kv_cache_update and KVCacheMode do not exist before TensorRT 10.15 (e.g. + # Jetpack L4T builds). Returning None here takes the caller's existing fallback + # instead of raising AttributeError, which reads like a bug in the model. + if not hasattr(ctx.net, "add_kv_cache_update") or not hasattr(trt, "KVCacheMode"): + logger.debug( + "KV cache update: skipped, this TensorRT build has no " + "KV-cache update layer" + ) + return None + layer = ctx.net.add_kv_cache_update( cache, src, write_indices, trt.KVCacheMode.LINEAR )