[CI/Build] Split up VLM tests (#11083)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -682,10 +682,12 @@ def fork_new_process_for_each_test(
|
||||
|
||||
|
||||
def large_gpu_mark(min_gb: int) -> pytest.MarkDecorator:
|
||||
"""Gets a pytest skipif mark, which triggers ig the the device doesn't have
|
||||
meet a minimum memory requirement in gb; can be leveraged via
|
||||
@large_gpu_test to skip tests in environments without enough resources, or
|
||||
called when filtering tests to run directly.
|
||||
"""
|
||||
Get a pytest mark, which skips the test if the GPU doesn't meet
|
||||
a minimum memory requirement in GB.
|
||||
|
||||
This can be leveraged via `@large_gpu_test` to skip tests in environments
|
||||
without enough resources, or called when filtering tests to run directly.
|
||||
"""
|
||||
try:
|
||||
if current_platform.is_cpu():
|
||||
@@ -712,26 +714,37 @@ def large_gpu_test(*, min_gb: int):
|
||||
|
||||
Currently, the CI machine uses L4 GPU which has 24 GB VRAM.
|
||||
"""
|
||||
test_skipif = large_gpu_mark(min_gb)
|
||||
mark = large_gpu_mark(min_gb)
|
||||
|
||||
def wrapper(f: Callable[_P, None]) -> Callable[_P, None]:
|
||||
return test_skipif(f)
|
||||
return mark(f)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def multi_gpu_marks(*, num_gpus: int):
|
||||
"""Get a collection of pytest marks to apply for `@multi_gpu_test`."""
|
||||
test_selector = pytest.mark.distributed(num_gpus=num_gpus)
|
||||
test_skipif = pytest.mark.skipif(
|
||||
cuda_device_count_stateless() < num_gpus,
|
||||
reason=f"Need at least {num_gpus} GPUs to run the test.",
|
||||
)
|
||||
|
||||
return [test_selector, test_skipif]
|
||||
|
||||
|
||||
def multi_gpu_test(*, num_gpus: int):
|
||||
"""
|
||||
Decorate a test to be run only when multiple GPUs are available.
|
||||
"""
|
||||
test_selector = getattr(pytest.mark, f"distributed_{num_gpus}_gpus")
|
||||
test_skipif = pytest.mark.skipif(
|
||||
cuda_device_count_stateless() < num_gpus,
|
||||
reason=f"Need at least {num_gpus} GPUs to run the test.",
|
||||
)
|
||||
marks = multi_gpu_marks(num_gpus=num_gpus)
|
||||
|
||||
def wrapper(f: Callable[_P, None]) -> Callable[_P, None]:
|
||||
return test_selector(test_skipif(fork_new_process_for_each_test(f)))
|
||||
func = fork_new_process_for_each_test(f)
|
||||
for mark in reversed(marks):
|
||||
func = mark(func)
|
||||
|
||||
return func
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
Reference in New Issue
Block a user