Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/runtime/TRTEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions py/torch_tensorrt/dynamo/conversion/impl/slice_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Loading