[TRTLLM-10487][feat] Add user-provided UUID support for multimodal KV cache identification.#11075
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #33925 [ run ] triggered by Bot. Commit: |
📝 WalkthroughWalkthroughThis pull request introduces multimodal UUID support for deterministic cache identification across the TensorRT LLM codebase. It extends request payloads, serialization mechanisms, and the hashing pipeline to propagate optional per-item UUIDs from user input through C++ execution and Python bindings, enabling stable KV cache management for multimodal content. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (11)
tensorrt_llm/_torch/pyexecutor/_util.py (1)
1-1: Add the NVIDIA copyright header with the latest modification year (2026).
This file now changes in 2026 but has no NVIDIA header at all. Please add the standard header.As per coding guidelines, all TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification.
cpp/include/tensorrt_llm/executor/serialization.h (1)
1-2: Update the NVIDIA copyright year to reflect 2026 changes.As per coding guidelines, all TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification.
cpp/tensorrt_llm/nanobind/executor/bindings.cpp (1)
1-3: Update the NVIDIA copyright year to include 2026.As per coding guidelines, all TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification.
cpp/tensorrt_llm/nanobind/batch_manager/llmRequest.cpp (1)
1-3: Update the NVIDIA copyright year to include 2026.As per coding guidelines, all TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification.
tests/unittest/bindings/test_executor_bindings.py (1)
1-1: Add the NVIDIA copyright header with the latest modification year (2026).
This test file is missing the required NVIDIA header.As per coding guidelines, all TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification.
tensorrt_llm/_utils.py (1)
1-1: Update the NVIDIA copyright year to include 2026.As per coding guidelines, all TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification.
tensorrt_llm/inputs/registry.py (1)
662-671: Fix docstring typo (“multinmodal” → “multimodal”).✏️ Suggested fix
- Process the multinmodal hashing for media tokens if possible. + Process the multimodal hashing for media tokens if possible.cpp/include/tensorrt_llm/executor/executor.h (1)
1-3: Update the copyright year to reflect the latest modification (2026).The header still ends at 2024, but this file is now modified in 2026. Please update the year range accordingly.
📝 Suggested update
- * Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2022-2026, NVIDIA CORPORATION. All rights reserved.tensorrt_llm/inputs/multimodal.py (2)
1-1: Add the NVIDIA Apache 2.0 copyright header (latest year 2026).This file is missing the required TensorRT‑LLM copyright header. Please add the standard NVIDIA header at the top.
584-692: Guard against non‑string UUIDs before hashing.
uuid_to_hashassumes a string; invalid types currently raise an AttributeError. Add an explicit type check for clearer errors.🛠️ Suggested fix
for i, item in enumerate(items): uuid = modality_uuids[i] if modality_uuids else None if uuid is not None: + if not isinstance(uuid, str): + raise TypeError( + f"UUID for modality '{modality}' at index {i} must be a string or None, got {type(uuid)}" + ) # Use UUID-based hash hashes.append(uuid_to_hash(uuid, hash_lib)) all_uuids.append(uuid) # Store original UUIDtests/unittest/_torch/multimodal/test_mm_encoder_standalone.py (1)
1-7: Add the NVIDIA Apache 2.0 copyright header (latest year 2026).This test module is missing the required NVIDIA header. Please add the standard TensorRT‑LLM header at the top.
🤖 Fix all issues with AI agents
In `@cpp/include/tensorrt_llm/executor/executor.h`:
- Around line 52-73: The header defines MmKey which uses std::array<uint8_t, 32>
but does not include <array>, so make the header self-contained by adding an
`#include` <array> near the other standard includes in executor.h; ensure the
include is placed before the MmKey definition so the std::array type is
available when parsing the struct (refer to MmKey, hash, and executor.h to
locate where to add the include).
In `@cpp/tests/unit_tests/executor/serializeUtilsTest.cpp`:
- Around line 1149-1151: The initializer for extraKeys is too long; split the
std::vector<MmKey> extraKeys initializer into multiple lines so each MmKey
element is on its own line (or wraps the inner std::string/std::nullopt entries)
to keep lines under 120 characters; update the line creating extraKeys
(references: MmKey, extraKeys, h1, h2, h3, SizeType32) so each element is
clearly separated and fits within the limit.
- Around line 1129-1131: The long UUID literal in the MmKey construction
(variable keyLongUuid passed to testSerializeDeserialize) exceeds the 120-char
line limit; break the string across lines so the source line stays under 120
chars (e.g., use a named const std::string uuid split across literals or
adjacent string literal concatenation and then pass that uuid into MmKey{hash,
SizeType32{255}, uuid}). Ensure the identifier names MmKey, keyLongUuid, and
testSerializeDeserialize are unchanged.
- Around line 1236-1239: The long UUID literal in the test vector longUuids in
serializeUtilsTest.cpp exceeds the 120-character line length; split the long
string into multiple shorter adjacent string literals or concatenate smaller
string parts to keep each source line under 120 chars (ensure the resulting
std::string value remains identical) and update the initializer for longUuids
accordingly so the test semantics (the long UUID value and the "short" entry)
are unchanged.
In `@tests/unittest/llmapi/test_llm_kv_cache_events.py`:
- Around line 425-440: The pytest.raises call in
test_apply_mm_hashes_uuid_length_mismatch uses a normal string for the regex
match which triggers RUF043; change the match argument to a raw string literal
(prefix with r) so the regex metacharacters like .* are interpreted correctly,
i.e., update the pytest.raises(..., match="UUID list length.*doesn't match.*data
items") to use a raw string r"UUID list length.*doesn't match.*data items" in
the test_apply_mm_hashes_uuid_length_mismatch that calls apply_mm_hashes.
🧹 Nitpick comments (2)
cpp/include/tensorrt_llm/executor/serialization.h (1)
352-355: Use Doxygen//!for the new MmKey section in the header.
Please convert the new section comment to Doxygen style (and add brief descriptions if needed) to match header documentation rules.As per coding guidelines, follow Doxygen rules for documenting new C++ class interfaces and function prototypes.
cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp (1)
148-156: Consider declaringuuidasconstafter conditional assignment.The variable
uuidis assigned once and never modified afterward. While the current code is correct, a slightly cleaner pattern would use a ternary or immediately-invoked lambda to enableconst:♻️ Optional refactor suggestion
- std::optional<std::string> uuid = std::nullopt; - if (multimodalUuids && *multimodalUuids && i < (*multimodalUuids)->size()) - { - uuid = (*(*multimodalUuids))[i]; - } + auto const uuid = [&]() -> std::optional<std::string> + { + if (multimodalUuids && *multimodalUuids && i < (*multimodalUuids)->size()) + { + return (*(*multimodalUuids))[i]; + } + return std::nullopt; + }();
|
PR_Github #33925 [ run ] completed with state
|
eopXD
left a comment
There was a problem hiding this comment.
Overall looks good. Do we guarantee UUID to be unique? How do we deal with collision.
kaiyux
left a comment
There was a problem hiding this comment.
Approving on behalf of trt-llm-doc-owners
2091730 to
4121ed0
Compare
|
/bot run --disable-fail-fast |
4121ed0 to
3306c17
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #34508 [ run ] triggered by Bot. Commit: |
3306c17 to
f94960b
Compare
|
PR_Github #35028 [ run ] completed with state
|
db094a6 to
b857e07
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #35133 [ run ] triggered by Bot. Commit: |
|
PR_Github #35133 [ run ] completed with state
|
b857e07 to
8d38f01
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #35175 [ run ] triggered by Bot. Commit: |
|
PR_Github #35175 [ run ] completed with state
|
8d38f01 to
5ad0359
Compare
|
/bot skip --comment "CI failures are all known bugs: 5880261, 5879614 and 5863877." |
|
PR_Github #35545 [ skip ] triggered by Bot. Commit: |
|
PR_Github #35545 [ skip ] completed with state |
5ad0359 to
80a8e99
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #35551 [ run ] triggered by Bot. Commit: |
|
PR_Github #35551 [ run ] completed with state
|
… cache identification This commit enables users to provide custom UUID strings for multimodal inputs (images, videos, etc.) to achieve deterministic KV cache management across sessions. When UUIDs are provided via the `multi_modal_uuids` parameter, they serve as stable identifiers in place of content-based hashes, allowing for predictable cache lookups without reprocessing content. Signed-off-by: SimengLiu-nv <simengl@nvidia.com>
Signed-off-by: SimengLiu-nv <simengl@nvidia.com>
Signed-off-by: SimengLiu-nv <simengl@nvidia.com>
…tent and other changes. Signed-off-by: SimengLiu-nv <simengl@nvidia.com>
Signed-off-by: SimengLiu-nv <simengl@nvidia.com>
80a8e99 to
63d27d5
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #35657 [ run ] triggered by Bot. Commit: |
|
PR_Github #35657 [ run ] completed with state |
… cache identification. (NVIDIA#11075) Signed-off-by: SimengLiu-nv <simengl@nvidia.com>

This commit enables users to provide custom UUID strings for multimodal inputs (images, videos, etc.) to achieve deterministic KV cache management across sessions. When UUIDs are provided via the
multi_modal_uuidsparameter, they serve as stable identifiers in place of content-based hashes, allowing for predictable cache lookups without reprocessing content.Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.
Description
Test Coverage
cpp/tests/unit_tests/executor/serializeUtilsTest.cpp
tests/unittest/_torch/multimodal/test_mm_encoder_standalone.py
tests/unittest/bindings/test_executor_bindings.py
tests/unittest/llmapi/test_llm_kv_cache_events.py
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
Details
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.