[None][chore] split up TorchSampler.Store#11566
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #36143 [ run ] triggered by Bot. Commit: |
0beed4d to
b535285
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #36146 [ run ] triggered by Bot. Commit: |
📝 WalkthroughWalkthroughThis PR refactors the TorchSampler to introduce a new caching and grouping abstraction. A new _CachingRequestGrouper class manages per-slot grouping state and rebuilds grouping only when necessary. New storage abstractions BeamSearchStore and LogProbsStore encapsulate beam-search and log-probability buffers, replacing direct store access patterns. The end_ids field is removed from BeamSearchMetadata, and MTPSampler.Store is updated to no longer inherit from TorchSampler.Store. Tests are updated to use the new storage abstractions. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/pyexecutor/sampler.py (1)
1713-1727:⚠️ Potential issue | 🟡 MinorAdd Google-style docstrings to the new request helpers.
_is_new_requestand_filter_new_requestsare new and lack Google-style docstrings required by the guidelines.📝 Suggested docstrings
`@staticmethod` def _is_new_request(request: LlmRequest) -> bool: + """Return True when a request needs per-slot initialization. + + Args: + request: Request to evaluate. + + Returns: + True if the request should be treated as new in setup. + """ return ( not request.is_finished and not request.py_is_draft and ( (request.is_context_init_state and request.is_last_context_chunk) or request.is_disagg_generation_transmission_complete ) ) `@classmethod` def _filter_new_requests(cls, requests: ScheduledRequests) -> list[LlmRequest]: + """Return requests that require new-slot initialization. + + Args: + requests: Scheduled request bundle. + + Returns: + Filtered list of new requests. + """ return [request for request in requests.context_requests if cls._is_new_request(request)]As per coding guidelines, "Use Google style docstrings for classes and functions, which can be parsed by Sphinx."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tensorrt_llm/_torch/pyexecutor/sampler.py` around lines 1713 - 1727, Add Google-style docstrings to the two new helper methods: for _is_new_request(request: LlmRequest) add a short one-line summary, an Args section describing the request parameter and its type, and a Returns section describing the boolean meaning (True when request is active, not draft, and either an initial context last chunk or disaggregated generation transmission is complete); for _filter_new_requests(cls, requests: ScheduledRequests) add a one-line summary, an Args section describing the requests parameter and its type, and a Returns section describing that it returns a list[LlmRequest] filtered from requests.context_requests using cls._is_new_request. Ensure the docstrings follow Google style and are placed immediately above each method definition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tensorrt_llm/_torch/pyexecutor/sampler.py`:
- Around line 404-424: Update the inline attribute docstrings in the _Store
dataclass to use the required """<type>: Description""" format for each field
(e.g., change the current free-form string for slots_needing_recompute to
"""set: Slots where strategy needs (re)computation. Populated in
setup_sampler_step.""" and similarly update need_processed, need_raw,
strategies, uses_beam_search, non_greedy_slots, speculation_needs_probs,
needs_probs to include their types like list, set, etc., followed by the
existing descriptions); ensure every remaining attribute in class _Store follows
this exact "<type>: Description" pattern so they comply with the repo coding
guideline.
In `@tests/unittest/_torch/sampler/test_torch_sampler.py`:
- Around line 1206-1209: Rename the unused receiver parameter in the test helper
function to satisfy Ruff ARG001: update the local function _mock_filter used to
patch TorchSampler._filter_new_requests so its first parameter is renamed from
self to _self (or _) while keeping the rest of the signature (requests:
ScheduledRequests) -> list[LlmRequest] unchanged; leave the
patcher.setattr(TorchSampler, "_filter_new_requests", _mock_filter) call intact.
---
Outside diff comments:
In `@tensorrt_llm/_torch/pyexecutor/sampler.py`:
- Around line 1713-1727: Add Google-style docstrings to the two new helper
methods: for _is_new_request(request: LlmRequest) add a short one-line summary,
an Args section describing the request parameter and its type, and a Returns
section describing the boolean meaning (True when request is active, not draft,
and either an initial context last chunk or disaggregated generation
transmission is complete); for _filter_new_requests(cls, requests:
ScheduledRequests) add a one-line summary, an Args section describing the
requests parameter and its type, and a Returns section describing that it
returns a list[LlmRequest] filtered from requests.context_requests using
cls._is_new_request. Ensure the docstrings follow Google style and are placed
immediately above each method definition.
|
PR_Github #36146 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #36219 [ run ] triggered by Bot. Commit: |
|
PR_Github #36219 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #36231 [ run ] triggered by Bot. Commit: |
|
PR_Github #36231 [ run ] completed with state
|
Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
18d4e3c to
e8c852b
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #36238 [ run ] triggered by Bot. Commit: |
Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
|
/bot run --disable-fail-fast |
|
PR_Github #36246 [ run ] triggered by Bot. Commit: |
|
PR_Github #36246 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #36323 [ run ] triggered by Bot. Commit: |
|
PR_Github #36323 [ run ] completed with state |
Description
Detailed changes:
BeamSearchMetadata.end_idsis not None, reducing the amount ofassert ... is not Nonerequired for type correctness.TorchSampler.setup_sampler_stepto make tests more robust (cf. discussions in [TRTLLM-10791][feat] TorchSampler general host time optimization #11141)MTPSamplerfromTorchSamplerTest Coverage
n/a
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.
Summary by CodeRabbit
Release Notes
Refactor
Breaking Changes
end_idsfield fromBeamSearchMetadata. Update code referencing this field accordingly.