collnet: size shared collNet comm arrays by NCCL_MAX_NETDEVS - #2262
Open
EylonKrause wants to merge 1 commit into
Open
collnet: size shared collNet comm arrays by NCCL_MAX_NETDEVS#2262EylonKrause wants to merge 1 commit into
EylonKrause wants to merge 1 commit into
Conversation
struct sharedResources sized collNetListenComms / collNetComms by MAXCHANNELS (64) but indexes them by netDev, which ranges up to NCCL_MAX_NETDEVS (128) -- the same domain used by the adjacent commRefCount, the sibling proxyAppend[2*NCCL_MAX_NETDEVS], and regular-net netComms[NCCL_MAX_NETDEVS]. On a host where the selected collnet netDev index is >= 64 this reads/writes past the arrays into neighbouring fields. Size both arrays by NCCL_MAX_NETDEVS to match their index domain. Signed-off-by: EylonKrause <eylon1909@gmail.com>
Author
|
Disclosure: this contribution was authored with an AI coding assistant (Claude) and reviewed before submission. |
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.
Description
In the collnet transport,
struct sharedResourcessizescollNetListenCommsandcollNetCommsbyMAXCHANNELS(64), but indexes them bynetDev, which ranges over[0, NCCL_MAX_NETDEVS)(128). The samenetDevindexes the adjacentcommRefCount[NCCL_MAX_NETDEVS]in the very same struct, the siblingncclCollNetSharedRes::proxyAppend[2*NCCL_MAX_NETDEVS], and the regular-netncclProxyProgressState::netComms[NCCL_MAX_NETDEVS]— all sized byNCCL_MAX_NETDEVS. So on a host where the selected collnetnetDevindex is>= 64,sharedListen/sharedConnect/sharedFreeread and writecollNetComms[netDev]/collNetListenComms[netDev]past the end of the 64-element arrays, into the neighbouringcommRefCountfield and beyond — a heap out-of-bounds access, not a clean assert.Related Issues
None.
Changes & Impact
src/transport/coll_net.cc(struct sharedResources): sizecollNetListenCommsandcollNetCommsbyNCCL_MAX_NETDEVS, matching theirnetDevindex domain (andcommRefCount/proxyAppend/netComms). ThencclCalloc-allocated struct grows by ~1 KB; indices 0–63 are byte-identical, only the previously-out-of-bounds 64–127 range is now valid storage. Non-breaking.Performance Impact
None.
Testing
make src.build;all_reduce_perfregression:Out of bounds values : 0 OK.static_assert(NCCL_MAX_NETDEVS <= MAXCHANNELS)would fail to compile) and from the three sibling arrays keyed on the samenetDev. The overrun only triggers with >64 collnet-capable NICs on one host, which cannot be reproduced on a single-GPU machine.