You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
petals/tests/test_dtype.py

18 lines
725 B
Python

import pytest
import torch
from petals.bloom.from_pretrained import load_pretrained_block
from petals.client import DistributedBloomConfig
from petals.server.block_utils import resolve_block_dtype
from test_utils import MODEL_NAME
@pytest.mark.forked
@pytest.mark.parametrize("torch_dtype", [torch.float32, torch.float16, "auto"])
def test_backend_dtype(torch_dtype):
config = DistributedBloomConfig.from_pretrained(MODEL_NAME)
block = load_pretrained_block(MODEL_NAME, 0, config, torch_dtype=torch_dtype)
backend_dtype = resolve_block_dtype(config, torch_dtype)
other_backend_dtype = next(block.parameters()).dtype if torch_dtype == "auto" else torch_dtype
assert backend_dtype == other_backend_dtype