-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[https://nvbugs/5647400] [fix] Enlarged the AllReduce workspace size to 64MB. Added AllReduce strategy to AD config. #9145
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
Conversation
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
… to ShardingInfo Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
📝 WalkthroughWalkthroughThis pull request adds comprehensive allreduce strategy support to TensorRT-LLM's auto-deploy system. Strategy parameters are introduced as configuration fields and propagated through custom ops APIs, distributed operations, and sharding utilities. A centralized validator normalizes strategy values (strings/enums to AllReduceStrategy type). Runtime enforcement in C++ validates strategy feasibility. A new multi-GPU test suite validates end-to-end strategy behavior. Changes
Sequence DiagramsequenceDiagram
participant Config as Config<br/>(default.yaml)
participant ShardingCfg as ShardingTransformConfig<br/>(validate_allreduce_strategy)
participant SharUtils as Sharding Utils<br/>(_insert_sharded_*)
participant OpsAPI as Custom Ops API<br/>(dist, linear, quant)
participant DistOps as Distributed Ops<br/>(trtllm_allreduce)
participant CppRT as C++ Runtime<br/>(allreduceOp)
Config->>ShardingCfg: allreduce_strategy: 'AUTO'
Note over ShardingCfg: Validate & convert<br/>string → enum
ShardingCfg->>SharUtils: allreduce_strategy: AllReduceStrategy
rect rgb(200, 220, 255)
Note over SharUtils: Propagate to sharding<br/>transforms (_insert_sharded_*)
SharUtils->>OpsAPI: strategy parameter
end
OpsAPI->>DistOps: strategy: str
rect rgb(220, 200, 220)
Note over DistOps: Convert to enum,<br/>validate, cache key,<br/>construct with strategy
end
DistOps->>CppRT: strategy in AllReduceStrategy
rect rgb(255, 220, 200)
Note over CppRT: Runtime guard:<br/>if non-AUTO, validate<br/>seq_len ≥ group_size<br/>else fallback to ONESHOT
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example:
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: 0
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/auto_deploy/transform/library/sharding.py (1)
588-598: Inconsistent handling of.add()return values.The code shows inconsistent patterns when calling
sharding_config.add():Correctly checks return value:
- Lines 588-598, 600-610, 644-654, 663-673:
if sharding_config.add(...): num_x += 1Unconditionally increments despite not checking return:
- Lines 612-622 (mamba config): Calls
.add()but then unconditionally incrementsnum_row_col_shardson line 623- Lines 633-642 (local_colwise): Calls
.add()without checking return- Lines 678-687 (fallback case): Calls
.add()without checking returnAccording to the PR description,
.add()returnsTruewhen the transform is successfully applied andFalsewhen the node is already sharded. Unconditional increments could lead to inaccurate counter values if transforms are rejected.For consistency and accuracy, consider checking the return value in all cases:
elif config == "mamba": - sharding_config.add( + if sharding_config.add( WeightShardingInfo.from_node( lin_node, split_dim=SplitDimension.COLUMN, rank=rank, world_size=world_size, dist_op=None, min_local_shape=min_local_shape, layer_type=LayerType.MAMBA, ) - ) - num_row_col_shards += 1 + ): + num_row_col_shards += 1Apply similar fixes to lines 633-642 and 678-687.
Also applies to: 600-610, 612-623, 633-642, 644-654, 663-673, 678-687
🧹 Nitpick comments (3)
tensorrt_llm/plugin/plugin.py (1)
609-616: Consider adding validation for the environment variable.The current implementation could raise a
ValueErrorifTRTLLM_ALLREDUCE_FUSION_WORKSPACE_SIZEcontains a non-numeric value, or could accept invalid values (negative, zero, or unreasonably large).Consider adding error handling:
# Allow override via environment variable for edge cases workspace_size_env = os.getenv("TRTLLM_ALLREDUCE_FUSION_WORKSPACE_SIZE") if workspace_size_env: - size = int(workspace_size_env) + try: + size = int(workspace_size_env) + if size <= 0: + logger.warning( + f"Invalid TRTLLM_ALLREDUCE_FUSION_WORKSPACE_SIZE={size}. Must be positive. Using default." + ) + else: + logger.info( + f"Using custom allreduce fusion workspace size: {size} bytes ({size / (1024**2):.1f} MiB)" + ) + return size + except ValueError: + logger.warning( + f"Invalid TRTLLM_ALLREDUCE_FUSION_WORKSPACE_SIZE='{workspace_size_env}'. Must be numeric. Using default." + ) - logger.info( - f"Using custom allreduce fusion workspace size: {size} bytes ({size / (1024**2):.1f} MiB)" - ) - return sizetensorrt_llm/_torch/auto_deploy/distributed/trtllm.py (1)
25-33: Broadenstrategyparsing to accept enumsSeveral call sites already traffic
AllReduceStrategyobjects (for example, the sharding config now stores enums); with the currentgetattrpath, handing one of those directly intotrtllm_allreduceraises aTypeError. We can make the conversion resilient by accepting enums (and ints) up front, while still raising a clearValueErrorfor bad inputs.- # Convert string strategy to enum - try: - strategy_enum = getattr(AllReduceStrategy, strategy) - except AttributeError: - raise ValueError( - f"Invalid allreduce strategy: {strategy}. " - f"Valid options: AUTO, NCCL, ONESHOT, TWOSHOT, MIN_LATENCY, " - f"LOWPRECISION, UB, MNNVL, NCCL_SYMMETRIC" - ) + if isinstance(strategy, AllReduceStrategy): + strategy_enum = strategy + else: + try: + strategy_enum = ( + AllReduceStrategy[strategy] + if isinstance(strategy, str) + else AllReduceStrategy(strategy) + ) + except (KeyError, ValueError, TypeError) as err: + valid = ", ".join(opt.name for opt in AllReduceStrategy) + raise ValueError( + f"Invalid allreduce strategy: {strategy}. Valid options: {valid}" + ) from errtensorrt_llm/_torch/auto_deploy/utils/sharding_utils.py (1)
1347-1352: Usemodel_copy(update=...)to clone frozen transformsSince these Pydantic models are frozen,
model_copy(update=...)communicates intent better than dumping to dict and re-instantiating withtype(transform), and it preserves any Pydantic-internal metadata automatically.- transform_dict = transform.model_dump() - transform_dict["allreduce_strategy"] = self.allreduce_strategy - transform = type(transform)(**transform_dict) + transform = transform.model_copy( + update={"allreduce_strategy": self.allreduce_strategy} + )
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
cpp/tensorrt_llm/thop/allreduceOp.cpp(1 hunks)tensorrt_llm/_torch/auto_deploy/config/default.yaml(1 hunks)tensorrt_llm/_torch/auto_deploy/custom_ops/dist.py(1 hunks)tensorrt_llm/_torch/auto_deploy/custom_ops/linear.py(1 hunks)tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py(3 hunks)tensorrt_llm/_torch/auto_deploy/distributed/trtllm.py(4 hunks)tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py(1 hunks)tensorrt_llm/_torch/auto_deploy/transform/library/collectives.py(2 hunks)tensorrt_llm/_torch/auto_deploy/transform/library/sharding.py(16 hunks)tensorrt_llm/_torch/auto_deploy/utils/sharding_utils.py(22 hunks)tensorrt_llm/plugin/plugin.py(1 hunks)tests/unittest/_torch/auto_deploy/unit/multigpu/test_ad_allreduce_strategies.py(1 hunks)
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: timlee0212
Repo: NVIDIA/TensorRT-LLM PR: 6886
File: tensorrt_llm/_torch/models/modeling_deepseekv3.py:0-0
Timestamp: 2025-08-14T06:36:40.701Z
Learning: In DeepSeek V3 model (tensorrt_llm/_torch/models/modeling_deepseekv3.py), the disagreement between AllReduce.__init__ guard and _compute_mlp_tp_size logic for MNNVL usage is expected by design. The AllReduce component and MLP TP-size computation intentionally use different criteria for MNNVL availability decisions.
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: tests/unittest/_torch/multi_gpu/test_nccl_device.py:138-149
Timestamp: 2025-10-13T19:45:03.518Z
Learning: In test_nccl_device.py, the NCCL device AllReduce implementation compares the entire residual tensor on each rank, unlike the UB implementation which compares per-rank chunks. The residual chunking calculations in the test are intentionally overridden to reflect this design difference.
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device implementation, NCCL version 2.28+ requirements are handled at runtime in the nccl_device/config layer rather than with compile-time guards. This allows the allreduceOp to remain version-agnostic and delegates version compatibility validation to the appropriate lower-level components that can gracefully handle unsupported configurations.
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 7520
File: tensorrt_llm/_torch/pyexecutor/resource_manager.py:605-613
Timestamp: 2025-09-24T03:31:28.908Z
Learning: In TensorRT-LLM Ray orchestrator mode, ProcessGroups are initialized with both Gloo and NCCL backends (e.g., "cuda:nccl,cpu:gloo"), allowing PyTorch distributed to automatically route CPU tensors through Gloo and GPU tensors through NCCL. This eliminates the need for manual device placement when performing allreduce operations on base types.
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.
Applied to files:
cpp/tensorrt_llm/thop/allreduceOp.cpptensorrt_llm/_torch/auto_deploy/transform/library/collectives.pytensorrt_llm/_torch/auto_deploy/custom_ops/quant.pytensorrt_llm/_torch/auto_deploy/distributed/trtllm.py
📚 Learning: 2025-08-14T06:36:40.701Z
Learnt from: timlee0212
Repo: NVIDIA/TensorRT-LLM PR: 6886
File: tensorrt_llm/_torch/models/modeling_deepseekv3.py:0-0
Timestamp: 2025-08-14T06:36:40.701Z
Learning: In DeepSeek V3 model (tensorrt_llm/_torch/models/modeling_deepseekv3.py), the disagreement between AllReduce.__init__ guard and _compute_mlp_tp_size logic for MNNVL usage is expected by design. The AllReduce component and MLP TP-size computation intentionally use different criteria for MNNVL availability decisions.
Applied to files:
cpp/tensorrt_llm/thop/allreduceOp.cpptensorrt_llm/_torch/auto_deploy/config/default.yamltensorrt_llm/plugin/plugin.pytensorrt_llm/_torch/auto_deploy/utils/sharding_utils.pytensorrt_llm/_torch/auto_deploy/transform/library/collectives.pytensorrt_llm/_torch/auto_deploy/distributed/trtllm.py
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device implementation, NCCL version 2.28+ requirements are handled at runtime in the nccl_device/config layer rather than with compile-time guards. This allows the allreduceOp to remain version-agnostic and delegates version compatibility validation to the appropriate lower-level components that can gracefully handle unsupported configurations.
Applied to files:
cpp/tensorrt_llm/thop/allreduceOp.cpptensorrt_llm/plugin/plugin.pytensorrt_llm/_torch/auto_deploy/transform/library/collectives.pytensorrt_llm/_torch/auto_deploy/distributed/trtllm.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/thop/allreduceOp.cpp
📚 Learning: 2025-08-14T23:23:27.449Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4010-4012
Timestamp: 2025-08-14T23:23:27.449Z
Learning: For MOE (Mixture of Experts) code reviews in TensorRT-LLM, avoid repeatedly suggesting finalize fusion validation checks and safety assertions. The user djns99 has indicated these suggestions are repetitive and unwanted across multiple MOE-related changes.
Applied to files:
cpp/tensorrt_llm/thop/allreduceOp.cpp
📚 Learning: 2025-08-08T04:10:19.038Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6728
File: cpp/tensorrt_llm/plugins/mixtureOfExperts/mixtureOfExpertsPlugin.cpp:966-966
Timestamp: 2025-08-08T04:10:19.038Z
Learning: TensorRT plugins currently don't support padding functionality, and TensorRT is not getting new features (in maintenance mode). This means that duplicating parameters like mExpertHiddenSize in function calls, even with TODO comments, can be acceptable as pragmatic solutions within these constraints.
Applied to files:
tensorrt_llm/plugin/plugin.py
📚 Learning: 2025-08-21T00:16:56.457Z
Learnt from: farshadghodsian
Repo: NVIDIA/TensorRT-LLM PR: 7101
File: docs/source/blogs/tech_blog/blog9_Deploying_GPT_OSS_on_TRTLLM.md:36-36
Timestamp: 2025-08-21T00:16:56.457Z
Learning: TensorRT-LLM container release tags in documentation should only reference published NGC container images. The README badge version may be ahead of the actual published container versions.
Applied to files:
tensorrt_llm/plugin/plugin.py
📚 Learning: 2025-08-19T03:35:20.866Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4616-4626
Timestamp: 2025-08-19T03:35:20.866Z
Learning: In the MOE profiler TMA workspace preparation (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu), the overlapping of TMA WS regions for NONE and FINALIZE variants is deliberate design to save memory space, as confirmed by djns99. The comment "reuse the same pointers to save space" reflects this intentional behavior.
Applied to files:
tensorrt_llm/plugin/plugin.py
📚 Learning: 2025-10-13T19:45:03.518Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: tests/unittest/_torch/multi_gpu/test_nccl_device.py:138-149
Timestamp: 2025-10-13T19:45:03.518Z
Learning: In test_nccl_device.py, the NCCL device AllReduce implementation compares the entire residual tensor on each rank, unlike the UB implementation which compares per-rank chunks. The residual chunking calculations in the test are intentionally overridden to reflect this design difference.
Applied to files:
tests/unittest/_torch/auto_deploy/unit/multigpu/test_ad_allreduce_strategies.pytensorrt_llm/_torch/auto_deploy/transform/library/collectives.pytensorrt_llm/_torch/auto_deploy/custom_ops/dist.pytensorrt_llm/_torch/auto_deploy/distributed/trtllm.py
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.
Applied to files:
tests/unittest/_torch/auto_deploy/unit/multigpu/test_ad_allreduce_strategies.py
📚 Learning: 2025-10-20T17:09:21.560Z
Learnt from: nvchenghaoz
Repo: NVIDIA/TensorRT-LLM PR: 8469
File: tensorrt_llm/_torch/auto_deploy/transform/library/rms_norm.py:180-182
Timestamp: 2025-10-20T17:09:21.560Z
Learning: In tensorrt_llm/_torch/auto_deploy/transform/library/rms_norm.py, the _gated_rmsnorm_replacement function does not need to cast the output of torch.ops.auto_deploy.torch_rmsnorm_gated back to the input dtype, even though the custom op returns fp32. The dtype handling is managed elsewhere or the fp32 output is acceptable for downstream consumers.
Applied to files:
tensorrt_llm/_torch/auto_deploy/transform/library/collectives.py
📚 Learning: 2025-10-20T16:54:09.824Z
Learnt from: nvchenghaoz
Repo: NVIDIA/TensorRT-LLM PR: 8469
File: tensorrt_llm/_torch/auto_deploy/custom_ops/rms_norm.py:6-6
Timestamp: 2025-10-20T16:54:09.824Z
Learning: In tensorrt_llm/_torch/auto_deploy/custom_ops/rms_norm.py, the import `from ...modules.mamba.layernorm_gated import _layer_norm_fwd` is correct and should not be changed to modules.fla.layernorm_gated. The _layer_norm_fwd function exists in both modules/mamba/layernorm_gated.py and modules/fla/layernorm_gated.py, but the mamba version is the intended implementation for this use case.
Applied to files:
tensorrt_llm/_torch/auto_deploy/transform/library/collectives.py
📚 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:
tensorrt_llm/_torch/auto_deploy/distributed/trtllm.py
🧬 Code graph analysis (7)
tests/unittest/_torch/auto_deploy/unit/multigpu/test_ad_allreduce_strategies.py (1)
tests/integration/defs/conftest.py (1)
llm_root(192-193)
tensorrt_llm/_torch/auto_deploy/utils/sharding_utils.py (3)
tensorrt_llm/functional.py (1)
AllReduceStrategy(3876-3885)tensorrt_llm/builder.py (1)
default(45-50)tensorrt_llm/_torch/auto_deploy/transform/library/sharding.py (1)
_validate_allreduce_strategy(163-165)
tensorrt_llm/_torch/auto_deploy/custom_ops/linear.py (2)
tensorrt_llm/_torch/auto_deploy/distributed/trtllm.py (3)
is_trtllm_op_available(90-92)trtllm_allreduce(21-44)trtllm_allreduce(84-85)tensorrt_llm/_torch/auto_deploy/custom_ops/dist.py (1)
all_reduce(29-43)
tensorrt_llm/_torch/auto_deploy/transform/library/sharding.py (2)
tensorrt_llm/functional.py (1)
AllReduceStrategy(3876-3885)tensorrt_llm/_torch/auto_deploy/utils/sharding_utils.py (7)
validate_allreduce_strategy(33-60)_validate_allreduce_strategy(589-593)_validate_allreduce_strategy(1316-1318)add(1339-1369)EPShardingInfo(1178-1201)from_node(654-659)from_node(1185-1190)
tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py (1)
tensorrt_llm/_torch/auto_deploy/distributed/trtllm.py (2)
trtllm_allreduce(21-44)trtllm_allreduce(84-85)
tensorrt_llm/_torch/auto_deploy/custom_ops/dist.py (1)
tensorrt_llm/_torch/auto_deploy/distributed/trtllm.py (3)
is_trtllm_op_available(90-92)trtllm_allreduce(21-44)trtllm_allreduce(84-85)
tensorrt_llm/_torch/auto_deploy/distributed/trtllm.py (3)
cpp/tensorrt_llm/thop/allreduceOp.cpp (3)
op(1036-1036)op(1075-1075)rank(814-925)tensorrt_llm/functional.py (1)
AllReduceStrategy(3876-3885)tensorrt_llm/_torch/distributed/ops.py (1)
AllReduce(554-710)
🪛 Ruff (0.14.4)
tests/unittest/_torch/auto_deploy/unit/multigpu/test_ad_allreduce_strategies.py
11-11: Unused noqa directive (non-enabled: F401)
Remove unused noqa directive
(RUF100)
33-33: Unused function argument: signum
(ARG001)
33-33: Unused function argument: frame
(ARG001)
34-34: Avoid specifying long messages outside the exception class
(TRY003)
86-86: subprocess call: check for execution of untrusted input
(S603)
90-90: Avoid specifying long messages outside the exception class
(TRY003)
107-107: Unused function argument: llm_root
(ARG001)
tensorrt_llm/_torch/auto_deploy/utils/sharding_utils.py
54-57: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
(B904)
54-57: Avoid specifying long messages outside the exception class
(TRY003)
297-299: Avoid specifying long messages outside the exception class
(TRY003)
458-460: Avoid specifying long messages outside the exception class
(TRY003)
1021-1021: Avoid specifying long messages outside the exception class
(TRY003)
1139-1141: Avoid specifying long messages outside the exception class
(TRY003)
tensorrt_llm/_torch/auto_deploy/custom_ops/linear.py
48-48: Unused function argument: strategy
(ARG001)
tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py
260-260: Unused function argument: strategy
(ARG001)
tensorrt_llm/_torch/auto_deploy/custom_ops/dist.py
47-47: Unused function argument: strategy
(ARG001)
tensorrt_llm/_torch/auto_deploy/distributed/trtllm.py
29-33: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
(B904)
29-33: Avoid specifying long messages outside the exception class
(TRY003)
71-71: Unused function argument: residual
(ARG001)
72-72: Unused function argument: norm_weight
(ARG001)
73-73: Unused function argument: eps
(ARG001)
74-74: Unused function argument: strategy
(ARG001)
84-84: Unused function argument: tensor
(ARG001)
84-84: Unused function argument: op
(ARG001)
84-84: Unused function argument: strategy
(ARG001)
84-84: Unused function argument: all_reduce_params
(ARG001)
🔇 Additional comments (11)
tensorrt_llm/plugin/plugin.py (2)
584-603: Excellent documentation for workspace calculation.The docstring clearly explains the lamport buffer sizing, triple buffering mechanism, TP scaling, and provides a concrete example. This will help users understand when they need to adjust the workspace size.
618-621: LGTM - workspace size increase addresses critical issues.The explicit 64 MiB default (8x increase from the previous 8 MB) aligns with the PR objectives to fix hangs and crashes. The clear comment provides guidance for users with larger models who may need to override via the environment variable.
tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py (1)
242-242: LGTM: Strategy parameter added correctly.The
strategyparameter has been properly added to both the real and fake implementations offused_fp8_linear_all_reduce. The real implementation (line 251) correctly forwards the strategy totrtllm_allreducewhen the TRT-LLM op is available.The static analysis warning about unused
strategyin the fake function (line 260) is a false positive—fake functions maintain signature parity for PyTorch tracing/export without executing the actual operation.Also applies to: 260-260
tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py (1)
328-332: LGTM: Good observability enhancement.The logging of the configured allreduce strategy provides valuable runtime visibility without affecting execution behavior. The check for non-AUTO strategies ensures the log is only emitted when users have explicitly configured a specific strategy.
tensorrt_llm/_torch/auto_deploy/config/default.yaml (1)
83-83: LGTM: Configuration field added appropriately.The
allreduce_strategy: 'AUTO'field extends the detect_sharding configuration with a sensible default that enables automatic strategy selection. This aligns with the AllReduceStrategy.AUTO enum and integrates well with the validation and propagation logic in the sharding pipeline.cpp/tensorrt_llm/thop/allreduceOp.cpp (1)
962-968: LGTM: Good defensive fallback for TWOSHOT constraint.The runtime check gracefully handles cases where TWOSHOT strategy is requested but
seq_len < tp_size, falling back to ONESHOT with a clear warning message. This prevents the operation from hitting the TORCH_CHECK at line 603 and throwing an error, allowing execution to continue with a valid strategy.This defensive programming aligns with the PR's stated objective of adding a fallback when sequence length is too short for the one-shot kernel.
tensorrt_llm/_torch/auto_deploy/transform/library/collectives.py (1)
31-31: LGTM: Pattern functions updated with explicit strategy parameter.The addition of
"AUTO"as the strategy argument totorch_dist_all_reducein both pattern functions correctly aligns with the updated API signature in dist.py. This ensures pattern matching captures the new parameter structure while maintaining automatic strategy selection.Also applies to: 55-55
tensorrt_llm/_torch/auto_deploy/custom_ops/dist.py (1)
29-43: LGTM: Strategy parameter integrated correctly.The
strategyparameter has been properly added as a mandatory argument toall_reduce, with clear documentation indicating it's required. The implementation correctly forwards the strategy totrtllm_allreducewhen the TRT-LLM op is available, while falling back to standard all_reduce otherwise.The static analysis warning about unused
strategyin the fake function (line 47) is a false positive—fake implementations maintain API parity for tracing without executing the actual distributed operation.tensorrt_llm/_torch/auto_deploy/custom_ops/linear.py (1)
37-44: LGTM: Fused linear all-reduce updated with strategy parameter.The
strategyparameter has been properly integrated into both the signature and implementation offused_linear_all_reduce. The docstring correctly documents that strategy is mandatory, and the real implementation forwards it totrtllm_allreducewhen available.The static analysis warning about unused
strategyin the fake function (line 48) is a false positive—fake implementations maintain interface parity for PyTorch's tracing/export system.tensorrt_llm/_torch/auto_deploy/transform/library/sharding.py (2)
154-165: LGTM: AllReduce strategy configuration with proper validation.The
allreduce_strategyfield has been correctly added toShardingTransformConfigwith:
- Appropriate default value (AllReduceStrategy.AUTO)
- Clear description of available options
- Pre-validation using the shared
validate_allreduce_strategyfunction to convert string/int inputs to the enumThis establishes a clean configuration path for allreduce strategy selection.
213-213: LGTM: Strategy propagation to sharding config.The allreduce_strategy is correctly propagated from the transform config to the shared sharding_config (line 213), ensuring the strategy setting flows through the sharding pipeline and is available for downstream operations.
greg-kwasniewski1
left a 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.
One larger comment - I'd move all_reduce_strategy from parent ShardingTransformInfo class to WeightShardingInfo chilld class.
tests/unittest/_torch/auto_deploy/unit/multigpu/test_ad_allreduce_strategies.py
Outdated
Show resolved
Hide resolved
lucaslie
left a 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.
Design looks good overall. Just a few comments to refine the PR
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
|
/bot run |
|
PR_Github #24682 [ run ] triggered by Bot. Commit: |
|
PR_Github #24682 [ run ] completed with state |
|
/bot run |
|
PR_Github #24684 [ run ] triggered by Bot. Commit: |
|
PR_Github #24684 [ run ] completed with state |
|
/bot run |
1 similar comment
|
/bot run |
|
PR_Github #24779 [ run ] triggered by Bot. Commit: |
|
PR_Github #24779 [ run ] completed with state |
|
/bot run |
|
PR_Github #24863 [ run ] triggered by Bot. Commit: |
|
PR_Github #24863 [ run ] completed with state |
|
/bot run |
|
PR_Github #25455 [ run ] triggered by Bot. Commit: |
|
PR_Github #25455 [ run ] completed with state |
|
/bot run |
|
PR_Github #25499 [ run ] triggered by Bot. Commit: |
|
PR_Github #25499 [ run ] completed with state |
|
/bot run |
|
PR_Github #25526 [ run ] triggered by Bot. Commit: |
|
PR_Github #25526 [ run ] completed with state |
|
/bot run |
|
PR_Github #25554 [ run ] triggered by Bot. Commit: |
|
PR_Github #25554 [ run ] completed with state |
Signed-off-by: Eran Geva <19514940+MrGeva@users.noreply.github.com>
|
/bot run |
|
PR_Github #25580 [ run ] triggered by Bot. Commit: |
|
PR_Github #25580 [ run ] completed with state |
|
/bot run |
|
PR_Github #25607 [ run ] triggered by Bot. Commit: |
|
PR_Github #25607 [ run ] completed with state |
|
/bot run |
1 similar comment
|
/bot run |
|
PR_Github #25672 [ run ] triggered by Bot. Commit: |
|
PR_Github #25673 [ run ] triggered by Bot. Commit: |
|
PR_Github #25672 [ run ] completed with state |
|
@lucaslie can you please approve it? |
|
PR_Github #25673 [ run ] completed with state |
Passing the allreduce strategy param:
This change makes allreduce_strategy a mandatory parameter throughout the AutoDeploy sharding pipeline. The strategy is configured in the detect_sharding transform YAML config, which sets it on the ShardingConfig. Since ShardingTransformInfo instances are immutable (frozen Pydantic models) and created without the strategy at ~10 call sites, I implemented automatic injection: when transforms are added via ShardingConfig.add(), it uses model_dump() to re-instantiate them with the strategy injected from the parent config. All custom ops (torch_dist_all_reduce, fused_linear_all_reduce, fused_fp8_linear_all_reduce) now require the strategy parameter (no defaults), and runtime validation checks ensure it's never None when helper functions execute. All direct .append() calls were replaced with .add() calls to trigger the injection mechanism.
Summary by CodeRabbit
New Features
Configuration
allreduce_strategyparameter to sharding and operation configurations.Improvements
Tests
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.
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.