mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-04 10:34:41 +00:00
[test] refactor tests with spawn (#3452)
* [test] added spawn decorator * polish code * polish code * polish code * polish code * polish code * polish code
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
import torch.multiprocessing as mp
|
||||
|
||||
from colossalai.device import AlphaBetaProfiler
|
||||
from colossalai.initialize import launch
|
||||
from colossalai.logging import disable_existing_loggers
|
||||
from colossalai.testing import parameterize, rerun_if_address_is_in_use
|
||||
from colossalai.utils import free_port
|
||||
from colossalai.testing import parameterize, rerun_if_address_is_in_use, spawn
|
||||
|
||||
|
||||
def check_extract_alpha_beta(rank, physical_devices, world_size, port):
|
||||
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')
|
||||
profiler = AlphaBetaProfiler(physical_devices)
|
||||
@@ -27,12 +23,7 @@ def check_extract_alpha_beta(rank, physical_devices, world_size, port):
|
||||
@parameterize('physical_devices', [[0, 1, 2, 3], [0, 3]])
|
||||
@rerun_if_address_is_in_use()
|
||||
def test_profile_alpha_beta(physical_devices):
|
||||
world_size = 4
|
||||
run_func = partial(check_extract_alpha_beta,
|
||||
physical_devices=physical_devices,
|
||||
world_size=world_size,
|
||||
port=free_port())
|
||||
mp.spawn(run_func, nprocs=world_size)
|
||||
spawn(check_extract_alpha_beta, 4, physical_devices=physical_devices)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Reference in New Issue
Block a user