-
Notifications
You must be signed in to change notification settings - Fork 2k
[TRTLLM-10628][feat] Apply tunable AllReduce to Ray path. #10947
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
📝 WalkthroughWalkthroughThe changes add MPI-offload support toggles to AllReduce-related APIs across custom operations and distributed operations modules. Function signatures for AllReduceRunner, tunable_allreduce, and related resolver functions now include disable_mpi and rank parameters. The forward execution path conditionally retrieves model extra attributes when MPI is disabled and passes them to the underlying operation. Test configuration for MPI pickling was also updated to use explicit module imports and protocol specification. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ 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 |
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
tensorrt_llm/_torch/distributed/ops.py (2)
1-5: Add NVIDIA SPDX header to this source file.This file is missing the required NVIDIA copyright SPDX header with the year of latest modification (2026).
📝 Suggested header
+ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + # SPDX-License-Identifier: Apache-2.0As per coding guidelines.
829-854: Non-AUTO path now leavesoutputundefined.Line 829 only assigns
outputinside the AUTO branch; whendisable_allreduce_autotuneis true or strategy ≠ AUTO, this will raiseUnboundLocalError. Also, Line 832 assumesget_model_extra_attrs()is initialized in the MPI-disabled path—add a guard to fail clearly.🐛 Proposed fix
- if allreduce_strategy == AllReduceStrategy.AUTO and not disable_allreduce_autotune: + if allreduce_strategy == AllReduceStrategy.AUTO and not disable_allreduce_autotune: # Set up pg_boxed in extra_attrs for tunable_allreduce to access if self._disable_mpi: - extra_attrs = get_model_extra_attrs() + extra_attrs = get_model_extra_attrs() + assert extra_attrs is not None, "Model extra attrs not initialized" pg = self.mapping.tp_group_pg assert pg is not None, "TP ProcessGroup not initialised" extra_attrs["pg_boxed"] = pg.boxed() output = torch.ops.trtllm.tunable_allreduce( input=input, residual=all_reduce_params.residual, norm_weight=all_reduce_params.norm_weight, scale=all_reduce_params.scale, bias=all_reduce_params.bias, workspace=self.workspace, group=self.mapping.tp_group, strategy=allreduce_strategy, op=all_reduce_params.fusion_op, eps=all_reduce_params.eps, trigger_completion_at_end=all_reduce_params. trigger_completion_at_end, disable_mpi=self._disable_mpi, rank=self.mapping.tp_rank, ) + else: + extra_args = {} + if self._disable_mpi: + pg = self.mapping.tp_group_pg + assert pg is not None, "TP ProcessGroup not initialised" + extra_args = {"pg_boxed": pg.boxed(), "rank": self.mapping.tp_rank} + output = self.all_reduce_op( + input=input, + residual=all_reduce_params.residual, + norm_weight=all_reduce_params.norm_weight, + scale=all_reduce_params.scale, + bias=all_reduce_params.bias, + workspace=self.workspace, + group=self.mapping.tp_group, + strategy=allreduce_strategy, + op=all_reduce_params.fusion_op, + eps=all_reduce_params.eps, + trigger_completion_at_end=all_reduce_params.trigger_completion_at_end, + **extra_args, + )tensorrt_llm/_torch/custom_ops/torch_custom_ops.py (1)
1-5: Add NVIDIA SPDX header to this source file.This file is missing the required NVIDIA copyright SPDX header with the year of latest modification (2026).
📝 Suggested header
+ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + # SPDX-License-Identifier: Apache-2.0As per coding guidelines.
🤖 Fix all issues with AI agents
In `@tensorrt_llm/_torch/custom_ops/torch_custom_ops.py`:
- Around line 1736-1756: The MPI-disabled branch assumes get_model_extra_attrs()
returns a dict with "pg_boxed"; add a defensive assertion before indexing: when
self.disable_mpi is true, call extra_attrs = get_model_extra_attrs() and assert
extra_attrs is a dict and "pg_boxed" in extra_attrs (or raise a clear
AssertionError/ValueError) so extra_args = {"pg_boxed": extra_attrs["pg_boxed"],
"rank": self.rank} cannot raise a TypeError/KeyError; keep the rest of the
all_reduce_op call unchanged (references: self.disable_mpi,
get_model_extra_attrs, extra_args, self.rank, all_reduce_op).
🧹 Nitpick comments (2)
tensorrt_llm/_torch/distributed/ops.py (1)
13-13: Keep module namespace for utils import.Use a module import (e.g.,
import tensorrt_llm._torch.utils as torch_utils) and calltorch_utils.get_model_extra_attrs()to follow the namespace rule.♻️ Suggested change
-from tensorrt_llm._torch.utils import get_model_extra_attrs +import tensorrt_llm._torch.utils as torch_utils- extra_attrs = get_model_extra_attrs() + extra_attrs = torch_utils.get_model_extra_attrs()As per coding guidelines.
tensorrt_llm/_torch/custom_ops/torch_custom_ops.py (1)
10-10: Keep module namespace for utils import.Use a module import (e.g.,
import tensorrt_llm._torch.utils as torch_utils) and calltorch_utils.get_model_extra_attrs()to follow the namespace rule.♻️ Suggested change
-from tensorrt_llm._torch.utils import get_model_extra_attrs +import tensorrt_llm._torch.utils as torch_utils- extra_attrs = get_model_extra_attrs() + extra_attrs = torch_utils.get_model_extra_attrs()As per coding guidelines.
|
/bot run --disable-fail-fast --only-multi-gpu-test |
|
PR_Github #33353 [ run ] triggered by Bot. Commit: |
Signed-off-by: Yukun He <23156053+hyukn@users.noreply.github.com>
35cf455 to
eec378e
Compare
|
/bot run --disable-fail-fast --only-multi-gpu-test |
|
PR_Github #33374 [ run ] triggered by Bot. Commit: |
|
PR_Github #33374 [ run ] completed with state
|
|
/bot run --disable-fail-fast --only-multi-gpu-test |
|
PR_Github #33435 [ run ] triggered by Bot. Commit: |
|
PR_Github #33435 [ run ] completed with state
|
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.
Description
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.