Skip to content

Fix gangs coordinator rank check - #1521

Open
joaopedroassad wants to merge 2 commits into
facebookresearch:mainfrom
joaopedroassad:fix-gangs-coordinator-rank-check
Open

Fix gangs coordinator rank check#1521
joaopedroassad wants to merge 2 commits into
facebookresearch:mainfrom
joaopedroassad:fix-gangs-coordinator-rank-check

Conversation

@joaopedroassad

Copy link
Copy Markdown

What does this PR do? Please describe:

Gangs.__post_init__ enforces that when root.rank == 0, the coordinator process must be rank 0 in every parallel gang. The check read:

if self.dp.rank != 0 or self.tp.rank != 0 and self.pp.rank != 0:

Since Python binds and tighter than or, this evaluates as dp.rank != 0 or (tp.rank != 0 and pp.rank != 0). As a result, a root.rank == 0 process that is non-zero in exactly one of the tensor- or pipeline-parallel gangs (for example tp.rank == 1, pp.rank == 0, or tp.rank == 0, pp.rank == 1) passes validation, contradicting the error message ("must be rank 0 in all parallel gangs"). This PR joins all three checks with or, adds parametrized regression tests, and adds a CHANGELOG entry.

No associated issue.

Does your PR introduce any breaking changes? If yes, please list them:

No. It only makes the validation reject coordinator configurations it was always meant to reject; valid configurations (rank 0 in every parallel gang) behave exactly as before.

Check list:

  • Was the content of this PR discussed and approved via a GitHub issue? No prior issue; this is a one-line logic-bug fix accompanied by a test.
  • Did you read the contributor guideline?
  • Did you make sure that your PR does only one thing instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? No documentation change is needed for this fix.
  • Did you write any new necessary tests? Added parametrized tests in tests/unit/test_gang.py covering the previously-accepted (tp=1, pp=0) and (tp=0, pp=1) coordinator configurations.
  • Did you verify new and existing tests pass locally with your changes? Verified the fix with a standalone reproduction of the check and ran isort / black / flake8 clean. The full pytest suite could not run locally because the native fairseq2n module has no macOS build; the new tests exercise the real Gangs class and run in CI.
  • Did you update the CHANGELOG?

@meta-cla

meta-cla Bot commented Jul 16, 2026

Copy link
Copy Markdown

Hi @joaopedroassad!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant