mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-18 16:00:49 +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:
@@ -8,7 +8,7 @@ import colossalai
|
||||
from colossalai.autochunk.autochunk_codegen import AUTOCHUNK_AVAILABLE
|
||||
from colossalai.fx.graph_module import ColoGraphModule
|
||||
from colossalai.fx.passes.meta_info_prop import MetaInfoProp
|
||||
from colossalai.utils import free_port
|
||||
from colossalai.testing import free_port
|
||||
|
||||
if AUTOCHUNK_AVAILABLE:
|
||||
from colossalai.autochunk.autochunk_codegen import AutoChunkCodeGen
|
||||
|
@@ -9,7 +9,7 @@ from colossalai.autochunk.utils import flat_list
|
||||
from colossalai.core import global_context as gpc
|
||||
from colossalai.fx.graph_module import ColoGraphModule
|
||||
from colossalai.fx.passes.meta_info_prop import MetaInfoProp
|
||||
from colossalai.utils import free_port
|
||||
from colossalai.testing import free_port
|
||||
|
||||
if AUTOCHUNK_AVAILABLE:
|
||||
from colossalai.autochunk.autochunk_codegen import AutoChunkCodeGen
|
||||
|
@@ -1,10 +1,8 @@
|
||||
from functools import partial
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
import torch.fx
|
||||
import torch.multiprocessing as mp
|
||||
|
||||
try:
|
||||
from fastfold.model.nn.evoformer import EvoformerBlock
|
||||
@@ -15,6 +13,7 @@ except:
|
||||
from test_autochunk_alphafold_utils import run_test
|
||||
|
||||
from colossalai.autochunk.autochunk_codegen import AUTOCHUNK_AVAILABLE
|
||||
from colossalai.testing import clear_cache_before_run, parameterize, spawn
|
||||
|
||||
|
||||
def get_model():
|
||||
@@ -66,18 +65,19 @@ def get_chunk_target() -> Dict:
|
||||
not (AUTOCHUNK_AVAILABLE and HAS_REPO),
|
||||
reason="torch version is lower than 1.12.0",
|
||||
)
|
||||
@pytest.mark.parametrize("max_memory", [None, 20, 24])
|
||||
@pytest.mark.parametrize("data_args", [(32, 64)]) # (msa_len, pair_len)
|
||||
@clear_cache_before_run()
|
||||
@parameterize("max_memory", [None, 20, 24])
|
||||
@parameterize("data_args", [(32, 64)])
|
||||
def test_evoformer_block(data_args, max_memory):
|
||||
run_func = partial(
|
||||
spawn(
|
||||
run_test,
|
||||
1,
|
||||
data_args=data_args,
|
||||
max_memory=max_memory,
|
||||
get_model=get_model,
|
||||
get_data=get_data,
|
||||
get_chunk_target=get_chunk_target,
|
||||
)
|
||||
mp.spawn(run_func, nprocs=1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@@ -1,10 +1,8 @@
|
||||
from functools import partial
|
||||
from typing import List, Tuple
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
import torch.fx
|
||||
import torch.multiprocessing as mp
|
||||
|
||||
try:
|
||||
from fastfold.model.nn.evoformer import EvoformerStack
|
||||
@@ -15,6 +13,7 @@ except:
|
||||
from test_autochunk_alphafold_utils import run_test
|
||||
|
||||
from colossalai.autochunk.autochunk_codegen import AUTOCHUNK_AVAILABLE
|
||||
from colossalai.testing import clear_cache_before_run, parameterize, spawn
|
||||
|
||||
|
||||
def get_model():
|
||||
@@ -61,17 +60,18 @@ def get_data(msa_len: int, pair_len: int) -> Tuple[List, List]:
|
||||
not (AUTOCHUNK_AVAILABLE and HAS_REPO),
|
||||
reason="torch version is lower than 1.12.0",
|
||||
)
|
||||
@pytest.mark.parametrize("max_memory", [None, 20, 24])
|
||||
@pytest.mark.parametrize("data_args", [(32, 64)]) # (msa_len, pair_len)
|
||||
@clear_cache_before_run()
|
||||
@parameterize("max_memory", [None, 20, 24])
|
||||
@parameterize("data_args", [(32, 64)]) # (msa_len, pair_len)
|
||||
def test_evoformer_stack(data_args, max_memory):
|
||||
run_func = partial(
|
||||
spawn(
|
||||
run_test,
|
||||
1,
|
||||
data_args=data_args,
|
||||
max_memory=max_memory,
|
||||
get_model=get_model,
|
||||
get_data=get_data,
|
||||
)
|
||||
mp.spawn(run_func, nprocs=1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@@ -1,10 +1,8 @@
|
||||
from functools import partial
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
import torch.fx
|
||||
import torch.multiprocessing as mp
|
||||
|
||||
try:
|
||||
from fastfold.model.nn.evoformer import ExtraMSABlock
|
||||
@@ -14,6 +12,7 @@ except:
|
||||
from test_autochunk_alphafold_utils import run_test
|
||||
|
||||
from colossalai.autochunk.autochunk_codegen import AUTOCHUNK_AVAILABLE
|
||||
from colossalai.testing import clear_cache_before_run, parameterize, spawn
|
||||
|
||||
|
||||
def get_model():
|
||||
@@ -57,17 +56,18 @@ def get_data(msa_len: int, pair_len: int) -> Tuple[List, List]:
|
||||
not (AUTOCHUNK_AVAILABLE and HAS_REPO),
|
||||
reason="torch version is lower than 1.12.0",
|
||||
)
|
||||
@pytest.mark.parametrize("max_memory", [None, 20, 24])
|
||||
@pytest.mark.parametrize("data_args", [(32, 64)]) # (msa_len, pair_len)
|
||||
@clear_cache_before_run()
|
||||
@parameterize("max_memory", [None, 20, 24])
|
||||
@parameterize("data_args", [(32, 64)]) # (msa_len, pair_len)
|
||||
def test_extramsa_block(data_args, max_memory):
|
||||
run_func = partial(
|
||||
spawn(
|
||||
run_test,
|
||||
1,
|
||||
data_args=data_args,
|
||||
max_memory=max_memory,
|
||||
get_model=get_model,
|
||||
get_data=get_data,
|
||||
)
|
||||
mp.spawn(run_func, nprocs=1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user