Skip to content

Fix lost rank output in the distributed launcher - #4615

Merged
zcbenz merged 6 commits into
ml-explore:mainfrom
tc3oliver:fix/launch-drain-rank-output
Oct 10, 2026
Merged

zcbenz merged 6 commits into
ml-explore:mainfrom
tc3oliver:fix/launch-drain-rank-output

Conversation

@tc3oliver

Copy link
Copy Markdown
Contributor
  • ☑️ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure: I used Claude Code to find the cause, write the patch and the test. I reviewed and ran everything myself.

The reader thread in _launch_with_io exits as soon as p.poll() reports the rank is done, which can drop output still buffered in the pipe. This caused intermittent missing output in oMLX CI.

The fix drains both pipes to EOF after the loop. Reads remain non-blocking, so it won't hang if a pipe is still open.

The test delays launcher reads so ranks can write their final line and exit first. It fails on main and passes 10/10 with the fix. Tested on macOS with the ring backend on 127.0.0.1; ssh was not tested.

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of duplicating the read code, I think we should just keep reading until error happens, there is no need to check p.poll().

@zcbenz zcbenz added the await response This pull request is waiting for response from the author. label Oct 7, 2026
@tc3oliver

Copy link
Copy Markdown
Contributor Author

Updated to use a single read loop. Kept p.poll() because EOF doesn't always mean the process has exited, and child processes can keep pipes open.

Local ring tests pass. I also tested SSH manually between two Macs using bash ranks. With delayed reads, main loses output, but not with this patch.

Could a maintainer approve the CI run?

@tc3oliver
tc3oliver requested a review from zcbenz October 9, 2026 16:04
@zcbenz zcbenz removed the await response This pull request is waiting for response from the author. label Oct 10, 2026
@tc3oliver

Copy link
Copy Markdown
Contributor Author

Fixed the CI test failures. Windows now skips the launcher tests, and the two timing-sensitive tests use file synchronization instead of sleeps.

Ruff passes. Tested 10/10 on macOS and 8/8 on Linux aarch64.

tc3oliver and others added 6 commits October 10, 2026 15:00
The reader thread stops as soon as poll() reports the process has exited.
Output the process wrote after the last select() is still in the pipe and
was dropped, so a rank that prints its result and exits right away could
lose it, more often on a loaded machine. Read the pipes to EOF after the
loop.
The launcher's reads are slowed so each rank prints its last line and exits
while the reader thread is still busy; the test fails on the previous
launcher and passes with the drain.
@zcbenz
zcbenz force-pushed the fix/launch-drain-rank-output branch from d514775 to 32bf7aa Compare October 10, 2026 06:02
@zcbenz
zcbenz merged commit 06eb748 into ml-explore:main Oct 10, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants