Repository navigation
fix(pytorch): initialize tp_group_initialized in TransformerEngineBaseModule - #3860
Open
pcbeingused333 wants to merge 2 commits into
Open
pcbeingused333 wants to merge 2 commits into
pcbeingused333 wants to merge 2 commits into
Conversation
…eModule Linear with tp_size > 1 and no tp_group never called set_tensor_parallel_group, so the forward-time guard read an undefined attribute and raised AttributeError instead of the intended RuntimeError. Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
Contributor
[Medium impact] The change appears safe to merge. SummaryInitializes
Reviews (2) · Last reviewed commit: "Remove the tensor parallel group initial..." · Reviewed by Greptile |
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
ptrendx
approved these changes
Nov 14, 2026
Member
|
/te-ci pytorch |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3857
te.Linear(..., tp_size=2, tp_group=None)never callsset_tensor_parallel_group()(it only does so whentp_size == 1or a group is given), andTransformerEngineBaseModule.__init__never definestp_group_initialized. The forward-time guard inprepare_forwardtherefore reads an undefined attribute and raisesAttributeError: 'Linear' object has no attribute 'tp_group_initialized'instead of the intendedRuntimeError: Tensor parallel group not initialized. Call set_tensor_parallel_group() ....Initialize
tp_group_initialized = Falsenext totp_groupin the base module's__init__, so the existing guard works as designed.set_tensor_parallel_group()still flips it toTrue, so modules that set the group are unaffected.Testing and validation
Adds
test_linear_tp_group_not_set_raises_runtime_errorintests/pytorch/test_sanity.py, which builds aLinearwithtp_size=2, tp_group=Noneand asserts theRuntimeError. It needs one CUDA device and no process group.The new test was run on a single RTX 5060 Ti (torch 2.11 + cu128) against the Transformer Engine 2.21.0 wheel, whose
base.pyhas the same bug: without the one-line change it fails with theAttributeErrorfrom the issue; with it, the test passes. It was not run against a source build ofmain, so CI results should be relied on for that.AI assistance: This patch and its test were generated with Claude Code (AI-assisted).