mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-03 01:55:12 +00:00
[misc] update pre-commit and run all files (#4752)
* [misc] update pre-commit * [misc] run pre-commit * [misc] remove useless configuration files * [misc] ignore cuda for clang-format
This commit is contained in:
@@ -8,7 +8,7 @@ from colossalai.testing import parameterize, rerun_if_address_is_in_use, spawn
|
||||
|
||||
def check_alpha_beta(rank, world_size, port, physical_devices):
|
||||
disable_existing_loggers()
|
||||
launch(config={}, rank=rank, world_size=world_size, host='localhost', port=port, backend='nccl')
|
||||
launch(config={}, rank=rank, world_size=world_size, host="localhost", port=port, backend="nccl")
|
||||
profiler = AlphaBetaProfiler(physical_devices)
|
||||
ab_dict = profiler.profile_ab()
|
||||
for _, (alpha, beta) in ab_dict.items():
|
||||
@@ -17,11 +17,11 @@ def check_alpha_beta(rank, world_size, port, physical_devices):
|
||||
|
||||
@pytest.mark.skip(reason="Skip because assertion fails for CI devices")
|
||||
@pytest.mark.dist
|
||||
@parameterize('physical_devices', [[0, 1, 2, 3], [0, 3]])
|
||||
@parameterize("physical_devices", [[0, 1, 2, 3], [0, 3]])
|
||||
@rerun_if_address_is_in_use()
|
||||
def test_profile_alpha_beta(physical_devices):
|
||||
spawn(check_alpha_beta, 4, physical_devices=physical_devices)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
test_profile_alpha_beta()
|
||||
|
@@ -27,8 +27,8 @@ def check_1d_device_mesh():
|
||||
|
||||
# checks
|
||||
assert device_mesh.shape == [4]
|
||||
assert len(device_mesh.get_process_group_for_all_axes().keys()) == 1, 'Expected 1 axis for the process group dict'
|
||||
assert device_mesh.get_process_group(axis=0) == process_group, 'Expected world process group'
|
||||
assert len(device_mesh.get_process_group_for_all_axes().keys()) == 1, "Expected 1 axis for the process group dict"
|
||||
assert device_mesh.get_process_group(axis=0) == process_group, "Expected world process group"
|
||||
assert device_mesh.is_initialized
|
||||
assert device_mesh.num_devices == 4
|
||||
assert device_mesh.is_initialized
|
||||
@@ -43,10 +43,10 @@ def check_2d_device_mesh():
|
||||
first_col_ranks = [0, 2]
|
||||
second_col_ranks = [1, 3]
|
||||
|
||||
first_row_pg = dist.new_group(first_row_ranks, backend='nccl')
|
||||
second_row_pg = dist.new_group(second_row_ranks, backend='nccl')
|
||||
first_col_pg = dist.new_group(first_col_ranks, backend='nccl')
|
||||
second_col_pg = dist.new_group(second_col_ranks, backend='nccl')
|
||||
first_row_pg = dist.new_group(first_row_ranks, backend="nccl")
|
||||
second_row_pg = dist.new_group(second_row_ranks, backend="nccl")
|
||||
first_col_pg = dist.new_group(first_col_ranks, backend="nccl")
|
||||
second_col_pg = dist.new_group(second_col_ranks, backend="nccl")
|
||||
|
||||
# check for
|
||||
current_rank = dist.get_rank()
|
||||
@@ -65,9 +65,9 @@ def check_2d_device_mesh():
|
||||
|
||||
# checks
|
||||
assert device_mesh.shape == [2, 2]
|
||||
assert len(device_mesh.get_process_group_for_all_axes().keys()) == 2, 'Expected 2 axes for the process group dict'
|
||||
assert device_mesh.get_process_group(axis=0) == col_pg, 'Expected column process group'
|
||||
assert device_mesh.get_process_group(axis=1) == row_pg, 'Expected row process group'
|
||||
assert len(device_mesh.get_process_group_for_all_axes().keys()) == 2, "Expected 2 axes for the process group dict"
|
||||
assert device_mesh.get_process_group(axis=0) == col_pg, "Expected column process group"
|
||||
assert device_mesh.get_process_group(axis=1) == row_pg, "Expected row process group"
|
||||
assert device_mesh.num_devices == 4
|
||||
assert device_mesh.is_initialized
|
||||
assert device_mesh.logical_mesh_id is None
|
||||
@@ -75,7 +75,7 @@ def check_2d_device_mesh():
|
||||
|
||||
|
||||
def check_init_from_process_group(rank, world_size, port):
|
||||
colossalai.launch(config={}, rank=rank, world_size=world_size, host='localhost', port=port, backend='nccl')
|
||||
colossalai.launch(config={}, rank=rank, world_size=world_size, host="localhost", port=port, backend="nccl")
|
||||
|
||||
|
||||
@pytest.mark.dist
|
||||
@@ -84,6 +84,6 @@ def test_device_mesh_from_process_group():
|
||||
spawn(check_init_from_process_group, 4)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
test_device_mesh()
|
||||
test_device_mesh_from_process_group()
|
||||
|
@@ -8,7 +8,7 @@ from colossalai.testing import parameterize, rerun_if_address_is_in_use, spawn
|
||||
|
||||
def check_extract_alpha_beta(rank, world_size, port, physical_devices):
|
||||
disable_existing_loggers()
|
||||
launch(config={}, rank=rank, world_size=world_size, host='localhost', port=port, backend='nccl')
|
||||
launch(config={}, rank=rank, world_size=world_size, host="localhost", port=port, backend="nccl")
|
||||
profiler = AlphaBetaProfiler(physical_devices)
|
||||
|
||||
mesh_alpha, mesh_beta = profiler.extract_alpha_beta_for_device_mesh()
|
||||
@@ -20,11 +20,11 @@ def check_extract_alpha_beta(rank, world_size, port, physical_devices):
|
||||
|
||||
@pytest.mark.skip(reason="Skip because assertion may fail for CI devices")
|
||||
@pytest.mark.dist
|
||||
@parameterize('physical_devices', [[0, 1, 2, 3], [0, 3]])
|
||||
@parameterize("physical_devices", [[0, 1, 2, 3], [0, 3]])
|
||||
@rerun_if_address_is_in_use()
|
||||
def test_profile_alpha_beta(physical_devices):
|
||||
spawn(check_extract_alpha_beta, 4, physical_devices=physical_devices)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
test_profile_alpha_beta()
|
||||
|
@@ -9,7 +9,7 @@ from colossalai.testing import rerun_if_address_is_in_use, spawn
|
||||
|
||||
|
||||
def check_layer(rank, world_size, port):
|
||||
launch(config={}, rank=rank, world_size=world_size, host='localhost', port=port, backend='nccl')
|
||||
launch(config={}, rank=rank, world_size=world_size, host="localhost", port=port, backend="nccl")
|
||||
|
||||
physical_mesh_id = torch.arange(0, 4)
|
||||
assert rank == dist.get_rank()
|
||||
@@ -33,5 +33,5 @@ def test_logical_pg():
|
||||
spawn(check_layer, 4)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
test_logical_pg()
|
||||
|
@@ -8,7 +8,7 @@ from colossalai.testing import parameterize, rerun_if_address_is_in_use, spawn
|
||||
|
||||
def check_alpha_beta(rank, world_size, port, physical_devices):
|
||||
disable_existing_loggers()
|
||||
launch(config={}, rank=rank, world_size=world_size, host='localhost', port=port, backend='nccl')
|
||||
launch(config={}, rank=rank, world_size=world_size, host="localhost", port=port, backend="nccl")
|
||||
profiler = AlphaBetaProfiler(physical_devices)
|
||||
best_logical_mesh = profiler.search_best_logical_mesh()
|
||||
|
||||
@@ -20,11 +20,11 @@ def check_alpha_beta(rank, world_size, port, physical_devices):
|
||||
|
||||
@pytest.mark.skip(reason="Skip because assertion may fail for CI devices")
|
||||
@pytest.mark.dist
|
||||
@parameterize('physical_devices', [[0, 1, 2, 3], [0, 3]])
|
||||
@parameterize("physical_devices", [[0, 1, 2, 3], [0, 3]])
|
||||
@rerun_if_address_is_in_use()
|
||||
def test_profile_alpha_beta(physical_devices):
|
||||
spawn(check_alpha_beta, 4, physical_devices=physical_devices)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
test_profile_alpha_beta()
|
||||
|
Reference in New Issue
Block a user