-
Notifications
You must be signed in to change notification settings - Fork 2k
[TRTLLM-9527][feat] change context params and disagg params (step3) #10495
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
📝 WalkthroughWalkthroughThis PR extends the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/bot run --add-multi-gpu-tes |
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: 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(incontext_phase_params) toctx_info_endpoint(inDisaggregatedParams). While this follows the pattern of other fields likectx_dp_rankandctx_request_id, it could cause confusion since it's the only field with a name transformation.Consider either:
- Keeping consistent naming (both as
disagg_info_endpoint), or- Document this mapping clearly if the distinction is intentional.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
cpp/include/tensorrt_llm/executor/executor.hcpp/tensorrt_llm/batch_manager/llmRequest.cppcpp/tensorrt_llm/executor/contextPhaseParams.cppcpp/tensorrt_llm/executor/serialization.cppcpp/tensorrt_llm/nanobind/batch_manager/bindings.cppcpp/tensorrt_llm/nanobind/executor/request.cppcpp/tensorrt_llm/pybind/batch_manager/bindings.cppcpp/tensorrt_llm/pybind/executor/request.cpptensorrt_llm/_torch/pyexecutor/executor_request_queue.pytensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.pytensorrt_llm/_torch/pyexecutor/llm_request.pytensorrt_llm/disaggregated_params.pytensorrt_llm/executor/base_worker.pytensorrt_llm/executor/result.pytensorrt_llm/serve/openai_disagg_service.pytensorrt_llm/serve/openai_protocol.pytests/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)
Preferconstorconstexprvariables over#defineswhenever possible
A variable that is not modified after its initialization should be declared asconst
For naming of constants in C++, use uppercase snakecase with prefix 'k' (e.g.,kDIGIT_NUM)
Except for0,nullptr,true, andfalse, 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 emptyfororwhileloop in a new line
The statement forming the body of aswitch,while,do..while, orforstatement must be a compound statement (use brace-delimited statements)
Ifandelsestatements 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.cppcpp/tensorrt_llm/pybind/batch_manager/bindings.cppcpp/tensorrt_llm/batch_manager/llmRequest.cppcpp/include/tensorrt_llm/executor/executor.hcpp/tensorrt_llm/executor/serialization.cppcpp/tensorrt_llm/pybind/executor/request.cppcpp/tensorrt_llm/executor/contextPhaseParams.cppcpp/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++
Preferunique_ptrfor single resource ownership andshared_ptrfor shared resource ownership in C++. Useweak_ptronly 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 tovoid*in C++ should be implicit (except if removingconst)
Casting in C++ should not remove anyconstorvolatilequalification 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 fromvoid*toT*in C++ should be done withstatic_cast, notreinterpret_cast
Usereinterpret_castin C++ as a last resort, whereconst_castandstatic_castwon't work
Avoiddynamic_castin C++
Do not use assignment operator in C++ subexpressions (e.g.,x = y = zorif (x = y))
When practical, a C++switchstatement controlled by anenumshould 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 orstd::fill_n()instead ofmemset()
Files:
cpp/tensorrt_llm/nanobind/batch_manager/bindings.cppcpp/tensorrt_llm/pybind/batch_manager/bindings.cppcpp/tensorrt_llm/batch_manager/llmRequest.cppcpp/tensorrt_llm/executor/serialization.cppcpp/tensorrt_llm/pybind/executor/request.cppcpp/tensorrt_llm/executor/contextPhaseParams.cppcpp/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.cppcpp/tensorrt_llm/pybind/batch_manager/bindings.cppcpp/tensorrt_llm/batch_manager/llmRequest.cppcpp/include/tensorrt_llm/executor/executor.hcpp/tensorrt_llm/executor/serialization.cppcpp/tensorrt_llm/pybind/executor/request.cppcpp/tensorrt_llm/executor/contextPhaseParams.cppcpp/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.cppcpp/tensorrt_llm/pybind/batch_manager/bindings.cpptensorrt_llm/serve/openai_protocol.pytensorrt_llm/executor/base_worker.pytensorrt_llm/_torch/pyexecutor/llm_request.pycpp/tensorrt_llm/batch_manager/llmRequest.cpptensorrt_llm/serve/openai_disagg_service.pytensorrt_llm/disaggregated_params.pycpp/include/tensorrt_llm/executor/executor.htensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.pycpp/tensorrt_llm/executor/serialization.cppcpp/tensorrt_llm/pybind/executor/request.cpptests/unittest/bindings/test_executor_bindings.pycpp/tensorrt_llm/executor/contextPhaseParams.cpptensorrt_llm/executor/result.pycpp/tensorrt_llm/nanobind/executor/request.cpptensorrt_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 prefixkfor variable names that start with a number (e.g.,k_99th_percentile)
Python global variables should use upper snake_case with prefixG(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.pytensorrt_llm/executor/base_worker.pytensorrt_llm/_torch/pyexecutor/llm_request.pytensorrt_llm/serve/openai_disagg_service.pytensorrt_llm/disaggregated_params.pytensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.pytests/unittest/bindings/test_executor_bindings.pytensorrt_llm/executor/result.pytensorrt_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 formatTRTLLM_<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.cppcpp/tensorrt_llm/pybind/batch_manager/bindings.cpptensorrt_llm/serve/openai_protocol.pytensorrt_llm/disaggregated_params.pycpp/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.cppcpp/tensorrt_llm/batch_manager/llmRequest.cpptensorrt_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.pytensorrt_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.pytensorrt_llm/_torch/pyexecutor/kv_cache_transceiver.pytensorrt_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_paramsis 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 & 0x7FFFFFFFFFFFFFFFcorrectly produces a positive 63-bit integer, suitable for int64 storage. The assignment toDisaggregatedParamsis 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_paramstoexecutor_request.py_disaggregated_paramsfollows 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 explicitreturn Nonehas 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:
first_gen_tokens(VecTokens)req_id(RequestIdType)opaque_state(optional py::bytes)draft_tokens(optional VecTokens)disagg_id(optional int64_t)ctx_dp_rank(optional SizeType32)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 thepy::bytesopaque_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_paramsandto_llm_disaggregated_paramsare 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 providessetContextPhaseParams.tensorrt_llm/_torch/pyexecutor/llm_request.py (2)
569-570: LGTM!The initialization of
py_disaggregated_paramsfollows the established pattern for other Python-specific attributes in theLlmRequestclass.
832-834: LGTM!The propagation of
py_disaggregated_paramsuses safe attribute access withgetattrand 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 theContextPhaseParamsconstructor, 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:
- Extend
__getstate__to serialize all 7 fields including the 3 new ones- Update
__setstate__validation to expect 7 fields and deserialize them in both code paths- Add new read-write properties (
disagg_id,ctx_dp_rank,disagg_info_endpoint) with proper getter/setter bindings- Update the constructor binding to accept the new optional parameters with
nb::none()defaultsThe field ordering is consistent across serialization, deserialization, and construction.
502-512: Properties converted to read-write access.The
first_gen_tokens,draft_tokens, andreq_idproperties are now read-write (previously read-only based on the summary). This enables mutation ofContextPhaseParamsinstances 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:
- Constructs
ContextPhaseParamswith all 7 parameters including the newdisagg_id,ctx_dp_rank, anddisagg_info_endpointfields- Verifies pickle round-trip preserves all new field values
- 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 compatibilityThe added
mDisaggId,mCtxDpRank, andmDisaggInfoEndpointare read and written in a consistent order, andserializedSize(ContextPhaseParams)accounts for them correctly. Ownership ofDataTransceiverStateviastate.release()andStatePtralso remains sound.The only thing to double‑check is whether changing the on‑wire layout of
ContextPhaseParams(new fields inserted beforehasState) 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 changeThe updated
ContextPhaseParamsbindings are internally consistent:
__getstate__and__setstate__both use a 7‑tuple with matching field order, and reconstruction dispatches to the correct C++ constructor depending onopaque_state.- The new
__init__lambda and thedisagg_id/ctx_dp_rank/disagg_info_endpointproperties line up with the C++ API and use appropriate optional types.One behavioral change is that pickled
ContextPhaseParamsfrom older versions (which encoded a smaller tuple) will now fail to unpickle becauseContextPhaseParamsSetStaterequiresstate.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‑compatibleThe extended
ContextPhaseParamsinterface (constructors plus getters/setters fordisaggId,ctxDpRank, anddisaggInfoEndpoint) 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, andmDisaggInfoEndpoint, including the serialized‑state path that rebuildsmStatefrom the buffer.- The copy ctor and
operator==were updated to account for the new members while preserving deep‑copy semantics formState.- 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
|
PR_Github #30883 [ run ] triggered by Bot. Commit: |
|
PR_Github #30883 [ run ] completed with state
|
@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
ContextPhaseParamsandDisaggregatedParams, disagg_id acts as unique_id ,ctx_dp_rank+ctx_info_endpointact asopaque_stateordataTransceiverState,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 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.