Skip to content

Conversation

@chuangz0
Copy link
Collaborator

@chuangz0 chuangz0 commented Jan 7, 2026

@coderabbitai summary

Description

for python based cache transceiver ,we need unique id to identify request in context and gen side for compatibility with the pre-registration flow and other purposes.
We add three new fields in ContextPhaseParams and DisaggregatedParams , disagg_id acts as unique_id , ctx_dp_rank + ctx_info_endpoint act as opaque_state or dataTransceiverState ,which can't be used in python based cache transceiver.

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

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter 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.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip 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-pipeline

Reuse 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.

@chuangz0 chuangz0 requested review from a team as code owners January 7, 2026 09:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

This PR extends the ContextPhaseParams API to support three new optional disaggregation-related fields (disaggId, ctxDpRank, disaggInfoEndpoint) across C++ core, serialization, Python bindings, and runtime execution layers, enabling tracking and propagation of disaggregated context data throughout the system.

Changes

Cohort / File(s) Summary
C++ Core API
cpp/include/tensorrt_llm/executor/executor.h, cpp/tensorrt_llm/executor/contextPhaseParams.cpp
Extended ContextPhaseParams constructor overloads to accept three new optional trailing parameters (disaggId, ctxDpRank, disaggInfoEndpoint). Added public getter/setter methods for new disaggregation fields and for existing fields (firstGenTokens, draftTokens, reqId). Introduced private member variables and updated equality operator to include new fields.
Serialization
cpp/tensorrt_llm/executor/serialization.cpp
Extended serialization/deserialization paths to handle three new optional fields in ContextPhaseParams. Updated size calculation and constructor invocations to propagate disaggregation metadata in both state-based and non-state code paths.
Batch Manager
cpp/tensorrt_llm/batch_manager/llmRequest.cpp, cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp, cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
Updated ContextPhaseParams initialization to pass three new disaggregation parameters. Changed Python binding for context_phase_params property from read-only to read-write by exposing setter method.
Python Executor Bindings
cpp/tensorrt_llm/nanobind/executor/request.cpp, cpp/tensorrt_llm/pybind/executor/request.cpp
Extended pickle serialization state from 4 to 7 fields in __getstate__/__setstate__. Added new public properties (disagg_id, ctx_dp_rank, disagg_info_endpoint) with read/write accessors. Updated constructor binding to accept three additional optional parameters with proper defaults.
PyTorch Executor Runtime
tensorrt_llm/_torch/pyexecutor/llm_request.py, tensorrt_llm/_torch/pyexecutor/executor_request_queue.py, tensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.py, tensorrt_llm/executor/base_worker.py
Added py_disaggregated_params attribute to LlmRequest class. Extended request broadcasting to include disaggregated params. Added propagation of disagg_id from py_disaggregated_params to context_phase_params. Added conditional attachment of disaggregated params for PyTorch backend.
DisaggregatedParams API
tensorrt_llm/disaggregated_params.py, tensorrt_llm/openai_protocol.py, tensorrt_llm/serve/openai_disagg_service.py, tensorrt_llm/executor/result.py
Added three new optional fields to DisaggregatedParams: disagg_id, ctx_dp_rank, ctx_info_endpoint. Updated get_context_phase_params to propagate new fields when constructing ContextPhaseParams. Updated conversion functions and result handling to include new fields in disaggregated params reconstruction.
Tests
tests/unittest/bindings/test_executor_bindings.py
Updated ContextPhaseParams construction from 4-argument to 7-argument form. Extended pickle round-trip assertions to verify new fields (disagg_id, ctx_dp_rank, disagg_info_endpoint) on both original and copied instances.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title '[TRTLLM-9527][feat] change context params and disagg params (step3)' is vague and generic. While it mentions the feature type and includes a ticket reference, 'change context params and disagg params' is overly broad and doesn't convey the specific nature of the changes (adding new fields, exposing setters, etc.). Clarify the title to describe the specific change, such as '[TRTLLM-9527][feat] Add disaggregation fields to ContextPhaseParams' or similar to better convey the main change.
Description check ❓ Inconclusive PR description is incomplete, using only template with placeholder text. Author-provided description lacks explicit rationale section, detailed test coverage, and documentation updates. Add detailed description of why these three fields (disagg_id, ctx_dp_rank, ctx_info_endpoint) are necessary, explain the pre-registration flow compatibility requirement, and document which test cases validate these changes.

✏️ 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.

@chuangz0
Copy link
Collaborator Author

chuangz0 commented Jan 7, 2026

/bot run --add-multi-gpu-tes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tensorrt_llm/serve/openai_disagg_service.py (1)

314-317: Consider extracting the error message to improve maintainability.

The validation logic is correct, but per the static analysis hint (TRY003), the error message could be extracted to a constant or custom exception class for better maintainability.

♻️ Optional refactoring to address TRY003

Define a constant at module level:

DISAGG_ID_MISSING_ERROR = (
    "Invalid disaggregated params in context phase response. disagg_id is None"
)

Then use it:

             if ctx_response.choices[0].disaggregated_params.disagg_id is None:
-                raise ValueError(
-                    "Invalid disaggregated params in context phase response. disagg_id is None"
-                )
+                raise ValueError(DISAGG_ID_MISSING_ERROR)
tensorrt_llm/executor/result.py (1)

430-432: Consider naming consistency for endpoint field.

The field name changes from disagg_info_endpoint (in context_phase_params) to ctx_info_endpoint (in DisaggregatedParams). While this follows the pattern of other fields like ctx_dp_rank and ctx_request_id, it could cause confusion since it's the only field with a name transformation.

Consider either:

  1. Keeping consistent naming (both as disagg_info_endpoint), or
  2. Document this mapping clearly if the distinction is intentional.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b130d58 and ead4fc3.

📒 Files selected for processing (17)
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/batch_manager/llmRequest.cpp
  • cpp/tensorrt_llm/executor/contextPhaseParams.cpp
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
  • cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • tensorrt_llm/_torch/pyexecutor/executor_request_queue.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.py
  • tensorrt_llm/_torch/pyexecutor/llm_request.py
  • tensorrt_llm/disaggregated_params.py
  • tensorrt_llm/executor/base_worker.py
  • tensorrt_llm/executor/result.py
  • tensorrt_llm/serve/openai_disagg_service.py
  • tensorrt_llm/serve/openai_protocol.py
  • tests/unittest/bindings/test_executor_bindings.py
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh}: Closing braces of namespaces should have a comment saying the namespace it closes (e.g., } // namespace foo)
Prefer const or constexpr variables over #defines whenever possible
A variable that is not modified after its initialization should be declared as const
For naming of constants in C++, use uppercase snakecase with prefix 'k' (e.g., kDIGIT_NUM)
Except for 0, nullptr, true, and false, all other literals should only be used for variable initialization and not in comparisons or expressions
Use Allman indentation style for brace notation in C++ code
Put the semicolon for an empty for or while loop in a new line
The statement forming the body of a switch, while, do..while, or for statement must be a compound statement (use brace-delimited statements)
If and else statements should always be followed by brace-delimited statements, even if empty or a single statement
C++ filenames should use camelCase with first letter lowercase (e.g., thisIsAFilename.cpp)
All types (including class names) in C++ should use PascalCase with uppercase first letter (e.g., FooBarClass)
Local variables, methods, and namespaces in C++ should use camelCase with first letter lowercase (e.g., localFooBar)
Non-magic-number global variables that are non-static and not defined in anonymous namespace should use camelCase prefixed with 'g' (e.g., gDontUseGlobalFoos)
Non-magic-number global variables that are static or defined in an anonymous namespace should use camelCase prefixed with 's' (e.g., sMutableStaticGlobal)
Locally visible static variables should use camelCase with 's' as the first letter (e.g., static std::once_flag sFlag;)
Public, private, and protected class member variables should use camelCase prefixed with 'm' (e.g., mNbFooValues)
Do not use Hungarian notation in C++ except for 'apps hungarian' (e.g., 'nb' to indicate count: mNbLayers)
If a constructor parameter name conflicts with a public me...

Files:

  • cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/batch_manager/llmRequest.cpp
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • cpp/tensorrt_llm/executor/contextPhaseParams.cpp
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
**/*.{cpp,cc,cxx,cu}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{cpp,cc,cxx,cu}: Use smart pointers for allocating objects on the heap in C++
Prefer unique_ptr for single resource ownership and shared_ptr for shared resource ownership in C++. Use weak_ptr only in exceptional cases
In C++ function calls where parameters are not obvious, use inline C comments to document the parameter (e.g., doSomeOperation(/* checkForErrors = */ false);)
Use the least forceful cast necessary in C++, or no cast if possible
Casting a pointer to void* in C++ should be implicit (except if removing const)
Casting in C++ should not remove any const or volatile qualification from the type of a pointer or reference
Do not use C-style casts (other than void casts) and functional notation casts (other than explicit constructor calls) in C++
Casting from void* to T* in C++ should be done with static_cast, not reinterpret_cast
Use reinterpret_cast in C++ as a last resort, where const_cast and static_cast won't work
Avoid dynamic_cast in C++
Do not use assignment operator in C++ subexpressions (e.g., x = y = z or if (x = y))
When practical, a C++ switch statement controlled by an enum should have a case for each enum value and not have a default clause
C++ switch statements should be well structured as structured multi-way branches, not as 'glorified gotos'
In C++ switch statements, prohibit fall-through except from one case label to another. Each case clause must be terminated with a break or throw
Do not end a C++ case clause with return; use break or throw instead
If a C++ switch clause is a compound statement, put the break inside the braces
Do not use C library functions in C++ whenever possible. Use C++ alternatives like brace initialization or std::fill_n() instead of memset()

Files:

  • cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/batch_manager/llmRequest.cpp
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • cpp/tensorrt_llm/executor/contextPhaseParams.cpp
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
**/*.{h,hpp,hxx,cpp,cc,cxx,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All C++ class templates, function templates, class template member functions, and class template static members must be instantiated at least once

Files:

  • cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/batch_manager/llmRequest.cpp
  • cpp/include/tensorrt_llm/executor/executor.h
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • cpp/tensorrt_llm/executor/contextPhaseParams.cpp
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification

Files:

  • cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp
  • tensorrt_llm/serve/openai_protocol.py
  • tensorrt_llm/executor/base_worker.py
  • tensorrt_llm/_torch/pyexecutor/llm_request.py
  • cpp/tensorrt_llm/batch_manager/llmRequest.cpp
  • tensorrt_llm/serve/openai_disagg_service.py
  • tensorrt_llm/disaggregated_params.py
  • cpp/include/tensorrt_llm/executor/executor.h
  • tensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.py
  • cpp/tensorrt_llm/executor/serialization.cpp
  • cpp/tensorrt_llm/pybind/executor/request.cpp
  • tests/unittest/bindings/test_executor_bindings.py
  • cpp/tensorrt_llm/executor/contextPhaseParams.cpp
  • tensorrt_llm/executor/result.py
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
  • tensorrt_llm/_torch/pyexecutor/executor_request_queue.py
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing Python modules, even if only one class or function from a module is used
Python filenames should use snake_case (e.g., some_file.py)
Python classes should use PascalCase (e.g., class SomeClass)
Python functions and methods should use snake_case (e.g., def my_awesome_function():)
Python local variables should use snake_case, with prefix k for variable names that start with a number (e.g., k_99th_percentile)
Python global variables should use upper snake_case with prefix G (e.g., G_MY_GLOBAL)
Python constants should use upper snake_case (e.g., MY_CONSTANT)
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Use comments in Python for code within a function, or interfaces that are local to a file
Use Google-style docstrings for Python classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with the format """<type>: Description"""
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except clause to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible and use the else block for the main logic

Files:

  • tensorrt_llm/serve/openai_protocol.py
  • tensorrt_llm/executor/base_worker.py
  • tensorrt_llm/_torch/pyexecutor/llm_request.py
  • tensorrt_llm/serve/openai_disagg_service.py
  • tensorrt_llm/disaggregated_params.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.py
  • tests/unittest/bindings/test_executor_bindings.py
  • tensorrt_llm/executor/result.py
  • tensorrt_llm/_torch/pyexecutor/executor_request_queue.py
**/*.{h,hpp,hxx}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{h,hpp,hxx}: Follow Doxygen rules for documenting new C++ class interfaces and function prototypes. Use //! for C++-style single-line comments and //!< for class members
Use a preprocessor guard in C++ header files with the format TRTLLM_<FILENAME>_H, where the filename is in uppercase with no underscores, no prefix underscores, and no trailing underscores

Files:

  • cpp/include/tensorrt_llm/executor/executor.h
🧠 Learnings (9)
📓 Common learnings
Learnt from: venkywonka
Repo: NVIDIA/TensorRT-LLM PR: 6029
File: .github/pull_request_template.md:45-53
Timestamp: 2025-08-27T17:50:13.264Z
Learning: For PR templates in TensorRT-LLM, avoid suggesting changes that would increase developer overhead, such as converting plain bullets to mandatory checkboxes. The team prefers guidance-style bullets that don't require explicit interaction to reduce friction in the PR creation process.
📚 Learning: 2025-08-14T15:38:01.771Z
Learnt from: MatthiasKohl
Repo: NVIDIA/TensorRT-LLM PR: 6904
File: cpp/tensorrt_llm/pybind/thop/bindings.cpp:55-57
Timestamp: 2025-08-14T15:38:01.771Z
Learning: In TensorRT-LLM Python bindings, tensor parameter collections like mla_tensor_params and spec_decoding_tensor_params are kept as required parameters without defaults to maintain API consistency, even when it might affect backward compatibility.

Applied to files:

  • cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp
  • tensorrt_llm/serve/openai_protocol.py
  • tensorrt_llm/disaggregated_params.py
  • cpp/tensorrt_llm/nanobind/executor/request.cpp
📚 Learning: 2025-08-21T09:41:49.347Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 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/pybind/batch_manager/bindings.cpp
  • cpp/tensorrt_llm/batch_manager/llmRequest.cpp
  • tensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.py
📚 Learning: 2025-12-12T03:27:18.859Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 9655
File: tensorrt_llm/_torch/pyexecutor/sampler.py:3031-3031
Timestamp: 2025-12-12T03:27:18.859Z
Learning: In tensorrt_llm/_torch/pyexecutor/sampler.py, when reviewing code that iterates through requests, ensure it does not convert excessive data into Python lists. Instead, the code should use torch.gather or indexing to gather only the data that will be used in the for loop before converting to Python lists. This minimizes data movement and improves performance.

Applied to files:

  • tensorrt_llm/executor/base_worker.py
  • tensorrt_llm/_torch/pyexecutor/executor_request_queue.py
📚 Learning: 2025-12-12T03:27:08.565Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 9655
File: tensorrt_llm/_torch/pyexecutor/sampler.py:3031-3031
Timestamp: 2025-12-12T03:27:08.565Z
Learning: In files under tensorrt_llm/_torch/pyexecutor, avoid accessing torch.Tensor objects inside for-loops when iterating over requests. Convert batched tensors to Python lists beforehand using tensor.tolist(), and then iterate over those lists. This improves performance by reducing tensor-bound operations inside hot loops. Apply this pattern to similar code paths that process batches to access simple Python data structures (lists) inside loops.

Applied to files:

  • tensorrt_llm/_torch/pyexecutor/llm_request.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.py
  • tensorrt_llm/_torch/pyexecutor/executor_request_queue.py
📚 Learning: 2025-08-20T06:56:02.889Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 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/llmRequest.cpp
📚 Learning: 2025-08-15T06:46:54.897Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 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/batch_manager/llmRequest.cpp
📚 Learning: 2025-08-14T21:04:50.248Z
Learnt from: thorjohnsen
Repo: NVIDIA/TensorRT-LLM PR: 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/batch_manager/llmRequest.cpp
📚 Learning: 2025-08-20T06:48:45.368Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 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/llmRequest.cpp
🧬 Code graph analysis (9)
cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp (2)
cpp/tensorrt_llm/executor/request.cpp (4)
  • getContextPhaseParams (211-214)
  • getContextPhaseParams (211-211)
  • setContextPhaseParams (376-379)
  • setContextPhaseParams (376-376)
cpp/tensorrt_llm/executor/requestImpl.h (1)
  • setContextPhaseParams (425-428)
cpp/tensorrt_llm/batch_manager/llmRequest.cpp (1)
cpp/tensorrt_llm/executor/contextPhaseParams.cpp (2)
  • getDraftTokens (114-117)
  • getDraftTokens (114-114)
tensorrt_llm/serve/openai_disagg_service.py (2)
tensorrt_llm/disaggregated_params.py (1)
  • DisaggregatedParams (15-102)
tensorrt_llm/serve/openai_protocol.py (1)
  • DisaggregatedParams (114-122)
cpp/include/tensorrt_llm/executor/executor.h (1)
cpp/tensorrt_llm/executor/contextPhaseParams.cpp (38)
  • ContextPhaseParams (30-41)
  • ContextPhaseParams (43-53)
  • ContextPhaseParams (55-73)
  • ContextPhaseParams (75-90)
  • ContextPhaseParams (92-92)
  • ContextPhaseParams (102-102)
  • setFirstGenTokens (109-112)
  • setFirstGenTokens (109-109)
  • getDraftTokens (114-117)
  • getDraftTokens (114-114)
  • setDraftTokens (119-122)
  • setDraftTokens (119-119)
  • popFirstGenTokens (124-127)
  • popFirstGenTokens (124-124)
  • getReqId (129-132)
  • getReqId (129-129)
  • setReqId (134-137)
  • setReqId (134-134)
  • getState (139-142)
  • getState (139-139)
  • getState (144-147)
  • getState (144-144)
  • releaseState (154-157)
  • releaseState (154-154)
  • getSerializedState (149-152)
  • getSerializedState (149-149)
  • getDisaggId (159-162)
  • getDisaggId (159-159)
  • setDisaggId (164-167)
  • setDisaggId (164-164)
  • getCtxDpRank (169-172)
  • getCtxDpRank (169-169)
  • setCtxDpRank (174-177)
  • setCtxDpRank (174-174)
  • getDisaggInfoEndpoint (179-182)
  • getDisaggInfoEndpoint (179-179)
  • setDisaggInfoEndpoint (184-187)
  • setDisaggInfoEndpoint (184-184)
cpp/tensorrt_llm/executor/serialization.cpp (3)
cpp/tensorrt_llm/executor/cache_transmission/agent_utils/connection.cpp (6)
  • deserialize (111-118)
  • deserialize (111-111)
  • serialize (103-109)
  • serialize (103-103)
  • serializedSize (120-125)
  • serializedSize (120-120)
cpp/tensorrt_llm/executor/cache_transmission/agent_utils/connection.h (3)
  • deserialize (55-122)
  • deserialize (181-204)
  • serializedSize (206-228)
cpp/tensorrt_llm/executor/requestImpl.h (1)
  • serialize (99-104)
cpp/tensorrt_llm/pybind/executor/request.cpp (1)
cpp/tensorrt_llm/executor/contextPhaseParams.cpp (2)
  • getFirstGenTokens (104-107)
  • getFirstGenTokens (104-104)
tests/unittest/bindings/test_executor_bindings.py (1)
cpp/tensorrt_llm/executor/contextPhaseParams.cpp (6)
  • ContextPhaseParams (30-41)
  • ContextPhaseParams (43-53)
  • ContextPhaseParams (55-73)
  • ContextPhaseParams (75-90)
  • ContextPhaseParams (92-92)
  • ContextPhaseParams (102-102)
cpp/tensorrt_llm/executor/contextPhaseParams.cpp (1)
cpp/include/tensorrt_llm/executor/types.h (1)
  • mState (907-907)
cpp/tensorrt_llm/nanobind/executor/request.cpp (1)
cpp/tensorrt_llm/executor/contextPhaseParams.cpp (16)
  • getReqId (129-132)
  • getReqId (129-129)
  • setReqId (134-137)
  • setReqId (134-134)
  • getDisaggId (159-162)
  • getDisaggId (159-159)
  • setDisaggId (164-167)
  • setDisaggId (164-164)
  • getCtxDpRank (169-172)
  • getCtxDpRank (169-169)
  • setCtxDpRank (174-177)
  • setCtxDpRank (174-174)
  • getDisaggInfoEndpoint (179-182)
  • getDisaggInfoEndpoint (179-179)
  • setDisaggInfoEndpoint (184-187)
  • setDisaggInfoEndpoint (184-184)
🪛 Ruff (0.14.10)
tensorrt_llm/serve/openai_disagg_service.py

315-317: Avoid specifying long messages outside the exception class

(TRY003)

⏰ 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). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (19)
tensorrt_llm/_torch/pyexecutor/executor_request_queue.py (1)

468-474: LGTM: Disaggregated parameters broadcasting follows established pattern.

The collection and broadcasting of py_disaggregated_params is implemented consistently with existing Python object handling (logits processors, multimodal data, scheduling params, etc.). The attribute is correctly collected on rank 0 and included in the broadcast flow.

tensorrt_llm/serve/openai_disagg_service.py (1)

146-152: LGTM: Disagg ID generation correctly produces positive int64 values.

The approach of generating a unique disagg_id using uuid.uuid4().int & 0x7FFFFFFFFFFFFFFF correctly produces a positive 63-bit integer, suitable for int64 storage. The assignment to DisaggregatedParams is appropriate for context-only requests.

tensorrt_llm/executor/base_worker.py (1)

566-568: LGTM: Disaggregated parameters correctly propagated for PyTorch backend.

The propagation of disaggregated_params to executor_request.py_disaggregated_params follows the established pattern for PyTorch backend-specific attributes (similar to multimodal data and logits processors). The conditional check ensures it only applies to the PyTorch backend, and the explanatory comment clearly documents the purpose.

tensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.py (1)

123-128: No action needed — all callers ignore the return value.

The method is called in three places: twice in tests and once in py_executor.py:2181, and none of them assign or use the return value. The explicit return None has no impact on existing callers.

Likely an incorrect or invalid review comment.

tensorrt_llm/disaggregated_params.py (1)

48-57: The 7-argument ContextPhaseParams constructor signature is correct.

Verification confirms the C++ pybind11 binding in cpp/tensorrt_llm/pybind/executor/request.cpp (lines 443-462) expects exactly 7 arguments with this signature:

  1. first_gen_tokens (VecTokens)
  2. req_id (RequestIdType)
  3. opaque_state (optional py::bytes)
  4. draft_tokens (optional VecTokens)
  5. disagg_id (optional int64_t)
  6. ctx_dp_rank (optional SizeType32)
  7. disagg_info_endpoint (optional string)

The code in get_context_phase_params() passes all 7 arguments in the correct order with matching types. The binding automatically converts the py::bytes opaque_state parameter to the appropriate C++ constructor form.

tensorrt_llm/serve/openai_protocol.py (2)

120-122: LGTM!

The new optional fields follow the existing pattern and are appropriately typed.


1006-1025: LGTM!

The bidirectional field mappings in to_disaggregated_params and to_llm_disaggregated_params are correctly implemented and maintain symmetry.

cpp/tensorrt_llm/pybind/batch_manager/bindings.cpp (1)

173-173: LGTM!

The binding change correctly exposes both getter and setter for context_phase_params, enabling Python-side mutation. This aligns with the corresponding change in the nanobind bindings and the underlying C++ API that provides setContextPhaseParams.

tensorrt_llm/_torch/pyexecutor/llm_request.py (2)

569-570: LGTM!

The initialization of py_disaggregated_params follows the established pattern for other Python-specific attributes in the LlmRequest class.


832-834: LGTM!

The propagation of py_disaggregated_params uses safe attribute access with getattr and a sensible default, consistent with similar patterns in the codebase.

cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp (1)

168-168: LGTM!

The binding change correctly exposes both getter and setter for context_phase_params, enabling Python-side mutation through nanobind. This is consistent with the corresponding pybind11 binding change and the underlying C++ API.

cpp/tensorrt_llm/batch_manager/llmRequest.cpp (1)

102-112: LGTM: New disaggregation parameters correctly propagated.

Both code paths consistently pass the three new optional fields (getDisaggId(), getCtxDpRank(), getDisaggInfoEndpoint()) to the ContextPhaseParams constructor, maintaining proper parameter ordering across the with-draft-tokens and without-draft-tokens branches.

cpp/tensorrt_llm/nanobind/executor/request.cpp (2)

439-525: LGTM: Comprehensive Python binding updates for new disaggregation fields.

The binding changes correctly:

  1. Extend __getstate__ to serialize all 7 fields including the 3 new ones
  2. Update __setstate__ validation to expect 7 fields and deserialize them in both code paths
  3. Add new read-write properties (disagg_id, ctx_dp_rank, disagg_info_endpoint) with proper getter/setter bindings
  4. Update the constructor binding to accept the new optional parameters with nb::none() defaults

The field ordering is consistent across serialization, deserialization, and construction.


502-512: Properties converted to read-write access.

The first_gen_tokens, draft_tokens, and req_id properties are now read-write (previously read-only based on the summary). This enables mutation of ContextPhaseParams instances after construction, which may be needed for disaggregated execution workflows. Ensure this mutability is intentional and doesn't introduce unexpected side effects in code that assumed immutability.

tests/unittest/bindings/test_executor_bindings.py (1)

1201-1225: LGTM: Test coverage for new disaggregation fields.

The test correctly:

  1. Constructs ContextPhaseParams with all 7 parameters including the new disagg_id, ctx_dp_rank, and disagg_info_endpoint fields
  2. Verifies pickle round-trip preserves all new field values
  3. Asserts equality between original and deserialized instances for each new field

The test values are appropriate: 13579 (int64), 1 (SizeType32), and "disagg_info_endpoint_24680" (string).

cpp/tensorrt_llm/executor/serialization.cpp (1)

649-699: ContextPhaseParams disagg fields are serialized symmetrically; check cross-version wire compatibility

The added mDisaggId, mCtxDpRank, and mDisaggInfoEndpoint are read and written in a consistent order, and serializedSize(ContextPhaseParams) accounts for them correctly. Ownership of DataTransceiverState via state.release() and StatePtr also remains sound.

The only thing to double‑check is whether changing the on‑wire layout of ContextPhaseParams (new fields inserted before hasState) is acceptable for your deployment topology. Any components deserializing data produced by older binaries (or vice versa) will now disagree on the expected layout unless rolled together or version‑gated.

cpp/tensorrt_llm/pybind/executor/request.cpp (1)

408-472: Python bindings for ContextPhaseParams look consistent; be aware of pickle schema change

The updated ContextPhaseParams bindings are internally consistent:

  • __getstate__ and __setstate__ both use a 7‑tuple with matching field order, and reconstruction dispatches to the correct C++ constructor depending on opaque_state.
  • The new __init__ lambda and the disagg_id / ctx_dp_rank / disagg_info_endpoint properties line up with the C++ API and use appropriate optional types.

One behavioral change is that pickled ContextPhaseParams from older versions (which encoded a smaller tuple) will now fail to unpickle because ContextPhaseParamsSetState requires state.size() == 7. If cross‑version pickle compatibility matters for you (e.g., long‑lived artifacts or job restarts across versions), you may want a versioned tuple or a len>=4 check with defaulting of the new fields.

cpp/include/tensorrt_llm/executor/executor.h (1)

445-508: ContextPhaseParams public API extension is coherent and source‑compatible

The extended ContextPhaseParams interface (constructors plus getters/setters for disaggId, ctxDpRank, and disaggInfoEndpoint) is consistent with existing patterns and remains source‑compatible thanks to defaulted optional parameters. No functional or ABI concerns stand out here.

cpp/tensorrt_llm/executor/contextPhaseParams.cpp (1)

30-82: ContextPhaseParams implementation correctly wires new disagg fields and preserves semantics

  • All three constructors now consistently initialize mDisaggId, mCtxDpRank, and mDisaggInfoEndpoint, including the serialized‑state path that rebuilds mState from the buffer.
  • The copy ctor and operator== were updated to account for the new members while preserving deep‑copy semantics for mState.
  • New setters (setFirstGenTokens, setDraftTokens, setReqId, and the disagg setters) are straightforward and noexcept, matching the header.

No functional issues spotted; this is a clean extension of the existing class behavior.

Also applies to: 109-187, 195-200

@chuangz0 chuangz0 requested a review from Shixiaowei02 January 7, 2026 09:37
@tensorrt-cicd
Copy link
Collaborator

PR_Github #30883 [ run ] triggered by Bot. Commit: ead4fc3

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30883 [ run ] completed with state SUCCESS. Commit: ead4fc3
/LLM/main/L0_MergeRequest_PR pipeline #23846 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

@Shixiaowei02 Shixiaowei02 added the Disaggregated serving <NV>Deploying with separated, distributed components (params, kv-cache, compute). Arch & perf. label Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Disaggregated serving <NV>Deploying with separated, distributed components (params, kv-cache, compute). Arch & perf.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants