2022-12-13 08:03:49 +00:00
|
|
|
import pytest
|
|
|
|
import torch
|
|
|
|
|
|
|
|
from petals.client import DistributedBloomConfig
|
2023-03-12 21:49:04 +00:00
|
|
|
from petals.server.throughput import measure_compute_rps
|
|
|
|
from test_utils import MODEL_NAME
|
2022-12-13 08:03:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.forked
|
2023-01-03 15:35:51 +00:00
|
|
|
@pytest.mark.parametrize("tensor_parallel", [False, True])
|
2023-01-13 16:16:31 +00:00
|
|
|
def test_compute_throughput(tensor_parallel: bool):
|
2022-12-13 08:03:49 +00:00
|
|
|
config = DistributedBloomConfig.from_pretrained(MODEL_NAME)
|
2023-01-03 15:35:51 +00:00
|
|
|
tensor_parallel_devices = ("cpu", "cpu") if tensor_parallel else ()
|
2022-12-15 12:21:33 +00:00
|
|
|
compute_rps = measure_compute_rps(
|
2023-01-03 15:35:51 +00:00
|
|
|
config,
|
|
|
|
device=torch.device("cpu"),
|
|
|
|
dtype=torch.bfloat16,
|
|
|
|
load_in_8bit=False,
|
|
|
|
tensor_parallel_devices=tensor_parallel_devices,
|
|
|
|
n_steps=10,
|
2022-12-13 08:03:49 +00:00
|
|
|
)
|
2022-12-15 12:21:33 +00:00
|
|
|
assert isinstance(compute_rps, float) and compute_rps > 0
|