fix: rank=0 falsy-value in ParameterServer.__init__ - #99
Open
Jackie2049 wants to merge 1 commit into
Open
Conversation
`self._rank = rank or int(os.environ["RANK"])` evaluates `rank=0` as falsy, so a rank-0 process always falls back to the environment variable. If `RANK` is unset in that process, it raises `KeyError` instead of using the zero passed by the caller. Fix: use `rank if rank is not None else ...` — only fall back to the env when the caller explicitly passes `None`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
In
ParameterServer.__init__(),rank=0is falsy in Python, sorank or int(os.environ["RANK"])always evaluates to the environment variable. IfRANKis not set in the calling process (common in standalone/debug/test setups), aKeyErroris raised despite the caller explicitly passingrank=0.Fix
Replace the falsy
orguard with an explicitNonecheck:Key Change
checkpoint_engine/ps.pyrank or int(os.environ["RANK"])→rank if rank is not None else int(os.environ["RANK"])Testing
Unit tests for
rank=0,rank=None, andrank=5all pass on 8×RTX 4090 (56/56).