fix: skip CUDA_DEVICE_MAX_CONNECTIONS check on non-CUDA platforms - #1288
Open
kolinweiwei wants to merge 1 commit into
Open
kolinweiwei wants to merge 1 commit into
kolinweiwei wants to merge 1 commit into
Conversation
Training with tensor/context parallelism fails on non-NVIDIA hardware
(e.g. Moore Threads MUSA) with:
AssertionError: Using tensor model parallelism or context parallelism
require setting the environment variable CUDA_DEVICE_MAX_CONNECTIONS to 1
CUDA_DEVICE_MAX_CONNECTIONS is an NVIDIA CUDA driver environment variable.
Other runtimes (MUSA, CANN, ...) do not read it, so setting it there has no
effect and the assertion only blocks startup without providing any benefit.
The guarding condition also relies on get_device_arch_version(), which returns
the raw device property `major`. That value only carries NVIDIA
compute-capability semantics (8: Ampere, 9: Hopper, 10: Blackwell) on CUDA. On
other platforms it belongs to an unrelated numbering scheme, so comparing it
against 10 is not meaningful and happens to fall through to the CUDA-only
branch.
Gate the whole block on cur_platform.name() == "cuda", matching the existing
platform-dispatch idiom used elsewhere in the repo (e.g. train_gr00t_n1_5.py).
Note that platform.name() rather than device_name() is required here, since
some backends deliberately report "cuda" as their device name to reuse
PyTorch's CUDA dispatch path.
Behaviour on CUDA is unchanged.
kolinweiwei
requested review from
aoyulong,
heavyrain-lzy and
zhaoyinglia
as code owners
September 8, 2026 10:10
|
BAAI3315 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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.
PR Category
Hardware
PR Types
Bug Fixes
PR Description
Training with tensor parallelism or context parallelism fails during argument validation on non-NVIDIA hardware (reproduced on Moore Threads / MUSA):
Root cause
Two issues combine in the block at
arguments.py:1465-1491:CUDA_DEVICE_MAX_CONNECTIONSis NVIDIA-specific. It is a CUDA driver environment variable. Other runtimes (MUSA, CANN, ...) do not read it, so setting it on those platforms has no effect — the assertion blocks startup without buying anything. All three branches of the block (including the twowarn_rank_0paths) talk exclusively about this variable, so the entire block is CUDA-only, not just the assertion.get_device_arch_version()is not portable. It returns the raw device propertymajor, which only carries NVIDIA compute-capability semantics (8: Ampere, 9: Hopper, 10: Blackwell) on CUDA. On other platforms that value belongs to an unrelated numbering scheme, soget_device_arch_version() < 10is not a meaningful test there — it merely happens to be true, which is what lets non-CUDA hardware fall into the CUDA-only branch.Fix
Gate the whole block on
cur_platform.name() == "cuda". This matches the existing platform-dispatch idiom in the repo (train_gr00t_n1_5.py:85,train_pi.py:88, ...), andcur_platformis already imported inarguments.py:60.platform.name()is used rather thandevice_name()on purpose: some backends deliberately report"cuda"as their device name to reuse PyTorch's CUDA dispatch path (e.g.platform_txda.pyreturns"txda"fromname()but"cuda"fromdevice_name()), sodevice_name()would reintroduce the same misclassification.Behaviour on CUDA is unchanged — the condition only gains a platform check.
Notes
The workaround until this lands is to export
CUDA_DEVICE_MAX_CONNECTIONS=1on non-CUDA platforms as well, where it is a no-op that exists purely to satisfy the assertion.This also affects Ascend:
plugin_flagscale/npu_plugin.pyoverridesget_device_arch_version()to return8, which avoids reading a device property that may be unavailable, but8 < 10still holds — so NPU runs reach the same assertion.Related: #1287, #1286
Fixes #1289