Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

import logging
import math
import shutil
from contextlib import nullcontext
from copy import deepcopy
Expand Down Expand Up @@ -211,6 +212,14 @@ def build_distributed_environment(mesh_dim_config: tuple):
"""
from torch.distributed.device_mesh import init_device_mesh

required_world_size = math.prod(mesh_dim_config)
world_size = torch.distributed.get_world_size()
if world_size < required_world_size:
pytest.skip(
f"This test requires {required_world_size} GPUs for mesh "
f"{mesh_dim_config}, but only {world_size} are available"
)

# Construct device mesh.
device_mesh = init_device_mesh(
"cuda", mesh_shape=mesh_dim_config, mesh_dim_names=(DP_OUTER, DP_SHARD, CP, TP)
Expand Down
Loading