Give each host a unique rank in Hostfile.from_list - #4027
Merged
Conversation
The repeats loop reused the name of the enumerate index, so every Host was constructed with the repeat counter instead of its position in the list: with the default repeats=1 every host got rank 0. Track the rank with the running length of the list, matching from_file.
zcbenz
approved these changes
Aug 6, 2026
krystophny
pushed a commit
to krystophny/mlx-jaccl-fix-small-recv
that referenced
this pull request
Aug 7, 2026
krystophny
pushed a commit
to krystophny/mlx-jaccl-fix-small-recv
that referenced
this pull request
Aug 7, 2026
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.
Proposed changes
Hostfile.from_listbuilds everyHostwith the wrong rank. The innerrepeatsloop reuses the name of theenumerateindex:so the value passed to
Hostis the repeat counter, never the position in the list. With the defaultrepeats=1the range is alwaysrange(1), so every host gets rank 0.from_file, the sibling constructor, assignsHost(i, ...)straight fromenumerate, so a unique sequential rank is clearly the intent.Repro
Using the running length of the list keeps ranks unique across repeats too.
Scope
To be upfront: nothing reads
Host.ranktoday, so this is latent rather than a live failure — I found it while reading the launcher, not from a bug report. It is still a wrong value on a public dataclass field thatfrom_filepopulates correctly, so it seemed worth correcting before something starts depending on it. Close it if you would rather leave the field alone.Behaviour that is unchanged: empty hostnames still raise, and literal IPs are still detected and stored in
ips.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes