pytorch/test
Rohit Singh Rathaur b558c986e8 Add regression test for get_root_mesh with multiple independent meshes (#164731)
Fixes #163330

I tried to reproduce the bug with my 4-GPU setup (the original issue used 8 GPUs). I created several different test scenarios, trying to trigger the bug by:
- creating two different device meshes
- slicing them in various ways
- checking if get_root_mesh() would get confused

but the bug didn't show up! Everything worked correctly in `2.10`. I found that there was a massive refactoring of the `DeviceMesh` code (PR #163213) that landed on October 2nd. That PR completely rewrote how `DeviceMesh` tracks relationships between parent meshes and submeshes using. It seems like this refactoring fixed the bug! But I added a regression test to make sure it doesn't come back. The test (`test_get_root_mesh_multiple_independent_meshes`) does exactly what the bug report described:
  - creates two independent meshes
  - slices them both
  - verifies that each submesh correctly points back to its real parent
  - makes sure submeshes from mesh1 don't incorrectly claim mesh2 as their parent

Pull Request resolved: https://github.com/pytorch/pytorch/pull/164731
Approved by: https://github.com/fduwjj
2025-10-06 18:52:25 +00:00
..
ao/sparsity Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
autograd
backends/xeon
benchmark_utils [BE][3/6] fix typos in test/ (#157637) 2025-07-17 12:08:33 +00:00
compiled_autograd_skips [ca] skip on some PYTORCH_TEST_WITH_DYNAMO=1 autograd tests (#156374) 2025-06-21 18:33:38 +00:00
cpp Migrate DeviceType to torch/headeronly (#163999) 2025-09-30 23:13:27 +00:00
cpp_api_parity [BE][PYFMT] migrate PYFMT for test/[a-h]*/ to ruff format (#144555) 2025-06-24 04:53:54 +00:00
cpp_extensions [OpenReg] Add AMP Integration guide for accelerators (#162050) 2025-09-30 12:27:11 +00:00
custom_backend [Cmake] Make PyTorch buildable by CMake-4.x (#150203) 2025-03-29 01:39:13 +00:00
custom_operator Using the latest torch.library.register_fake API instead of torch.library.impl_abstract (#158839) 2025-07-25 02:37:30 +00:00
distributed Add regression test for get_root_mesh with multiple independent meshes (#164731) 2025-10-06 18:52:25 +00:00
distributions [Reland][2/N]Port several test files under test/distributed to Intel GPU (#159473) 2025-09-17 06:42:27 +00:00
dynamo [dynamo] Support torch.fx.traceback.annotate (#164678) 2025-10-06 02:59:24 +00:00
dynamo_expected_failures Add a RECORD_FUNCTION for Python fallback so it shows in profile (#160573) 2025-10-01 14:10:44 +00:00
dynamo_skips Add functions to setup PrivateUse1 as a python backend device. (#157859) 2025-10-01 21:32:59 +00:00
error_messages
expect [fx] Allow customization of submod name in split graph (#164035) 2025-10-01 16:26:14 +00:00
export [export] Better state_dict and constant dedup in torch.export.save (#164196) 2025-10-06 17:03:15 +00:00
forward_backward_compatibility Fused RMSNorm implementation (#153666) 2025-07-22 22:25:44 +00:00
functorch Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
fx Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
higher_order_ops [hop] support local_map + SAC (#163322) 2025-09-24 04:57:40 +00:00
inductor Limit path search within range (#164581) 2025-10-06 18:29:27 +00:00
inductor_expected_failures [dynamo] Graph break on on user-defined class in compiled region (#161670) 2025-09-10 04:39:20 +00:00
inductor_skips
jit Revert "Support setting grad_dtype on leaf tensors (#162815)" 2025-10-03 23:14:28 +00:00
jit_hooks [Cmake] Make PyTorch buildable by CMake-4.x (#150203) 2025-03-29 01:39:13 +00:00
lazy [BE][PYFMT] migrate PYFMT for test/[i-z]*/ to ruff format (#144556) 2025-07-29 03:26:09 +00:00
mobile Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
nn [ROCm][CI] test_convolution.py uses miopen immediate mode (#164598) 2025-10-06 17:48:50 +00:00
onnx Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
optim [optim] prevent unintended aliasing in lr_scheduler; update type annotations/docs (#163120) 2025-09-25 06:58:58 +00:00
package [Torch Package] Make get names of OrderedImporters support fallback to importers (#155743) 2025-08-06 02:26:10 +00:00
profiler Add a RECORD_FUNCTION for Python fallback so it shows in profile (#160573) 2025-10-01 14:10:44 +00:00
quantization Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
scripts [BE][PYFMT] migrate PYFMT for test/[i-z]*/ to ruff format (#144556) 2025-07-29 03:26:09 +00:00
strobelight/examples Enable strobelight profiling specific compile frame ids using COMPILE_STROBELIGHT_FRAME_FILTER (#147549) 2025-02-22 03:44:53 +00:00
test_img
torch_np Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
typing Revert "Add __init__.pyi to torch/linalg (#160750)" 2025-09-02 16:53:55 +00:00
xpu [WOQ] Add XPU kernel for _weight_int8pack_mm (#160938) 2025-09-19 07:37:14 +00:00
_test_bazel.py
allowlist_for_publicAPI.json Clean up 'torch.onnx' entries from public API allowlist (#162850) 2025-09-15 16:14:43 +00:00
bench_mps_ops.py [BE] Remove macos-13 guard from bench_mps_ops (#159732) 2025-08-03 20:53:58 +00:00
conftest.py Stop parsing command line arguments every time common_utils is imported. (#156703) 2025-10-02 22:22:04 +00:00
create_dummy_torchscript_model.py
HowToWriteTestsUsingFileCheck.md
linear.py
load_torchscript_model.py
minioptest_failures_dict.json
mkl_verbose.py
mkldnn_verbose.py
pytest_shard_custom.py
run_doctests.sh
run_test.py Add functions to setup PrivateUse1 as a python backend device. (#157859) 2025-10-01 21:32:59 +00:00
simulate_nccl_errors.py [BE]: Update ruff to 0.11.8 (#153249) 2025-05-12 18:30:52 +00:00
slow_tests.json Update slow tests (#164726) 2025-10-06 12:57:29 +00:00
test_accelerator.py Add UT for torch.accelerator memory-related API (#155200) 2025-08-08 17:41:22 +00:00
test_ao_sparsity.py [testing] Add test owner labels for some ao sparse tests (#163203) 2025-09-18 16:08:13 +00:00
test_appending_byte_serializer.py Check integrity of bytes in AppendingByteSerializer (#152139) 2025-04-26 18:10:58 +00:00
test_autocast.py
test_autograd_fallback.py Fix TestAutogradFallback flaky tests under Dynamo: migrate to lib._destroy() (#159443) 2025-07-30 19:30:55 +00:00
test_autograd.py Add pure view support in autograd Function (#164736) 2025-10-06 18:21:05 +00:00
test_autoload.py
test_binary_ufuncs.py [TEST][CUDA] Use proper dtype in test_cuda_tensor_pow_scalar_tensor_cuda (#163070) 2025-09-16 18:28:50 +00:00
test_bundled_images.py Add __main__ guards to tests (#154716) 2025-06-04 14:38:13 +00:00
test_bundled_inputs.py Add pyrefly suppressions (3/n) (#164588) 2025-10-03 22:03:03 +00:00
test_ci_sanity_check_fail.py
test_comparison_utils.py
test_compile_benchmark_util.py
test_complex.py Add pyrefly suppressions (3/n) (#164588) 2025-10-03 22:03:03 +00:00
test_content_store.py [ROCm] Enabling several UTs (#161715) 2025-09-09 15:49:21 +00:00
test_cpp_api_parity.py Revert "Stop parsing command line arguments every time common_utils is imported. (#156703)" 2025-08-04 20:37:39 +00:00
test_cpp_extensions_aot.py Replace setup.py install with pip install (#156711) 2025-09-29 15:15:10 +00:00
test_cpp_extensions_jit.py [MPSHooks] Release pending command encoder (#164093) 2025-09-29 17:50:12 +00:00
test_cpp_extensions_mtia_backend.py Revert "Generalize poison fork logic for each device backend (#144664)" 2025-04-10 21:02:14 +00:00
test_cpp_extensions_stream_and_event.py [Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event (#151404) 2025-04-25 20:15:04 +00:00
test_cuda_expandable_segments.py
test_cuda_multigpu.py [ROCm] Enabling several UTs (#161715) 2025-09-09 15:49:21 +00:00
test_cuda_nvml_based_avail.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_cuda_primary_ctx.py [ROCm][CI] skip TestCudaPrimaryCtx.test_set_device_0 (#163693) 2025-09-23 22:15:10 +00:00
test_cuda_sanitizer.py
test_cuda_trace.py
test_cuda.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_custom_ops.py Add utility to get computed kernel in torch.library (#158393) 2025-08-13 21:00:59 +00:00
test_dataloader.py Skip test_ind_worker_queue on Windows and macOS (flaky) (#162555) 2025-09-10 07:05:14 +00:00
test_datapipe.py [BC breaking] Remove deprecated imports for torch.utils.data.datapipes.iter.grouping (#163438) 2025-09-23 05:02:06 +00:00
test_decomp.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_determination.py
test_dispatch.py Typo fixes for "overridden" in comments and function names (#155944) 2025-06-14 03:37:38 +00:00
test_dlpack.py Upgrades dlpack to v1.1 to include fp8/fp4 (#162195) 2025-09-17 16:39:11 +00:00
test_dynamic_shapes.py remove no longer needed torch._check_is_size calls from test_dynamic_shapes (#164627) 2025-10-04 22:06:04 +00:00
test_expanded_weights.py Revert "Stop parsing command line arguments every time common_utils is imported. (#156703)" 2025-08-04 20:37:39 +00:00
test_extension_utils.py
test_fake_tensor.py [FakeTensor] Supplement the relevant logic for converting conv1d to conv2d in meta_conv (#160408) 2025-09-26 15:45:02 +00:00
test_file_check.py
test_flop_counter.py [ROCm] Transformer/SDPA unit test parity (#163745) 2025-09-25 17:14:19 +00:00
test_foreach.py Fix requires_cuda to requires_cuda_and_triton (#160222) 2025-08-10 07:05:52 +00:00
test_function_schema.py
test_functional_autograd_benchmark.py
test_functional_optim.py
test_functionalization_of_rng_ops.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_functionalization.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_futures.py
test_fx_experimental.py [fx] fix split_module with symint (#160093) 2025-08-13 05:50:15 +00:00
test_fx_passes.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_fx_reinplace_pass.py [dynamic shapes] avoid unnecessary slices (#157528) 2025-07-10 06:34:46 +00:00
test_fx.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_hop_infra.py Support torch.compile rng selective activation checkpointing with cudagraph (#146878) 2025-02-28 00:47:03 +00:00
test_hub.py Add __main__ guards to tests (#154716) 2025-06-04 14:38:13 +00:00
test_import_stats.py
test_indexing.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_itt.py
test_jit_autocast.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_jit_disabled.py
test_jit_fuser_legacy.py Stop parsing command line arguments every time common_utils is imported. (#156703) 2025-10-02 22:22:04 +00:00
test_jit_fuser_te.py Stop parsing command line arguments every time common_utils is imported. (#156703) 2025-10-02 22:22:04 +00:00
test_jit_fuser.py Stop parsing command line arguments every time common_utils is imported. (#156703) 2025-10-02 22:22:04 +00:00
test_jit_legacy.py Stop parsing command line arguments every time common_utils is imported. (#156703) 2025-10-02 22:22:04 +00:00
test_jit_llga_fuser.py
test_jit_profiling.py
test_jit_simple.py
test_jit_string.py
test_jit.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_jiterator.py
test_kernel_launch_checks.py [testing] Add test owner labels for some cuda? tests (#163296) 2025-09-26 18:26:56 +00:00
test_legacy_vmap.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_license.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_linalg.py Enable several unit tests on ROCm (#163087) 2025-10-03 19:30:59 +00:00
test_logging.py
test_masked.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_maskedtensor.py Fix MaskedTensor to device ignored mask (#151205) 2025-07-21 21:44:49 +00:00
test_matmul_cuda.py Revert "[CUDA] Add experimental green context support for SM carveout (#159104)" 2025-10-03 20:15:56 +00:00
test_meta.py [Inductor] support mixed dtype in the native_layer_norm_backward meta function (#159830) 2025-09-17 20:29:12 +00:00
test_metal.py
test_mkl_verbose.py
test_mkldnn_fusion.py
test_mkldnn_verbose.py
test_mkldnn.py Enable TF32 as fp32 internal precision for matmul/linear/conv (#157520) 2025-07-17 08:57:34 +00:00
test_mobile_optimizer.py
test_model_exports_to_core_aten.py Replace export_for_training with export (#162396) 2025-09-10 14:19:34 +00:00
test_module_tracker.py
test_modules.py [ROCm][CI] unskip some test_memory_format tests (#162766) 2025-09-12 15:02:40 +00:00
test_monitor.py
test_mps.py [MPS] Add backward pass for embedding_bag (#163931) 2025-10-03 00:48:38 +00:00
test_multiprocessing_spawn.py Test multiprocessing spawn timing fix (#160672) 2025-08-15 00:11:55 +00:00
test_multiprocessing.py Revert "[CI] Use setup-python from for Mac tests (#155698)" 2025-06-12 14:42:32 +00:00
test_namedtensor.py Fix tensor creation with empty names crash (#163957) 2025-09-26 17:41:00 +00:00
test_namedtuple_return_api.py
test_native_functions.py
test_native_mha.py
test_nestedtensor.py Fix NestedTensor max/min operations for integer dtypes. (#162273) 2025-10-02 18:46:27 +00:00
test_nn.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_nnapi.py
test_numa_binding.py Revert "[RELAND] Always build USE_DISTRIBUTED (#160449) and Make distributed modules importable even when backend not built (#159889) (#162594)" 2025-09-25 13:47:46 +00:00
test_numba_integration.py [testing] Add test owner labels for some cuda? tests (#163296) 2025-09-26 18:26:56 +00:00
test_numpy_interop.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_opaque_obj.py [opaque_obj] Add set_payload + docs (#163276) 2025-09-22 20:02:29 +00:00
test_openmp.py
test_ops_fwd_gradients.py
test_ops_gradients.py Enable more nightly tests on s390x (#148452) 2025-03-18 16:09:39 +00:00
test_ops_jit.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_ops.py [1/N]Enable some tests in test_ops.TestCommon on Intel GPU (#159944) 2025-09-29 09:08:04 +00:00
test_optim.py Fix LBFGS wolfe max iteration (#161488) 2025-09-16 12:07:50 +00:00
test_out_dtype_op.py
test_overrides.py Revert "[Reland] Use std::string_view in torchgen (#158625)" 2025-09-13 07:52:50 +00:00
test_package.py
test_per_overload_api.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_prims.py [Bugfix] Match eager stride semantics for cloned tensors with preserve_format in compile (#163017) 2025-09-19 19:41:33 +00:00
test_privateuseone_python_backend.py Add functions to setup PrivateUse1 as a python backend device. (#157859) 2025-10-01 21:32:59 +00:00
test_proxy_tensor.py remove more no longer needed torch._check_is_size calls 1 (#164630) 2025-10-04 22:06:04 +00:00
test_pruning_op.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_public_bindings.py Revert "[CUDA] Add experimental green context support for SM carveout (#159104)" 2025-10-03 20:15:56 +00:00
test_python_dispatch.py Remove guard_size_oblivious from default contiguity python check, and add aten.sym_is_contiguous. [attempt2] (#160869) 2025-09-08 22:59:13 +00:00
test_pytree.py [BE][pytree] cleanup parameterized pytree tests (#160842) 2025-09-05 20:15:29 +00:00
test_quantization.py Remove pytorch quant docs since we are moving to torchao (#157766) 2025-07-11 03:21:47 +00:00
test_reductions.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_rename_privateuse1_to_existing_device.py [Device] Add support for PrivateUse1 device type in parse_type function (#157609) 2025-07-17 01:27:44 +00:00
test_scaled_matmul_cuda.py MX: Remove redundant PLATFORM_SUPPORTS_MX_GEMM constant (#164320) 2025-10-02 23:30:56 +00:00
test_scatter_gather_ops.py fix deterministic scatter_add path for multi-d tensors (#162866) 2025-09-15 06:50:00 +00:00
test_schema_check.py [inductor] slow test some Windows UTs. (#160267) 2025-08-10 18:35:42 +00:00
test_segment_reductions.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_serialization.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_set_default_mobile_cpu_allocator.py
test_shape_ops.py [Quant] flip: throw runtime error for QUInt4x2 and QUInt2x4 input (#147430) 2025-02-25 03:47:40 +00:00
test_show_pickle.py
test_sort_and_select.py Add dtype checks in meta dispatch for various ordering ops (#159556) 2025-08-14 17:06:27 +00:00
test_sparse_csr.py [Fix] Adding missing f prefixes to formatted strings [4/N] (#164068) 2025-09-29 04:07:07 +00:00
test_sparse_semi_structured.py Remove test conditions for CUDA<12 (#163495) 2025-09-23 07:52:00 +00:00
test_sparse.py [MPS] [Sparse] unique_dim and sparse broadcast (#163694) 2025-09-26 23:03:13 +00:00
test_spectral_ops.py fix numpy compatibility for 2d small list indices (#154806) 2025-06-04 01:58:52 +00:00
test_stateless.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_static_runtime.py
test_subclass.py
test_sympy_utils.py [1/N] Apply UP035 rule in tests (#163947) 2025-09-29 01:42:01 +00:00
test_tensor_creation_ops.py Revert "Enable all SIM rules except disabled ones (#164645)" 2025-10-05 19:32:21 +00:00
test_tensorboard.py Fix protobuf test comparison by parsing proto instead of raw strings (#162644) 2025-09-12 16:26:54 +00:00
test_tensorexpr_pybind.py
test_tensorexpr.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_testing.py [1/N] Apply UP035 rule in tests (#163947) 2025-09-29 01:42:01 +00:00
test_throughput_benchmark.py
test_torch.py [cuBLAS] update cuBLAS determinism docs, remove workspace requirement checks (#161749) 2025-10-03 00:09:47 +00:00
test_torchfuzz_repros.py [torchfuzz] check in some more xfail repros (#164619) 2025-10-06 16:20:44 +00:00
test_transformers.py [cuDNN][SDPA] Disable dropout for cuDNN SDPA on 9.11 - 9.13 (#163903) 2025-09-26 23:50:09 +00:00
test_type_hints.py Add pyrefly suppressions (3/n) (#164588) 2025-10-03 22:03:03 +00:00
test_type_info.py Add pyrefly suppressions (3/n) (#164588) 2025-10-03 22:03:03 +00:00
test_type_promotion.py [BE] Raise ValueError from torch.cat meta func (#158249) 2025-07-20 23:49:18 +00:00
test_typing.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_unary_ufuncs.py [BUG] Fix nonzero_static crash on CUDA when the input is a empty tensor (#162578) 2025-09-15 05:44:15 +00:00
test_utils_config_module.py
test_utils_filelock.py
test_utils.py Revert "Add device argument to torch.random.get_rng_state (#163034)" 2025-10-04 15:25:45 +00:00
test_view_ops.py unify broadcast_shapes functions and avoid duplicates (#160251) 2025-08-16 00:54:32 +00:00
test_vulkan.py
test_weak.py [BE][2/6] fix typos in test/ (test/test_*.py) (#157636) 2025-07-09 11:02:23 +00:00
test_xnnpack_integration.py
test_xpu.py Add a new API torch.xpu.can_device_access_peer for Intel GPU (#162705) 2025-09-16 18:00:22 +00:00