Repository navigation
Conversation
torch 2.11's destroy_process_group reads _world.comms, and that release's ThreadLocalWorld (the world of the threaded test backend) has no such attribute. Every thread of a threaded test therefore raises AttributeError in the finally of run_test_with_threaded_pg, after the test body. That fails no test: torch only prints the tracebacks. With the 128 threads of TestFullyShardCollectiveOps printing at once, the interpreter has segfaulted inside the traceback printer, which is the intermittent failure of test_fully_shard_collective_ops in the nightly (exit -11). sitecustomize gives ThreadLocalWorld the attribute when it is missing, so a torch that has it is left alone. The wrapper now also fails on a thread that raised outside its test body, which until now showed up only as a traceback in the captured stderr of a passing run. Co-Authored-By: Claude Code <noreply@anthropic.com>
This branch has not been deployed
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.
test_fully_shard_collective_opsfails intermittently in the nightly with exit code -11: run 45654740589 on 2026-11-25 and run 43735884533 on 2026-11-15, 2 of the last 12 nightlies, on the same image digest as the green runs between them. The three commits between the last green nightly and the 11-25 failure touch none ofmiles/backends/fsdp_utils,tests/fast-gpuand the image.What
torch_ported/sitecustomize.pygives torch'sThreadLocalWorldacommsproperty when it has none._run_ported_testfails when the captured stderr holdsException in thread.Why
destroy_process_groupreads_world.comms(distributed_c10d.py:2310).ThreadLocalWorld, the world of the threaded test backend, has no such attribute in v2.11.0; pytorchmainhas added it.AttributeError: 'ThreadLocalWorld' object has no attribute 'comms'in thefinallyofrun_test_with_threaded_pg, after the test body. That fails no test; torch only prints the tracebacks, and it also skipsperThreadTearDown().TestFullyShardCollectiveOpsruns 128 threads. The failing subprocess died inside the traceback printer (_PyErr_Display→_PyTraceBack_Print_Indented→PyFrame_GetCode) while they printed. Why CPython crashes there was not investigated; the fix removes the exceptions that are being printed.destroy_process_groupshould see. The property is added only when missing, so a torch that has it is left alone.Validation
MultiThreadedTestCase(8 threads, oneall_reduce) without the shimOK, with thecommsAttributeErrortracebacks on stderrsitecustomize.py, minus its two Miles-patch lines (milesis not importable on that machine)OK, stderr holds noException in threadpre-commiton the two filesNot executed: the three ported tests themselves, which need CUDA. Their first run with this change is this PR's CI (
run-ci-torch). The new assertion also coverstest_fully_shard_mixed_precisionandtest_fully_shard_frozen; whether either prints a thread traceback today is not known until that run.Files
tests/fast-gpu/backends/fsdp_utils/torch_ported/sitecustomize.py: thecommsproperty.tests/fast-gpu/backends/fsdp_utils/torch_ported/test_upstream_fsdp.py: the stderr assertion.Checklist
pre-commitpasses on the changed files (--all-filesnot run)pytest -xis green: not run, the touched tests need CUDA; see Validation🤖 Generated with Claude Code