Skip to content

[#10013][feat] AutoDeploy: native cache manager integration - #10635

Merged
lucaslie merged 1 commit into
NVIDIA:mainfrom
nv-auto-deploy:ll/cm_integration
Jan 27, 2026
Merged

[#10013][feat] AutoDeploy: native cache manager integration#10635
lucaslie merged 1 commit into
NVIDIA:mainfrom
nv-auto-deploy:ll/cm_integration

Conversation

@lucaslie

@lucaslie lucaslie commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Description

fixes #10013

New Features

  • Introduces a unified integration of caches (kv, states, ...) for AutoDeploy into TRT-LLM Cache ResourceManagers with the following design:
    1. During the graph transforms for caching, we build up a cache-wise lookup of needed cache resources based on the underlying attention ops.
    2. The descriptors of the cache resources are then organized into buckets corresponding to vanilla kv-pages, state resources, and generic resources.
    3. Based on the organization, the cache resources are initialized and managed via the corresponding Resource Manager (or managed internally if it's a generic resource)
  • Unified configuration of caching with PT's config class KVCacheConfig
  • Introduced a per-transform memory tracker to track memory usage in every transform. Each transform indicates whether a change in CUDA memory is expected or not and the tracker emits a warning if unexpected memory changes happen

Backwards breaking changes (ACTION REQUIRED)

  • Deprecation of arguments

    • transforms.resize_kv_cache.free_mem_ratio --> kv_cache_config.free_gpu_memory_fraction
    • attn_page_size --> kv_cache_config.tokens_per_block
    • transforms.insert_cached_ssm_attention.cache_config.mamba_dtype --> kv_cache_config.mamba_ssm_cache_dtype
  • New features and behavior

    • Transforms default behavior is now expect_mem_change: False. If you expect a transform to change mem allocation, make sure to set expect_mem_change: True
    • The notion of buffers in the AttentionDescriptor has been deprecated without replacement as it is not needed anymore.

@lucaslie
lucaslie requested review from a team as code owners January 13, 2026 15:26
@lucaslie
lucaslie marked this pull request as draft January 13, 2026 15:26
@coderabbitai

coderabbitai Bot commented Jan 13, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This pull request refactors the AutoDeploy KV cache management system to use native KVCacheManager with abstract cache resource handlers. It replaces page-based configuration (attn_page_size, free_mem_ratio) with a token-block-based system (tokens_per_block, free_gpu_memory_fraction), introduces a resource handler abstraction for cache initialization, and removes several deprecated parameters from the LLM configuration interface.

Changes

Cohort / File(s) Summary
Documentation Updates
docs/source/features/auto_deploy/advanced/benchmarking_with_trtllm_bench.md, docs/source/torch/auto_deploy/advanced/*
Replaced free_mem_ratio parameter with kv_cache_config.free_gpu_memory_fraction; removed resize_kv_cache transform references; updated configuration examples and performance guidance.
Configuration Files
examples/auto_deploy/model_registry/configs/*, examples/auto_deploy/*.yaml, tensorrt_llm/_torch/auto_deploy/config/*
Removed free_mem_ratio entries and resize_kv_cache blocks; replaced with new kv_cache_config structure using free_gpu_memory_fraction; updated YAML configuration schemas.
Cache Interface Architecture
tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py
Major refactoring: replaced CacheConfig with KvCacheConfig; replaced page_size with tokens_per_block; introduced resource handler hierarchy (ResourceHandler, PagedResourceHandler, StateResourceHandler, UnpagedResourceHandler); replaced functional cache initializers with resource-based objects; removed is_paged() methods.
Attention Descriptors
tensorrt_llm/_torch/auto_deploy/custom_ops/flashinfer_attention.py, tensorrt_llm/_torch/auto_deploy/custom_ops/mla.py, tensorrt_llm/_torch/auto_deploy/custom_ops/torch_backend_attention.py, tensorrt_llm/_torch/auto_deploy/custom_ops/triton_attention.py
Updated get_cache_initializers() signature to accept KvCacheConfig and return ResourceHandlerDict; removed is_paged() classmethod; replaced workspace buffer handling with resource-based initialization; updated cache dtype resolution.
Mamba/SSM Cache Backends
tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/*.py, tensorrt_llm/_torch/auto_deploy/custom_ops/fla/fla_backend_delta.py
Updated cache initializer interfaces to use KvCacheConfig and StateResourceHandler; removed is_paged() methods; switched from function-based cache creation to resource handler objects.
LLM Arguments & Configuration
tensorrt_llm/_torch/auto_deploy/llm_args.py, tensorrt_llm/llmapi/llm_args.py
Removed kv_cache_config, kv_cache_dtype, attn_page_size, free_mem_ratio fields from AutoDeployConfig; removed build_config from LlmArgs; added causal_conv_cache_dtype and delta_net_cache_dtype to KvCacheConfig.
Model Factory & Quantization
tensorrt_llm/_torch/auto_deploy/models/factory.py, tensorrt_llm/_torch/auto_deploy/models/hf.py, tensorrt_llm/_torch/auto_deploy/models/quant_config_reader.py
Renamed get_cache_config() to get_cache_config_updates(); changed return type from CacheConfig to Dict[str, Any]; updated quantization config reader to use "fp8" string instead of torch dtype.
Executor & Cache Management Shim
tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py, tensorrt_llm/_torch/auto_deploy/shim/demollm.py
Removed _CacheManagerWithFakePool internal class; replaced attn_page_size with tokens_per_block sourced from kv_cache_config; refactored slot index resolution; updated cache manager initialization path; changed page-based to block-based allocation logic.
Cached Sequence Interface
tensorrt_llm/_torch/auto_deploy/shim/interface.py
Major redesign: added kv_cache_config parameter; introduced resource registration system (add_resource()); added initialize_resources(), update_kv_cache_config(), resize_kv_cache_manager(); added unified byte-buffer views for paged and state resources; added cache manager creation workflow.
Transform Library
tensorrt_llm/_torch/auto_deploy/transform/library/kvcache.py, tensorrt_llm/_torch/auto_deploy/transform/library/build_model.py, tensorrt_llm/_torch/auto_deploy/transform/library/hidden_states.py
Removed ResizeKVCacheConfig class; removed buffer node handling; refactored ResizeKVCache to use cm.needs_resize() and cm.resize_kv_cache_manager(); renamed initialize_caches() to initialize_resources(); introduced HiddenStatesResourceHandler for state resource management.
KVCache Transform Helpers
tensorrt_llm/_torch/auto_deploy/transform/library/kvcache_transformers.py
Removed buffer_nodes parameter from cache insertion; updated metadata key from "metadata_cache_buffer_keys" to "metadata_cache_keys".
Resource Manager
tensorrt_llm/_torch/pyexecutor/resource_manager.py
Added force_distributed_sync parameter to KVCacheManager.__init__ to enable distributed synchronization in single-process setups.
Test Updates
tests/integration/defs/accuracy/test_llm_api_autodeploy.py, tests/integration/defs/perf/test_perf.py, tests/unittest/_torch/auto_deploy/*
Updated test configurations to use kv_cache_config with free_gpu_memory_fraction; removed attn_page_size and resize_kv_cache test cases; renamed test parameters from attn_page_size to tokens_per_block; refactored planner initialization to use device-specific reset; updated factory mock objects.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~65 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive Changes are tightly scoped to the cache manager integration objective. However, some secondary refactorings appear tangential: replacing page_size with tokens_per_block terminology, removing attn_page_size parameter, and various test infrastructure updates. These are likely necessary for the integration but represent broader architectural shifts beyond just 'native cache manager integration'. Clarify in PR description whether terminology changes (tokens_per_block, attn_page_size removal) and configuration restructuring are essential to the cache manager integration or represent separate refactoring efforts.
Description check ❓ Inconclusive The PR description is minimal with only the issue number and high-level bullet points, lacking detailed explanation of what, why, and how. Expand the description with: (1) clear problem statement, (2) solution approach and design rationale, (3) list of key changes and their purpose, (4) relevant test coverage details, (5) any breaking changes or migration notes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title '[#10013][feat] AutoDeploy: native cache manager integration' clearly and specifically describes the main feature: integrating AutoDeploy with the native cache manager. It directly relates to the primary objective in the linked issue.
Linked Issues check ✅ Passed The PR addresses the primary objective from issue #10013: deeply integrating AutoDeploy with the native KVCacheManager using abstract cache handlers. The raw_summary shows extensive refactoring replacing CacheConfig with KvCacheConfig, introducing ResourceHandler hierarchy, and integrating cache management through CachedSequenceInterface, directly fulfilling the issue's requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (6)
tests/unittest/_torch/auto_deploy/_utils_test/_graph_test_helpers.py (1)

1-10: Missing NVIDIA copyright header.

Per coding guidelines, all TensorRT-LLM source files (including .py) should contain an NVIDIA copyright header with the year of latest meaningful modification.

Proposed fix
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 import copy
 from typing import Callable, Dict, List, Optional
tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_build_small_single.py (1)

1-2: Missing NVIDIA copyright header.

As per the coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header with the year of latest meaningful modification. This file is missing the required copyright header at the top.

Proposed fix to add copyright header
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 """Testing build_and_run_ad end2end."""
tensorrt_llm/_torch/auto_deploy/transform/library/build_model.py (1)

71-91: Missing update_kv_cache_config call for consistency.

BuildAndLoadFactoryModel overrides _apply_to_full_model() but doesn't call cm.update_kv_cache_config(). Since this class explicitly uses hf.AutoModelFactory (which returns dtype updates from get_cache_config_updates()), the KV cache config updates may not be applied for HF models loaded via this path.

Suggested fix
         # build and load the model
         model = factory.build_and_load_model(cm.device)
 
+        # update the kv cache config
+        cm.update_kv_cache_config(**factory.get_cache_config_updates())
+
         # we set the standard example sequence WITHOUT extra_args to set them to None so that
         # only the text portion of the model gets called.
         cm.info.set_example_sequence()
tests/unittest/_torch/auto_deploy/unit/singlegpu/shim/test_engine.py (1)

1-4: Missing NVIDIA copyright header.

As per coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header with the year of latest meaningful modification.

Suggested fix
+# SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 from types import SimpleNamespace
 from typing import List, Optional, Type
tests/integration/defs/accuracy/test_llm_api_autodeploy.py (2)

107-119: Duplicate kv_cache_config key overwrites enable_block_reuse setting.

The dictionary has "kv_cache_config" defined twice (lines 107-109 and 117-119). Python dictionaries use the last occurrence, so enable_block_reuse: False is silently discarded. Since SSMs do not support cache reuse (as noted in the comment), this bug could cause test failures or incorrect behavior.

Proposed fix: merge into single kv_cache_config
             # SSMs do not support cache reuse.
             "kv_cache_config": {
-                "enable_block_reuse": False
-            },
-            # Keep max_batch_size as in the PyTorch test to avoid OOM
-            "max_batch_size": 128,
-            # Model context length is 8K
-            "max_seq_len": 8192,
-            # Set explicitly to match default build_config behavior
-            "max_num_tokens": 8192,
-            "skip_loading_weights": False,
-            "kv_cache_config": {
-                "free_gpu_memory_fraction": 0.7
+                "enable_block_reuse": False,
+                "free_gpu_memory_fraction": 0.7,
             },
+            # Keep max_batch_size as in the PyTorch test to avoid OOM
+            "max_batch_size": 128,
+            # Model context length is 8K
+            "max_seq_len": 8192,
+            # Set explicitly to match default build_config behavior
+            "max_num_tokens": 8192,
+            "skip_loading_weights": False,

165-181: Duplicate kv_cache_config key overwrites enable_block_reuse and mamba config.

Same issue: "kv_cache_config" is defined at lines 165-169 and again at lines 179-181. The second definition overwrites the first, losing enable_block_reuse: False and the mamba cache dtype comments. This could cause incorrect behavior for the MOE model tests.

Proposed fix: merge into single kv_cache_config
             # SSMs do not support cache reuse.
             "kv_cache_config": {
-                "enable_block_reuse": False
+                "enable_block_reuse": False,
+                "free_gpu_memory_fraction": 0.7,
                 # NOTE: some accuracy benchmarks may require fp32 precision for mamba cache
                 # "mamba_ssm_cache_dtype": "float32",
             },
             # Keep max_batch_size as in the PyTorch test to avoid OOM
             "max_batch_size": 128,
             # Model context length is 8K
             "enable_chunked_prefill": True,
             "max_seq_len": 8192,
             # Set explicitly to match default build_config behavior
             "max_num_tokens": 8192,
             "skip_loading_weights": False,
             "compile_backend": "torch-cudagraph",
-            "kv_cache_config": {
-                "free_gpu_memory_fraction": 0.7
-            },
             "cuda_graph_batch_sizes": [1, 2, 4, 8, 16, 32, 64, 128],
🤖 Fix all issues with AI agents
In @docs/source/features/auto_deploy/advanced/benchmarking_with_trtllm_bench.md:
- Line 86: The docs show a mismatch: the table documents
kv_cache_config.free_gpu_memory_fraction default as 0.9 but the example uses
0.8; update the example value to 0.9 to match the documented default (or
alternatively keep 0.8 and add an inline comment in the example explaining why
0.8 was chosen) so the example and the documented default are consistent; edit
the example block that sets kv_cache_config.free_gpu_memory_fraction to reflect
this change and ensure the table and example no longer disagree.
- Around line 58-63: Remove the incorrect duplicated header "# transform
options" that precedes the kv_cache_config block; ensure the block begins with
the correct KV cache comment (e.g., the line "# KV cache configuration") and
leave the kv_cache_config: and free_gpu_memory_fraction: 0.8 entries unchanged
so the separate "# transform options" comment remains only above the actual
transforms section later.

In @docs/source/torch/auto_deploy/advanced/serving_with_trtllm_serve.md:
- Around line 57-63: Remove the duplicated and misleading comment header by
deleting or replacing the top "# transform options" line that precedes the
kv_cache_config block; ensure the kv_cache_config stanza remains and, if a
header is desired, use a correct comment like "# KV cache configuration" so only
the accurate header (for kv_cache_config) appears and the original "# transform
options" remains only once before the actual transforms section (refer to the
kv_cache_config block and the later transform options header).

In @examples/models/core/nemotron/README_nemotron_nano_v3.md:
- Around line 42-47: The README guidance is inconsistent: the YAML example
leaves mamba_ssm_cache_dtype commented while the text recommends float32; either
make the example match the recommendation by uncommenting mamba_ssm_cache_dtype:
float32 in the YAML snippet (so users see the recommended default), or change
the textual guidance that references mamba-cache-dtype to state explicitly that
float32 is optional and explain the accuracy vs. speed tradeoff and point to the
commented example; update references to the setting name mamba_ssm_cache_dtype
and ensure the nano v3 doc aligns with nano-v2-vl behavior.

In @tensorrt_llm/_torch/auto_deploy/shim/demollm.py:
- Around line 81-82: The calculation for num_extra_pages over-allocates when
extra_tokens divides tokens_per_block; replace the current expression that adds
a boolean (extra_tokens // tokens_per_block) + (extra_tokens > 0) with a proper
ceiling division and ensure non-positive extra_tokens yield zero pages: compute
num_extra_pages using ceiling division of extra_tokens by tokens_per_block
(e.g., (extra_tokens + tokens_per_block - 1) // tokens_per_block or
-(-extra_tokens // tokens_per_block)) and clamp to 0 when extra_tokens <= 0,
updating the assignment that currently sets num_extra_pages.

In @tensorrt_llm/_torch/auto_deploy/shim/interface.py:
- Around line 101-166: The byte-level abstraction relies on Mapping().tp_size ==
1 but this is not validated; update _create_kv_cache_manager to either (A)
validate and raise a clear error when Mapping().tp_size != 1 (e.g., assert or
raise ValueError referencing Mapping.tp_size and total_bytes_per_token), or (B)
compute num_kv_heads as total_bytes_per_token // mapping.tp_size (with proper
ceil/overflow handling) before assigning into kv_cache_kwargs; target the
_create_kv_cache_manager function, the kv_cache_kwargs["num_kv_heads"]
assignment, and the Mapping() instance to implement the chosen fix so the
implicit division in resource_manager.py no longer produces incorrect buffer
sizes.

In @tests/unittest/_torch/auto_deploy/unit/singlegpu/shim/test_engine.py:
- Around line 45-46: The pytest parametrization for test_engine contains a
duplicated value ([0, 2, 0]) so update the pytest.mark.parametrize call for
test_engine to remove the duplicate 0 (e.g., change to [0, 2]) so
tokens_per_block only gets unique cases; locate the pytest.mark.parametrize
annotation above the test_engine function and modify the list accordingly.
🧹 Nitpick comments (12)
tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_build_small_single.py (1)

48-50: Test coverage gap for resize_kv_cache with new configuration.

The resize_kv_cache transform is now commented out, leaving no test coverage for triggering the resize behavior through the new kv_cache_config.free_gpu_memory_fraction path. Consider adding a test case that configures kv_cache_config appropriately to validate the resize functionality still works as expected.

Would you like me to help draft a test case that uses the new kv_cache_config.free_gpu_memory_fraction approach? Alternatively, should this TODO be tracked as a follow-up issue?

tensorrt_llm/_torch/auto_deploy/models/hf.py (1)

263-272: Add return type hint and use explicit exception instead of assert.

Two issues with this method:

  1. Missing return type hint: The base class ModelFactory.get_cache_config_updates specifies -> Dict[str, Any]. This override should include the same type hint for consistency and clarity.

  2. Using assert for input validation: assert statements are stripped when Python runs with the -O (optimize) flag, which would silently allow unsupported dtype values in production. Use a proper exception for validation that must always execute.

♻️ Suggested improvement
-    def get_cache_config_updates(self):
-        """Return kv cache dtype updates."""
+    def get_cache_config_updates(self) -> Dict[str, Any]:
+        """Return updates for the KVCacheConfig for the model.
+
+        Returns:
+            A dictionary with "dtype" key for kv cache dtype configuration.
+        """
         if not self._quant_config_reader:
             return {}

         kv_cache_dtype = self._quant_config_reader.get_config().get("kv_cache_dtype", "auto")
-        assert kv_cache_dtype in ("fp8", "auto"), (
-            f"Unsupported dtype: {kv_cache_dtype}. Only fp8 and auto are supported."
-        )
+        if kv_cache_dtype not in ("fp8", "auto"):
+            raise ValueError(
+                f"Unsupported kv_cache_dtype: {kv_cache_dtype}. Only 'fp8' and 'auto' are supported."
+            )
         return {"dtype": kv_cache_dtype}
tensorrt_llm/_torch/auto_deploy/models/quant_config_reader.py (1)

1-7: Missing NVIDIA copyright header.

As per coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header with the year of latest meaningful modification. Please add the appropriate copyright header at the top of the file.

📄 Suggested addition
+# SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 """
 Quantization Config Reader Registry.
tensorrt_llm/llmapi/llm_args.py (1)

1681-1690: Consider adding type constraints consistent with mamba_ssm_cache_dtype.

The new causal_conv_cache_dtype and delta_net_cache_dtype fields use str type, while the existing mamba_ssm_cache_dtype field (lines 1674-1679) uses Literal["auto", "float16", "bfloat16", "float32"] with explicit validation. If these new cache dtype fields support the same set of values, consider using the same Literal type for consistency and input validation.

♻️ Suggested improvement
-    # This is a pure python field, not a pybind field. It is only for the AutoDeploy backend.
-    causal_conv_cache_dtype: str = Field(
-        default="auto",
-        description="The data type to use for the causal conv cache.")
-
-    # This is a pure python field, not a pybind field. It is only for the AutoDeploy backend.
-    delta_net_cache_dtype: str = Field(
-        default="auto",
-        description="The data type to use for the delta net cache.")
+    # This is a pure python field, not a pybind field. It is only for the AutoDeploy backend.
+    causal_conv_cache_dtype: Literal[
+        "auto", "float16", "bfloat16", "float32"] = Field(
+            default="auto",
+            description="The data type to use for the causal conv cache.")
+
+    # This is a pure python field, not a pybind field. It is only for the AutoDeploy backend.
+    delta_net_cache_dtype: Literal[
+        "auto", "float16", "bfloat16", "float32"] = Field(
+            default="auto",
+            description="The data type to use for the delta net cache.")
tensorrt_llm/_torch/auto_deploy/shim/demollm.py (1)

80-80: Consider adding strict=True to zip() for safety.

Adding strict=True ensures total_lens and page_assignments have matching lengths, failing fast if there's a mismatch rather than silently truncating.

-        for t_l, pages in zip(total_lens, page_assignments):
+        for t_l, pages in zip(total_lens, page_assignments, strict=True):
tests/unittest/_torch/auto_deploy/unit/singlegpu/custom_ops/test_flashinfer_attention_op.py (1)

1-6: Missing copyright header.

This test file is missing the NVIDIA copyright header that should be present in all TensorRT-LLM source files. As per coding guidelines, all source files should contain an NVIDIA copyright header with the year of the latest meaningful modification.

Suggested header to add at the top of the file
+# SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 import flashinfer
 import pytest
tensorrt_llm/_torch/auto_deploy/custom_ops/triton_attention.py (1)

1-4: Missing copyright header.

This source file is missing the NVIDIA copyright header. As per coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header with the year of the latest meaningful modification.

Suggested header to add at the top of the file
+# SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 """Custom ops for MHA/XQA attention."""
tensorrt_llm/_torch/auto_deploy/transform/library/hidden_states.py (1)

230-236: Consider prefixing unused parameter with underscore.

The cache_config parameter is intentionally unused since the hidden states dtype is derived from the source node's metadata. This is correct behavior, but the static analysis hint (ARG003) could be silenced by prefixing the parameter with an underscore to indicate it's intentionally unused while maintaining interface consistency.

Optional fix
     @classmethod
     def get_cache_initializers(
-        cls, source_attn_node: Node, cache_config: KvCacheConfig
+        cls, source_attn_node: Node, _cache_config: KvCacheConfig
     ) -> ResourceHandlerDict:
tensorrt_llm/_torch/auto_deploy/custom_ops/fla/fla_backend_delta.py (1)

1-6: Missing copyright header.

This source file has a docstring but is missing the required NVIDIA copyright header. As per coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header.

Suggested header to add at the top of the file
+# SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 """Cached attention op for delta rule using the fla kernel library.
tensorrt_llm/_torch/auto_deploy/custom_ops/mla.py (1)

23-36: Hardcoded bfloat16 dtype may cause precision issues for float16 models.

The _precompute_inv_freq function hardcodes torch.bfloat16 for the cos/sin stacked tensor:

cos_sin_stacked = torch.stack([emb.cos().to(torch.bfloat16), emb.sin().to(torch.bfloat16)])

For models using float16, this could introduce unnecessary precision mismatches or type casting overhead. Consider accepting a dtype parameter or inferring from the input tensors:

💡 Suggested improvement
 def _precompute_inv_freq(
-    max_seq_len: int, head_dim: int, rope_theta: float, device: torch.device
+    max_seq_len: int, head_dim: int, rope_theta: float, device: torch.device, dtype: torch.dtype = torch.bfloat16
 ) -> torch.Tensor:
     inv_freq = 1.0 / (
         rope_theta ** (torch.arange(0, head_dim, 2, device=device).float() / head_dim)
     )
     t = torch.arange(max_seq_len, device=inv_freq.device, dtype=inv_freq.dtype)

     freqs = torch.outer(t, inv_freq.to(t.device))
     # Different from paper, but it uses a different permutation in order to obtain the same calculation
     emb = torch.cat((freqs, freqs), dim=-1)
-    cos_sin_stacked = torch.stack([emb.cos().to(torch.bfloat16), emb.sin().to(torch.bfloat16)])
+    cos_sin_stacked = torch.stack([emb.cos().to(dtype), emb.sin().to(dtype)])
     return cos_sin_stacked
tensorrt_llm/_torch/auto_deploy/shim/interface.py (1)

89-95: Consider using a more specific exception type.

The method correctly validates against model_fields, but per the static analysis hint (TRY003), consider defining a custom exception or using KeyError:

💡 Optional improvement
     def update_kv_cache_config(self, **kwargs) -> None:
         """Update the KVCacheConfig with the given kwargs."""
         for k, v in kwargs.items():
             if k in type(self.kv_cache_config).model_fields:
                 setattr(self.kv_cache_config, k, v)
             else:
-                raise ValueError(f"Invalid KVCacheConfig field: {k}")
+                raise KeyError(f"Invalid KVCacheConfig field: {k!r}")

This is a minor suggestion; the current implementation is functionally correct.

tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py (1)

273-274: TODO acknowledged - dummy request handling for MambaHybridCacheManager.

The TODO notes that _generate_dummy_request may need updates for MambaHybridCacheManager and that max_state_slots shouldn't be used anymore. Consider creating a tracking issue if this needs to be addressed before the feature is fully stable.

Do you want me to open an issue to track this TODO for proper MambaHybridCacheManager support in dummy request generation?

Comment thread docs/source/torch/auto_deploy/advanced/serving_with_trtllm_serve.md
Comment thread examples/models/core/nemotron/README_nemotron_nano_v3.md
Comment thread tensorrt_llm/_torch/auto_deploy/shim/demollm.py
Comment thread tensorrt_llm/_torch/auto_deploy/shim/interface.py Outdated
@lucaslie
lucaslie force-pushed the ll/cm_integration branch 2 times, most recently from eb50af0 to 0d9f9c9 Compare January 14, 2026 21:18
@lucaslie
lucaslie marked this pull request as ready for review January 14, 2026 21:39
@lucaslie
lucaslie requested a review from a team as a code owner January 14, 2026 21:39
@lucaslie
lucaslie requested a review from danielafrimi January 14, 2026 21:39
@lucaslie

Copy link
Copy Markdown
Contributor Author

/bot run --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #32059 [ run ] triggered by Bot. Commit: f45b082

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #32059 [ run ] completed with state SUCCESS. Commit: f45b082
/LLM/main/L0_MergeRequest_PR pipeline #24847 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@lucaslie

Copy link
Copy Markdown
Contributor Author

/bot run --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #32158 [ run ] triggered by Bot. Commit: f9eeead

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #32158 [ run ] completed with state SUCCESS. Commit: f9eeead
/LLM/main/L0_MergeRequest_PR pipeline #24933 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Comment thread tensorrt_llm/_torch/auto_deploy/transform/library/kvcache.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/llm_args.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/llm_args.py
Comment thread tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py Outdated
Comment thread tensorrt_llm/_torch/pyexecutor/resource_manager.py
Comment thread tensorrt_llm/llmapi/llm_args.py Outdated

@nvchenghaoz nvchenghaoz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review all files except interface.py and the kvcache.py. will get back to this tomorrow. Consider split this into small PRs next time for such big changes...

Comment thread examples/auto_deploy/nano_v3.yaml Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py
Comment thread tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py
Comment thread tensorrt_llm/_torch/auto_deploy/custom_ops/flashinfer_attention.py
Comment thread tensorrt_llm/_torch/auto_deploy/custom_ops/mla.py
Comment thread tensorrt_llm/_torch/auto_deploy/models/hf.py
Comment thread tensorrt_llm/_torch/auto_deploy/shim/demollm.py
Comment thread tensorrt_llm/_torch/auto_deploy/shim/interface.py
Comment thread tensorrt_llm/_torch/auto_deploy/shim/interface.py
Comment thread tensorrt_llm/_torch/auto_deploy/shim/interface.py
@lucaslie

Copy link
Copy Markdown
Contributor Author

/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33235 [ run ] triggered by Bot. Commit: 20e609a

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33235 [ run ] completed with state ABORTED. Commit: 20e609a
LLM/main/L0_MergeRequest_PR #25676 (Blue Ocean) completed with status: ABORTED

@ZhanruiSunCh

Copy link
Copy Markdown
Collaborator

/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33301 [ run ] triggered by Bot. Commit: 20e609a

Comment thread tensorrt_llm/_torch/auto_deploy/config/default.yaml Outdated
@suyoggupta

Copy link
Copy Markdown
Collaborator

The mem tracker is neat!
could we run a perf test for nano-v3 to make sure there are no regressions?

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33301 [ run ] completed with state SUCCESS. Commit: 20e609a
/LLM/main/L0_MergeRequest_PR pipeline #25707 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@lucaslie
lucaslie force-pushed the ll/cm_integration branch 2 times, most recently from 147dc88 to 6fe5b23 Compare January 23, 2026 23:51
@lucaslie

Copy link
Copy Markdown
Contributor Author

/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33416 [ run ] triggered by Bot. Commit: 6fe5b23

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33416 [ run ] completed with state SUCCESS. Commit: 6fe5b23
/LLM/main/L0_MergeRequest_PR pipeline #25793 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
@lucaslie

Copy link
Copy Markdown
Contributor Author

/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" --disable-fail-fast

@lucaslie
lucaslie removed request for a team January 26, 2026 23:54
Comment thread tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
@lucaslie
lucaslie requested review from Wanli-Jiang and removed request for hchings January 26, 2026 23:55
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33638 [ run ] triggered by Bot. Commit: f6ec4d8

@nv-guomingz nv-guomingz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on doc changes.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #33638 [ run ] completed with state SUCCESS. Commit: f6ec4d8
/LLM/main/L0_MergeRequest_PR pipeline #25951 completed with status: 'SUCCESS'

@lucaslie

Copy link
Copy Markdown
Contributor Author
image Performance overview before and after. No visible regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: AutoDeploy: native KVCacheManager integration with abstract cache interface

8 participants