Repository navigation
Conversation
`debug_launcher` relies on three assumptions that only hold on Unix-like platforms, each of which stops it on Windows: * it starts the workers with `fork`, which Windows does not have (`ValueError: cannot find context for 'fork'`), * it hands the workers a `NamedTemporaryFile` path, but that file stays open in the parent process, so a spawned worker cannot open it (`PermissionError`), * it pins gloo to the `lo` interface, a name that only Unix-like platforms use (`RuntimeError: Unable to find address for: lo`). Pick the first start method torch actually offers, hand the workers a path inside a temporary directory instead of an open file handle, and only pin `lo` where that interface exists. Platforms that have both `fork` and `lo` behave exactly as before. The three tests added to `tests/test_launch.py` replace the process spawn and the interface listing, so they exercise the arguments and environment accelerate passes to its workers on every platform. Signed-off-by: CJstate <142857225+CJstate@users.noreply.github.com>
CJstate
added a commit
to CJstate/CJstate
that referenced
this pull request
Oct 2, 2026
Author
|
Small process note on CI: the five Could someone click "Approve and run workflows" when convenient? Until then the checks stay empty and the PR cannot be evaluated by the bot. Meanwhile the description has the local before/after evidence for the Windows |
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.
What does this PR do?
debug_launcheris meant to let a training script be debugged on CPU, but on Windows it cannot get as far as afirst step. Three things in it only hold on Unix-like platforms:
fork—start_processes(..., start_method="fork")raisesValueError: cannot find context for 'fork'onWindows, before a single worker starts.
tempfile.NamedTemporaryFile(), which keeps the file open in theparent process for the whole launch. Workers are started with
spawn, and a spawned worker cannot open a filethat is still open elsewhere, so
FileStorefails withPermissionError.gloo_socket_ifname="lo"—lois the Unix name of the loopback interface. On a platform that names itdifferently, gloo fails with
RuntimeError: Unable to find address for: lo.This PR:
torch.multiprocessingactually reports. That isforkwherever it exists, sobehaviour on Unix-like platforms is unchanged, and
spawnon Windows;TemporaryDirectoryinstead of an open file handle, lettingFileStorecreate the file in the workers themselves;
loonly when an interface with that name is present, and otherwise leaves gloo's own interface selectionalone, exactly as it does today whenever the variable is unset.
These three problems were reported together in #4285, which was closed unmerged; this PR fixes the same three
points and adds regression tests.
Tests
Three tests are added to
tests/test_launch.py. They replacetorch.multiprocessing.start_processesandsocket.if_nameindex, so they assert the start method, the rendezvous path and the interface pinning thataccelerate hands to its workers, and they run on any platform.
I reproduced all three failures on Windows (Python 3.13, torch 2.9.1): the
ValueErrorcomes out ofstart_processesitself, and thePermissionErrorout of a worker opening the rendezvous path. The tests failon the current
mainand pass with this change.A note on what is not covered: the new tests replace the process spawn, so they exercise the contract accelerate
controls rather than a full worker run. After these fixes the launch on my machine stops later inside gloo, which
refuses every interface it is offered on the Windows torch build I have — a limitation of that build rather than
of accelerate. The three failures fixed here all happen before, or independently of, gloo device selection.
Before submitting
Pull Request section?
to it if that's the case. — Not discussed beforehand; the problems themselves are from Make
debug_launcherwork on Windows #4285.documentation guidelines, and
here are tips on formatting docstrings.
The
debug_launcherdocstring now records thefork/spawndifference.Who can review?
Anyone in the community is free to review the PR once the tests have passed.
debug_launcheris a core part of the library: @BenjaminBossan @SunMarc