diff --git a/tests/fast-gpu/backends/fsdp_utils/torch_ported/sitecustomize.py b/tests/fast-gpu/backends/fsdp_utils/torch_ported/sitecustomize.py index aec6dc2b4..215246767 100644 --- a/tests/fast-gpu/backends/fsdp_utils/torch_ported/sitecustomize.py +++ b/tests/fast-gpu/backends/fsdp_utils/torch_ported/sitecustomize.py @@ -1,6 +1,12 @@ import torch +from torch.testing._internal.distributed.multi_threaded_pg import ThreadLocalWorld from miles.backends.fsdp_utils.monkey_patches.fsdp_param_dtype_patch import apply_param_dtype_map_patch apply_param_dtype_map_patch() torch.use_deterministic_algorithms(True) + +# torch 2.11's destroy_process_group reads _world.comms, which that release's threaded test world lacks: every thread +# of a threaded test raises in its teardown, and the interpreter has segfaulted while they printed their tracebacks. +if not hasattr(ThreadLocalWorld, "comms"): + ThreadLocalWorld.comms = property(lambda self: []) diff --git a/tests/fast-gpu/backends/fsdp_utils/torch_ported/test_upstream_fsdp.py b/tests/fast-gpu/backends/fsdp_utils/torch_ported/test_upstream_fsdp.py index fc5abed3e..5e4b39405 100644 --- a/tests/fast-gpu/backends/fsdp_utils/torch_ported/test_upstream_fsdp.py +++ b/tests/fast-gpu/backends/fsdp_utils/torch_ported/test_upstream_fsdp.py @@ -36,6 +36,8 @@ def _run_ported_test(filename, *selectors): assert result.returncode == 0, result.stdout + result.stderr # site.py swallows sitecustomize errors, which would run the ported tests unpatched assert "Error in sitecustomize" not in result.stderr, result.stderr + # a thread that raises outside its test body fails no test; only its traceback shows it + assert "Exception in thread" not in result.stderr, result.stderr def test_fully_shard_mixed_precision():