-
Notifications
You must be signed in to change notification settings - Fork 2k
[TRTLLM-7078][chore] optimal kvcache transfer for VWSA #7952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TRTLLM-7078][chore] optimal kvcache transfer for VWSA #7952
Conversation
|
/bot run |
|
PR_Github #19774 [ run ] triggered by Bot |
📝 WalkthroughWalkthroughIntroduces per-window KV-cache handling across APIs and implementations: new BlockRangeForWindow, BlockRange now holds per-window data, request and transceiver paths carry per-window block hashes, cache formatting and MLA formatting iterate by window, buffer sizing accounts for tokensPerBlock and an env flag, bindings and tests updated accordingly, and new integration tests added. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Model as Model/Executor
participant Formatter as CacheFormatter
participant Range as BlockRange (multi-window)
participant Tx as DataTransceiver::Sender
participant Rx as DataTransceiver::Receiver
participant Req as LlmRequest
Model->>Formatter: getBlockRangeForSending(requestId)
Formatter->>Range: compute per-window blockIds/pools
Range-->>Formatter: windowSizes + BlockRangeForWindow
Formatter->>Tx: sendRequestInfo(RequestId, blockHashesPerWindow)
Tx->>Tx: Serialize map<windowSize, hashes>
Tx-->>Rx: Transmit RequestInfo
Rx->>Req: setRequestedBlockHashesPerWindow(map)
Note over Rx,Req: Per-window hashes stored on request
Model->>Formatter: getBlockRangeForReceiving(requestId)
Formatter->>Range: build per-window ranges (env-aware)
Range-->>Formatter: BlockRangeForWindow per window
loop for each windowSize
Formatter->>Rx: receive blocks for window
Rx-->>Formatter: blocks for window
Formatter->>Formatter: unformat into per-window buffers
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
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 (5)
cpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cpp (2)
76-83: Fix typo: py::classh -> py::class_. This won’t compile as-is.Apply this diff:
- py::classh<tb::BaseCacheTransceiver, PyCacheTransceiver>(m, "BaseCacheTransceiver") + py::class_<tb::BaseCacheTransceiver, PyCacheTransceiver>(m, "BaseCacheTransceiver")
88-96: Fix all occurrences ofpy::classh→py::class_in pybind registrationsReplace every
py::classh<withpy::class_<(typo). Matches found:
- cpp/tensorrt_llm/pybind/runtime/bindings.cpp:202
- cpp/tensorrt_llm/pybind/runtime/bindings.cpp:224
- cpp/tensorrt_llm/pybind/runtime/bindings.cpp:229
- cpp/tensorrt_llm/pybind/bindings.cpp:78
- cpp/tensorrt_llm/pybind/bindings.cpp:107
- cpp/tensorrt_llm/pybind/bindings.cpp:398
- cpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cpp:76
- cpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cpp:88
- cpp/tensorrt_llm/pybind/batch_manager/kvCacheManager.cpp:336
- cpp/tensorrt_llm/pybind/batch_manager/kvCacheManager.cpp:477
- cpp/tensorrt_llm/pybind/batch_manager/kvCacheManager.cpp:497
- cpp/tensorrt_llm/pybind/batch_manager/kvCacheManager.cpp:517
- cpp/tensorrt_llm/pybind/batch_manager/kvCacheManager.cpp:524
- cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp:99
- cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp:262
- cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp:393
- cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp:401
Example (apply similarly everywhere):
- py::classh<tb::CacheTransceiver, tb::BaseCacheTransceiver>(m, "CacheTransceiver") + py::class_<tb::CacheTransceiver, tb::BaseCacheTransceiver>(m, "CacheTransceiver")cpp/tensorrt_llm/batch_manager/cacheTransBuffer.cpp (1)
247-271: Same clamping bug in preAllocBufferSize()Mirror the fix for the pre-allocation path.
- auto validTokenNum = (static_cast<size_t>(windowSize) < maxNumTokens.value() - ? static_cast<size_t>(windowSize) + tokensPerBlock - : maxNumTokens.value()); + auto validTokenNum = std::min( + maxNumTokens.value(), + static_cast<size_t>(windowSize) + static_cast<size_t>(tokensPerBlock)); if (common::getEnvKVCacheTransferAllBlocksForWindow()) { validTokenNum = maxNumTokens.value(); }cpp/tensorrt_llm/batch_manager/cacheFormatter.cpp (1)
436-438: Buffer index mismatch in chunked send pathUsing processIdx instead of bufferIdx corrupts the slice logic when TP×PP > 1. Use bufferIdx consistently.
- size_t remainSendSize = outputSplitCaches[processIdx]->getSize(); - size_t needSendSize = outputSplitCaches[processIdx]->getSize(); + size_t remainSendSize = outputSplitCaches[bufferIdx]->getSize(); + size_t needSendSize = outputSplitCaches[bufferIdx]->getSize();cpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cpp (1)
878-902: Bug: CP over-allocation check uses global blockIdx instead of per-window index.
isBlockOverallocated(blockIdx, numTotalBlocks)compares a global index against a per-window count. UseblockIdInWindowfor correctness within each window.Apply this diff:
- if (isBlockOverallocated(blockIdx, numTotalBlocks)) + if (isBlockOverallocated(blockIdInWindow, numTotalBlocks)) { TLLM_LOG_INFO( "[generationVerifyKVCache] Skipping over-allocated block for request id %d (rank %d, blockIdx " "%d, numTotalBlocks %d)", - llmRequest->mRequestId, mRank, blockIdx, numTotalBlocks); + llmRequest->mRequestId, mRank, blockIdInWindow, numTotalBlocks); break; }
🧹 Nitpick comments (11)
cpp/tensorrt_llm/common/envUtils.h (1)
119-120: Add Doxygen comment for the new env getter.Document the env var name and semantics for consistency with our header guidelines.
Apply this diff:
- bool getEnvKVCacheTransferAllBlocksForWindow(); + //! Returns true when environment TRTLLM_KVCACHE_TRANSFER_ALL_BLOCKS_FOR_WINDOW is set to "1". + bool getEnvKVCacheTransferAllBlocksForWindow();cpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cpp (1)
442-443: Add a unit test for TRTLLM_KVCACHE_TRANSFER_ALL_BLOCKS_FOR_WINDOW.Exercise the env‑flag path in preAllocBufferSize to prevent regressions.
Apply this diff to append a new test:
+TEST_F(CacheTransBufferTest, TestPreAlloc_AllBlocksForWindowEnv) +{ + pid_t pid = fork(); + ASSERT_NE(pid, -1) << "Fork failed"; + if (pid == 0) + { + // Child + SizeType32 maxBlocksPerSeq = 10; + SizeType32 tokensPerBlock = 8; + const size_t maxNumTokens = static_cast<size_t>(maxBlocksPerSeq) * tokensPerBlock; + SetUpCacheTransBuffer(4, 2, 64, tokensPerBlock, CacheType::kSELFKONLY, maxNumTokens, maxBlocksPerSeq); + const size_t cacheSizeBytesPerToken = kvCacheSizePerToken(4, 2, 64, CacheType::kSELFKONLY); + std::map<SizeType32, SizeType32> perWindow{ + {maxBlocksPerSeq * tokensPerBlock, cacheSizeBytesPerToken}}; + tensorrt_llm::executor::CacheTransceiverConfig cfg{ + tensorrt_llm::executor::CacheTransceiverConfig::BackendType::UCX, maxNumTokens}; + + // Baseline (flag not set): window + tokensPerBlock + unsetenv("TRTLLM_KVCACHE_TRANSFER_ALL_BLOCKS_FOR_WINDOW"); + size_t sz1 = CacheTransBufferManager::preAllocBufferSize(perWindow, tokensPerBlock, cfg); + + // With flag set: uses maxNumTokens for the window + setenv("TRTLLM_KVCACHE_TRANSFER_ALL_BLOCKS_FOR_WINDOW", "1", 1); + size_t sz2 = CacheTransBufferManager::preAllocBufferSize(perWindow, tokensPerBlock, cfg); + EXPECT_GT(sz2, sz1); + exit(testing::Test::HasFailure() ? 1 : 0); + } + int status; + ASSERT_NE(-1, waitpid(pid, &status, 0)) << "waitpid failed"; + ASSERT_TRUE(WIFEXITED(status)); + ASSERT_EQ(0, WEXITSTATUS(status)); +}cpp/tensorrt_llm/batch_manager/cacheTransBuffer.h (1)
63-65: Add brief Doxygen to the updated API; consider clamping logic in the implementation.
- Document tokensPerBlock purpose.
- In the .cpp, consider clamping (windowSize + tokensPerBlock) to maxTokens to avoid oversizing when windowSize is close to maxTokens.
Apply this diff to document the API:
- static size_t preAllocBufferSize(std::map<SizeType32, SizeType32> const& cacheSizeBytesPerTokenPerWindow, - SizeType32 tokensPerBlock, - std::optional<executor::CacheTransceiverConfig> const& cacheTransceiverConfig = std::nullopt); + //! Pre-compute total bytes to pre-allocate for KV cache transfer buffers. + //! cacheSizeBytesPerTokenPerWindow: map of window_size -> bytes-per-token across local attention layers. + //! tokensPerBlock: tokens per cache block (used for block-aligned sizing). + //! cacheTransceiverConfig: when absent or without backend, returns 0. + static size_t preAllocBufferSize(std::map<SizeType32, SizeType32> const& cacheSizeBytesPerTokenPerWindow, + SizeType32 tokensPerBlock, + std::optional<executor::CacheTransceiverConfig> const& cacheTransceiverConfig = std::nullopt);For the .cpp implementation, consider:
- auto validTokenNum = (static_cast<size_t>(windowSize) < maxNumTokens.value() - ? static_cast<size_t>(windowSize) + tokensPerBlock - : maxNumTokens.value()); + auto validTokenNum = static_cast<size_t>(windowSize) + static_cast<size_t>(tokensPerBlock); + validTokenNum = std::min(validTokenNum, maxNumTokens.value());cpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cpp (2)
132-132: Remove stray merge markerLeftover "diff end" marker should be removed.
- // diff end +
141-145: Deterministic window orderinggetWindowSizes() draws keys from an unordered_map; ordering is not guaranteed and can desync zcopy send/recv iteration order. Sort windowSizes before iterating.
- auto const& windowSizes = blockRange.getWindowSizes(); + auto windowSizes = blockRange.getWindowSizes(); + std::sort(windowSizes.begin(), windowSizes.end());Apply similarly in unformat().
Also applies to: 350-352
cpp/include/tensorrt_llm/batch_manager/llmRequest.h (1)
2048-2049: Add Doxygen for new per-window APIsHeaders require Doxygen docs for new interfaces. Please document setRequestedBlockHashes and getRequestedBlockHashesPerWindow.
cpp/tensorrt_llm/batch_manager/cacheFormatter.cpp (1)
271-277: Deterministic window orderingSort windowSizes; current getWindowSizes() draws from an unordered_map.
- auto const& windowSizes = blockRange.getWindowSizes(); + auto windowSizes = blockRange.getWindowSizes(); + std::sort(windowSizes.begin(), windowSizes.end()); @@ - auto windowSizes = blockRange.getWindowSizes(); + auto windowSizes = blockRange.getWindowSizes(); + std::sort(windowSizes.begin(), windowSizes.end());Also applies to: 547-549
cpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h (2)
122-130: Make getWindowSizes deterministicReturn a sorted list of window sizes to stabilize iteration order across sender/receiver.
- std::vector<SizeType32> getWindowSizes() const - { - std::vector<SizeType32> windowSizes; - for (auto const& [windowSize, _] : mPoolsPerWindow) - { - windowSizes.push_back(windowSize); - } - return windowSizes; - } + std::vector<SizeType32> getWindowSizes() const + { + std::vector<SizeType32> windowSizes; + windowSizes.reserve(mPoolsPerWindow.size()); + for (auto const& [windowSize, _] : mPoolsPerWindow) + { + windowSizes.push_back(windowSize); + } + std::sort(windowSizes.begin(), windowSizes.end()); + return windowSizes; + }Add include outside this hunk:
#include <algorithm>
27-56: Header API additions: please add DoxygenNew BlockRangeForWindow class and modified BlockRange API need Doxygen per project guidelines.
Also applies to: 58-66, 80-96, 97-111, 113-121, 132-136, 137-166, 187-193, 230-233, 250-253, 255-258
cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp (2)
218-224: Serialize unordered_map deterministically (optional).Current serialization iterates an unordered_map; correctness is fine since deserialization restores a map. For reproducible byte streams/logs, consider ordering by windowSize when serializing.
Apply this diff:
- su::serialize(requestInfo.mBlockHashesPerWindow.size(), os); - for (auto const& [windowSize, blockHashes] : requestInfo.mBlockHashesPerWindow) + su::serialize(requestInfo.mBlockHashesPerWindow.size(), os); + // Optional: stable order for reproducible serialization + std::vector<SizeType32> keys; + keys.reserve(requestInfo.mBlockHashesPerWindow.size()); + for (auto const& kv : requestInfo.mBlockHashesPerWindow) { keys.push_back(kv.first); } + std::sort(keys.begin(), keys.end()); + for (auto const& windowSize : keys) { - su::serialize(windowSize, os); - su::serialize(blockHashes, os); + su::serialize(windowSize, os); + su::serialize(requestInfo.mBlockHashesPerWindow.at(windowSize), os); }
433-446: Passing per-window hashes via LlmRequest mutation — acceptable, but consider removing the TODO.The TODO suggests passing hashes directly; that would reduce hidden coupling. For future refactor, Thread the hashes through TransferSession/formatter API instead of mutating LlmRequest.
I can draft an API sketch to pass block hashes into BaseCacheFormatter::format without touching LlmRequest if helpful.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (18)
cpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h(4 hunks)cpp/include/tensorrt_llm/batch_manager/llmRequest.h(2 hunks)cpp/tensorrt_llm/batch_manager/cacheFormatter.cpp(6 hunks)cpp/tensorrt_llm/batch_manager/cacheTransBuffer.cpp(3 hunks)cpp/tensorrt_llm/batch_manager/cacheTransBuffer.h(1 hunks)cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp(9 hunks)cpp/tensorrt_llm/batch_manager/dataTransceiver.h(4 hunks)cpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cpp(2 hunks)cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp(1 hunks)cpp/tensorrt_llm/common/envUtils.cpp(1 hunks)cpp/tensorrt_llm/common/envUtils.h(1 hunks)cpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cpp(1 hunks)cpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cpp(1 hunks)cpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cpp(2 hunks)cpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cpp(2 hunks)cpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cpp(14 hunks)tests/integration/defs/accuracy/test_disaggregated_serving.py(3 hunks)tests/integration/test_lists/test-db/l0_dgx_h200.yml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh}: Namespace closing braces must include a trailing comment with the namespace name (e.g., '} // namespace foo').
Prefer const or constexpr variables over #define for constants.
Declare variables that are not modified after initialization as const.
Avoid magic literals in code; except for 0, nullptr, true, false. Use named constants for comparisons and logic.
Use Allman brace style for formatting.
Place the semicolon of an empty for/while loop on a new line.
Bodies of switch/while/do-while/for must be compound statements (brace-delimited), and if/else must always be followed by brace-delimited statements.
Type names (e.g., classes) must be CamelCase starting with an uppercase letter (e.g., FooBar).
Local variables, methods, and namespaces use lowerCamelCase (e.g., localFooBar).
Non-magic-number global variables that are non-static and not in an anonymous namespace must be lowerCamelCase prefixed with 'g' (e.g., gDontUseGlobalFoos).
Non-magic-number globals that are static or in an anonymous namespace use lowerCamelCase prefixed with 's' (e.g., sMutableStaticGlobal).
Locally visible static variables use lowerCamelCase with 's' prefix (e.g., static std::once_flag sFlag).
Private/protected member variables use 'm' prefix with CamelCase (e.g., mNbFooValues). Public members may omit, but 'm' is encouraged for clarity.
Constants (enums, global constants, static constants, and function-scope magic/literal constants) use uppercase SNAKE_CASE with 'k' prefix (e.g., kDIGIT_NUM).
Function-scope constants that are not magic numbers or literals are named like non-constant variables (e.g., bool const pass = a && b).
If macros are necessary, name them in UPPER_SNAKE_CASE (e.g., FOO_VERSION) and prefer constants over #define.
Use LLVM clang-format; wrap lines at a maximum of 120 columns; use '// clang-format off/on' sparingly with justification.
Use smart pointers for heap allocations; prefer unique_ptr for sole ownership, shared_ptr for shared...
Files:
cpp/tensorrt_llm/common/envUtils.cppcpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
**/*.{cpp,cxx,cc,cu,h,hpp,hh,hxx,cuh}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
C++ filenames should be lowerCamelCase (first letter lowercase) and must be case-insensitive unique within a compilation target.
Files:
cpp/tensorrt_llm/common/envUtils.cppcpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Use only spaces, no tabs; indent with 4 spaces.
Files:
cpp/tensorrt_llm/common/envUtils.cppcpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.htests/integration/defs/accuracy/test_disaggregated_serving.pycpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
**/*.{h,hpp,hh,hxx,cpp,cxx,cc}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc}: Prefer anonymous namespaces over 'static' for internal linkage of functions.
All templates (class/function/member/static) must be instantiated at least once; non-POD classes should have private data members.
Files:
cpp/tensorrt_llm/common/envUtils.cppcpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).
Files:
cpp/tensorrt_llm/common/envUtils.cppcpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.htests/integration/defs/accuracy/test_disaggregated_serving.pycpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
**/*.{h,hpp,hh,hxx}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Document new class interfaces and function prototypes with Doxygen; use //! for single-line and //!< for members.
Files:
cpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
**/*.{h,hpp,hh,hxx,cuh}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Use include guards named 'TRTLLM_<FILE_NAME_IN_CAPS_WITH_UNDERSCORES>_H' (no leading or trailing underscore; directory names excluded).
Files:
cpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
**/*.py
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.
Files:
tests/integration/defs/accuracy/test_disaggregated_serving.py
🧠 Learnings (12)
📓 Common learnings
Learnt from: eopXD
PR: NVIDIA/TensorRT-LLM#6768
File: cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h:0-0
Timestamp: 2025-08-20T06:48:45.368Z
Learning: There is a planned refactoring to move cache block bookkeeping utilities from BlockManager/WindowBlockManager into the GenerationRequest class itself to improve code organization and make responsibilities clearer.
Learnt from: thorjohnsen
PR: NVIDIA/TensorRT-LLM#6910
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-14T21:04:50.248Z
Learning: In KV cache onboarding logic during prefill in cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, when calculating which blocks fall within the attention window, use getTokensPerBlock() to advance token indices rather than block->getUniqueTokens().size(), because the calculation needs to consider the post-prefill state where blocks will be filled to capacity, not their current token count.
Learnt from: eopXD
PR: NVIDIA/TensorRT-LLM#6767
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-15T06:46:54.897Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp addToken function, newly allocated blocks are unshared by design. The beam search path in addToken (when sequence.getNumTokens() > windowSize) is currently broken/non-functional with SWA, so the block allocation doesn't follow a shared-then-unshared pattern.
📚 Learning: 2025-08-14T21:04:50.248Z
Learnt from: thorjohnsen
PR: NVIDIA/TensorRT-LLM#6910
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-14T21:04:50.248Z
Learning: In KV cache onboarding logic during prefill in cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, when calculating which blocks fall within the attention window, use getTokensPerBlock() to advance token indices rather than block->getUniqueTokens().size(), because the calculation needs to consider the post-prefill state where blocks will be filled to capacity, not their current token count.
Applied to files:
cpp/tensorrt_llm/common/envUtils.cppcpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
📚 Learning: 2025-08-15T06:46:54.897Z
Learnt from: eopXD
PR: NVIDIA/TensorRT-LLM#6767
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-15T06:46:54.897Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp addToken function, newly allocated blocks are unshared by design. The beam search path in addToken (when sequence.getNumTokens() > windowSize) is currently broken/non-functional with SWA, so the block allocation doesn't follow a shared-then-unshared pattern.
Applied to files:
cpp/tensorrt_llm/common/envUtils.cppcpp/tensorrt_llm/common/envUtils.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
📚 Learning: 2025-08-20T06:56:02.889Z
Learnt from: eopXD
PR: NVIDIA/TensorRT-LLM#6768
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:577-579
Timestamp: 2025-08-20T06:56:02.889Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, maxSequenceLength is now enforced as a non-optional argument in the BlockManager constructor, so concerns about std::nullopt defaulting to 0 are not applicable. When windowSize > maxSequenceLength, a warning should be added instead of handling optional parameter cases.
Applied to files:
cpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
📚 Learning: 2025-08-21T09:41:49.347Z
Learnt from: eopXD
PR: NVIDIA/TensorRT-LLM#6768
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:2010-2045
Timestamp: 2025-08-21T09:41:49.347Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, updateSequenceCacheBlockOffsets is specifically for updating bookkeeping when blocks are added during the context phase, not for refreshing offsets after detach operations. During detach operations, GenerationRequest::removeFrontBlock handles the necessary cache block bookkeeping internally.
Applied to files:
cpp/tensorrt_llm/batch_manager/cacheTransBuffer.hcpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/cacheTransBuffer.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
📚 Learning: 2025-09-23T14:58:05.372Z
Learnt from: nv-lschneider
PR: NVIDIA/TensorRT-LLM#7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:42-49
Timestamp: 2025-09-23T14:58:05.372Z
Learning: In TensorRT-LLM NCCL device kernels (cpp/tensorrt_llm/kernels/nccl_device/), the token partitioning intentionally uses ceil-like distribution (same token_per_rank for all ranks) to ensure all ranks launch the same number of blocks. This is required for optimal NCCL device API barrier performance, even though it may launch extra blocks for non-existent tokens on later ranks. Runtime bounds checking in the kernel (blockID validation) handles the overshoot cases.
Applied to files:
cpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cppcpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cpp
📚 Learning: 2025-08-20T06:48:45.368Z
Learnt from: eopXD
PR: NVIDIA/TensorRT-LLM#6768
File: cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h:0-0
Timestamp: 2025-08-20T06:48:45.368Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, updateSequenceCacheBlockOffsets is only called when adding a sequence, not during detach operations. During detach, the cache block bookkeeping is handled by GenerationRequest::removeFrontBlock.
Applied to files:
cpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cppcpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cppcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
📚 Learning: 2025-08-20T06:48:45.368Z
Learnt from: eopXD
PR: NVIDIA/TensorRT-LLM#6768
File: cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h:0-0
Timestamp: 2025-08-20T06:48:45.368Z
Learning: There is a planned refactoring to move cache block bookkeeping utilities from BlockManager/WindowBlockManager into the GenerationRequest class itself to improve code organization and make responsibilities clearer.
Applied to files:
cpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cppcpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h
📚 Learning: 2025-09-23T15:01:00.070Z
Learnt from: nv-lschneider
PR: NVIDIA/TensorRT-LLM#7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:15-17
Timestamp: 2025-09-23T15:01:00.070Z
Learning: In TensorRT-LLM NCCL device kernels (cpp/tensorrt_llm/kernels/nccl_device/config.cu), std::ostringstream is used but <sstream> doesn't need to be explicitly included because it's provided transitively through other headers like tensorrt_llm/common/cudaUtils.h or config.h. Local compilation testing confirms this works without the explicit include.
Applied to files:
cpp/tensorrt_llm/batch_manager/cacheFormatter.cppcpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/dataTransceiver.cpp
📚 Learning: 2025-08-06T08:18:28.669Z
Learnt from: zhengd-nv
PR: NVIDIA/TensorRT-LLM#6633
File: cpp/tensorrt_llm/batch_manager/dataTransceiverImpl.cpp:145-155
Timestamp: 2025-08-06T08:18:28.669Z
Learning: In cpp/tensorrt_llm/batch_manager/dataTransceiverImpl.cpp, the existing `mMtxForMap` mutex in DataSenderImpl is sufficient to synchronize measurement file operations in the `release` method, as all file operations occur within the same critical section that protects the `mRequestToSession` map access.
Applied to files:
cpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/dataTransceiver.cpp
📚 Learning: 2025-09-23T15:01:00.070Z
Learnt from: nv-lschneider
PR: NVIDIA/TensorRT-LLM#7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:15-17
Timestamp: 2025-09-23T15:01:00.070Z
Learning: In TensorRT-LLM NCCL device kernels, the <sstream> header is not needed as an explicit include in config.cu because it's provided transitively through other headers. Local compilation testing confirms this works without the explicit include.
Applied to files:
cpp/tensorrt_llm/batch_manager/dataTransceiver.hcpp/tensorrt_llm/batch_manager/dataTransceiver.cpp
📚 Learning: 2025-09-02T13:42:44.885Z
Learnt from: pcastonguay
PR: NVIDIA/TensorRT-LLM#7455
File: tensorrt_llm/_torch/pyexecutor/py_executor.py:1852-1860
Timestamp: 2025-09-02T13:42:44.885Z
Learning: In MPI communication within TensorRT-LLM pipeline parallelism, different communication types (tokens, logits, termination sync) must use disjoint tag namespaces to avoid message routing collisions when using the same source/destination patterns.
Applied to files:
cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp
🧬 Code graph analysis (11)
cpp/tensorrt_llm/common/envUtils.h (1)
cpp/tensorrt_llm/common/envUtils.cpp (2)
getEnvKVCacheTransferAllBlocksForWindow(449-453)getEnvKVCacheTransferAllBlocksForWindow(449-449)
cpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cpp (1)
cpp/tensorrt_llm/batch_manager/cacheTransBuffer.cpp (2)
preAllocBufferSize(246-285)preAllocBufferSize(246-248)
cpp/tensorrt_llm/batch_manager/cacheFormatter.cpp (3)
cpp/tensorrt_llm/common/envUtils.cpp (4)
getEnvKVCacheTransferAllBlocksForWindow(449-453)getEnvKVCacheTransferAllBlocksForWindow(449-449)getEnvDisableSelectiveCacheTransfer(321-325)getEnvDisableSelectiveCacheTransfer(321-321)cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp (13)
llmRequest(282-282)llmRequest(390-397)llmRequest(390-390)llmRequest(597-597)llmRequest(603-603)llmRequest(654-717)llmRequest(654-654)llmRequest(719-735)llmRequest(719-719)llmRequest(763-777)llmRequest(763-763)it(534-545)it(534-534)cpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cpp (5)
llmRequest(322-361)llmRequest(322-322)llmRequest(813-845)llmRequest(813-813)llmRequest(847-854)
cpp/include/tensorrt_llm/batch_manager/llmRequest.h (1)
cpp/tensorrt_llm/batch_manager/dataTransceiver.h (1)
nodiscard(82-179)
cpp/tensorrt_llm/batch_manager/cacheTransBuffer.cpp (2)
cpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cpp (1)
maxNumTokens(293-307)cpp/tensorrt_llm/common/envUtils.cpp (2)
getEnvKVCacheTransferAllBlocksForWindow(449-453)getEnvKVCacheTransferAllBlocksForWindow(449-449)
cpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cpp (1)
cpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h (1)
BlockRangeForWindow(27-56)
cpp/tensorrt_llm/batch_manager/dataTransceiver.h (1)
cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp (16)
requestId(309-309)requestId(316-333)requestId(316-316)blockHashesPerWindow(433-459)blockHashesPerWindow(433-434)nodiscard(282-297)nodiscard(299-302)nodiscard(309-314)nodiscard(335-388)nodiscard(547-550)nodiscard(552-555)nodiscard(557-561)nodiscard(597-601)nodiscard(603-635)getBlockHashesPerWindow(258-261)getBlockHashesPerWindow(258-258)
tests/integration/defs/accuracy/test_disaggregated_serving.py (4)
tests/integration/defs/accuracy/test_llm_api_pytorch.py (1)
TestGPTOSS(3166-3379)tests/integration/defs/accuracy/accuracy_core.py (4)
LlmapiAccuracyTestHarness(793-804)GSM8K(293-308)evaluate(147-206)evaluate(712-722)tests/integration/defs/conftest.py (1)
llm_models_root(77-82)tensorrt_llm/evaluate/lm_eval.py (2)
GSM8K(440-488)evaluate(385-417)
cpp/tensorrt_llm/batch_manager/mlaCacheFormatter.cpp (2)
cpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cpp (8)
llmRequest(322-361)llmRequest(322-322)llmRequest(813-845)llmRequest(813-813)llmRequest(847-854)llmRequest(847-847)llmRequest(869-904)llmRequest(869-869)cpp/tensorrt_llm/batch_manager/cacheFormatter.cpp (2)
getBlockRangeForSending(44-90)getBlockRangeForSending(44-44)
cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp (1)
cpp/tensorrt_llm/common/envUtils.cpp (2)
getEnvDisableSelectiveCacheTransfer(321-325)getEnvDisableSelectiveCacheTransfer(321-321)
cpp/include/tensorrt_llm/batch_manager/kvCacheUtils.h (2)
cpp/include/tensorrt_llm/batch_manager/llmRequest.h (13)
tensorrt_llm(37-272)nodiscard(554-557)nodiscard(562-565)nodiscard(585-588)nodiscard(772-780)nodiscard(783-786)nodiscard(789-792)nodiscard(1028-1031)nodiscard(1193-1201)nodiscard(1239-1247)nodiscard(1262-1270)nodiscard(1284-1287)nodiscard(1333-1363)cpp/tensorrt_llm/batch_manager/dataTransceiver.h (2)
tensorrt_llm(37-258)kv_cache_manager(40-43)
🪛 Ruff (0.13.1)
tests/integration/defs/accuracy/test_disaggregated_serving.py
851-854: Mutable class attributes should be annotated with typing.ClassVar
(RUF012)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Check PR Checklist Resolution
- GitHub Check: Pre-commit Check
🔇 Additional comments (29)
tests/integration/defs/accuracy/test_disaggregated_serving.py (4)
801-803: Parametrizing block reuse — LGTMGood coverage toggle for per-window cache reuse.
812-812: Validate per-window attention configurationPlease confirm the max_attention_window vector matches Gemma-3-1B’s windowing layout. Mismatched lengths or ordering will produce incorrect window clipping and KV transfer.
Also applies to: 819-825, 823-825
848-850: New GPT‑OSS disaggregated test class — LGTMScope and gating look appropriate for heavy CI.
861-864: Bug: scores_filter must be a single key; MAX_OUTPUT_LEN=8192 risks CI timeouts/OOM
- lm_eval.evaluate expects a single metric key; passing "exact_match,flexible-extract" will raise a KeyError.
- MAX_OUTPUT_LEN=8192 is excessive for CI and can trigger timeouts or OS OOM; reduce it.
Location: tests/integration/defs/accuracy/test_disaggregated_serving.py lines 861-864
Apply this diff:
- mocker.patch.object(GSM8K, "MAX_OUTPUT_LEN", 8192) - mocker.patch.dict(GSM8K.EVALUATE_KWARGS, - {"scores_filter": "exact_match,flexible-extract"}) + mocker.patch.object(GSM8K, "MAX_OUTPUT_LEN", 2048) + mocker.patch.dict(GSM8K.EVALUATE_KWARGS, {"scores_filter": "exact_match"})If you need the "flexible-extract" metric, switch to that single key instead.
tests/integration/test_lists/test-db/l0_dgx_h200.yml (1)
32-33: Add GPT‑OSS disaggregated tests — LGTMEntries align with test gating for 8x H200 and new class.
Ensure the GPT‑OSS model assets are pre-staged at LLM_MODELS_ROOT/gpt_oss/gpt-oss-120b on CI to avoid spurious skips/failures.
cpp/tensorrt_llm/common/envUtils.cpp (1)
449-453: LGTM: cached env flag getter.Static caching matches the pattern used across env getters and is thread‑safe.
cpp/tensorrt_llm/pybind/batch_manager/cacheTransceiver.cpp (1)
100-101: LGTM: expose tokens_per_block in binding.Signature and kwarg ordering match the C++ API and nanobind counterpart.
cpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cpp (1)
104-105: LGTM: nanobind adds tokens_per_block kwarg.Binding matches the updated C++ API.
cpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cpp (2)
119-121: LGTM: test updated to 3‑arg preAllocBufferSize.Covers SELF K-only path.
164-165: LGTM: test updated to 3‑arg preAllocBufferSize (SELF path).cpp/tests/unit_tests/batch_manager/kvCacheUtilsTest.cpp (2)
55-55: LGTM: use BlockRangeForWindow with moved inputs.Correctly transfers ownership and avoids extra copies.
127-130: LGTM: prepare moved copies before constructing BlockRangeForWindow.Safe use; no use-after-move of pool or blockIds.
cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp (1)
309-309: Update to pass tokensPerBlock is correct — all call sites use the 3-arg form.Header/implementation expose the 3-arg signature and every call site (cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp and tests in cpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cpp) passes the cacheTransceiverConfig argument.
cpp/tensorrt_llm/batch_manager/dataTransceiver.h (1)
138-141: Per-window RequestInfo API changes look consistentConstructor, accessor, and member rename align with the per-window design.
Also applies to: 151-176
cpp/tensorrt_llm/batch_manager/cacheTransBuffer.cpp (1)
246-249: All preAllocBufferSize callers updated — no action requiredAll usages found include the new tokensPerBlock argument: cpp/tests/unit_tests/batch_manager/cacheTransBufferTest.cpp:119,163 and cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp:308.
cpp/include/tensorrt_llm/batch_manager/llmRequest.h (1)
1846-1854: API shift to per-window hashes looks good — all call-sites migrated
Search found only the getter definition in cpp/include/tensorrt_llm/batch_manager/llmRequest.h and a single usage in cpp/tensorrt_llm/batch_manager/cacheFormatter.cpp; no occurrences of getRequestedBlockHashes or mRequestedBlockHashes remain.cpp/tests/unit_tests/multi_gpu/cacheTransceiverTest.cpp (6)
331-338: Per-window iteration on sender path looks good.Using getWindowSizes()/getBlockRangeForWindow(windowSize) aligns tests with per-window semantics.
823-834: Context fill respects per-window pools.Passing windowSize into fillBlockData and selecting the correct BufferManager per window is correct.
906-913: Selecting BufferManager by window is correct.Defaulting windowSize==0 to the primary pool and otherwise using the specific window pool is appropriate.
957-971: Seeding expected values with windowSize is appropriate.Including windowSize in generateExpectedValue keeps patterns unique per window.
980-1051: Per-window verify path is consistent.Verification mirrors fillBlockData and uses the correct BufferManager per window. No issues.
1339-1345: Good: Added explicit windowed test instantiation.Covers windowed scenarios; types and params look consistent.
cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp (7)
188-195: RequestInfo now carries per-window block hashes — interface change LGTM.Constructor extension and member storage via unordered_map is reasonable.
199-201: Equality updated to include per-window hashes.Matches new semantics.
231-241: Deserialize per-window map — LGTM.Reads count then (windowSize, vector) pairs; returns the new RequestInfo as expected.
248-256: serializedSize accounts for per-window entries — LGTM.Accurate size accumulation for id, map entries, and transState.
258-261: Accessor for per-window hashes — LGTM.Const-ref return avoids copies.
478-485: Receiver path correctly extracts per-window hashes.Uses RequestInfo::getBlockHashesPerWindow; aligns with sender format.
665-672: Selective transfer gating via env — LGTM.Using common::getEnvDisableSelectiveCacheTransfer and falling back to empty hashes is correct. Ensure formatters treat empty map as “send all”.
Can you confirm that BaseCacheFormatter implementations interpret an empty requested-hashes map as “no filtering”?
|
PR_Github #19774 [ run ] completed with state |
af1be23 to
3c9a661
Compare
|
/bot run |
|
PR_Github #19790 [ run ] triggered by Bot |
|
PR_Github #19790 [ run ] completed with state |
8610839 to
b82a114
Compare
|
/bot run |
|
PR_Github #19912 [ run ] triggered by Bot |
|
PR_Github #19912 [ run ] completed with state |
|
/bot run |
|
PR_Github #19921 [ run ] triggered by Bot |
|
PR_Github #19921 [ run ] completed with state |
b82a114 to
d462d62
Compare
|
/bot run |
|
PR_Github #20025 [ run ] triggered by Bot |
|
PR_Github #20025 [ run ] completed with state |
d462d62 to
7e54c54
Compare
|
/bot run --add-multi-gpu-test |
|
PR_Github #22039 [ run ] triggered by Bot. Commit: |
|
PR_Github #22039 [ run ] completed with state |
7508243 to
c913b9d
Compare
|
/bot run --add-multi-gpu-test |
|
PR_Github #22049 [ run ] triggered by Bot. Commit: |
|
PR_Github #22049 [ run ] completed with state |
c913b9d to
34db4b1
Compare
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com> fix nanobind Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com> fix nanobind Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com> onewindow fix Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com> Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
34db4b1 to
ce24727
Compare
|
/bot run --add-multi-gpu-test |
|
/bot skip --comment " all tests have passed" |
|
PR_Github #22442 [ skip ] triggered by Bot. Commit: |
|
PR_Github #22442 [ skip ] completed with state |
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com> Signed-off-by: yufeiwu-nv <230315618+yufeiwu-nv@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
enhance cache transceiver to support VSWA.
the basic idea is transfer the blocks in the range
transfer (windowSize/tokensPerBlock+1) block for each window.
limitation:
Summary by CodeRabbit
New Features
API Changes
Tests
Description
cache transceiver will only send block in window for VWSA
Test Coverage
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
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.