plugin: set tunerPluginLoaded on the already-loaded path so refcount balances - #2261
Open
EylonKrause wants to merge 1 commit into
Open
plugin: set tunerPluginLoaded on the already-loaded path so refcount balances#2261EylonKrause wants to merge 1 commit into
EylonKrause wants to merge 1 commit into
Conversation
…balances When a tuner plugin is already loaded, ncclTunerPluginLoad takes the fast path: it sets comm->tuner and increments tunerPluginRefCount but did not set comm->tunerPluginLoaded. ncclTunerPluginUnload gates the decrement on that per-comm flag (if (comm->tunerPluginLoaded && 0 == --refCount)), so fast-path comms never decrement. With N comms sharing one tuner the count never reaches 0 and the plugin is never dlclose-d. Set the flag on the fast path, matching the first-load path. 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
ncclTunerPluginLoadhas two success paths. The first-load path setscomm->tuner, incrementstunerPluginRefCount, and setscomm->tunerPluginLoaded = 1. The "already loaded" fast path — taken by every subsequent communicator — setscomm->tunerand incrementstunerPluginRefCountbut does not setcomm->tunerPluginLoaded.ncclTunerPluginUnloadgates the decrement on that per-comm flag:Because
&&short-circuits, fast-path comms (flag == 0) never execute--tunerPluginRefCount. With N communicators sharing one tuner, the refcount is incremented N times but decremented at most once, so it never reaches 0: the plugin is neverdlclosed (it stays loaded for the life of the process) and the accounting is permanently skewed.Related Issues
None.
Changes & Impact
src/plugin/tuner.cc(ncclTunerPluginLoad): setcomm->tunerPluginLoaded = 1on the already-loaded fast path, matching the first-load path, so every comm that increments the refcount can also decrement it inncclTunerPluginUnload. The single-comm path is unaffected (it already set the flag). Non-breaking.Performance Impact
None.
Testing
make src.build;all_reduce_perfregression:Out of bounds values : 0 OK.tunerPluginRefCountreaches 0 (and the plugin is closed) only after this fix.