2022-07-06 08:15:16 +00:00
|
|
|
from colossalai.tensor import ColoParameter, ColoTensor, ColoTensorSpec, ProcessGroup
|
2022-05-30 09:23:44 +00:00
|
|
|
import torch
|
2022-07-06 08:15:16 +00:00
|
|
|
import pytest
|
2022-07-19 07:46:24 +00:00
|
|
|
from common_utils import tensor_equal
|
2022-07-06 08:15:16 +00:00
|
|
|
import colossalai
|
|
|
|
from colossalai.utils import free_port
|
2022-05-30 09:23:44 +00:00
|
|
|
|
2022-07-06 08:15:16 +00:00
|
|
|
|
|
|
|
@pytest.mark.skip
|
2022-05-30 09:23:44 +00:00
|
|
|
def test_multiinheritance():
|
2022-07-06 08:15:16 +00:00
|
|
|
colossalai.launch(config={}, rank=0, world_size=1, host='localhost', port=free_port(), backend='nccl')
|
|
|
|
colo_param = ColoParameter(None, requires_grad=True)
|
|
|
|
assert colo_param.dist_spec.placement.value == 'r'
|
2022-05-30 09:23:44 +00:00
|
|
|
assert isinstance(colo_param, ColoTensor)
|
|
|
|
assert isinstance(colo_param, torch.nn.Parameter)
|
|
|
|
|
|
|
|
# __deepcopy__ overload
|
|
|
|
import copy
|
|
|
|
colo_param2 = copy.deepcopy(colo_param)
|
|
|
|
assert isinstance(colo_param2, ColoParameter)
|
|
|
|
assert tensor_equal(colo_param.data, colo_param2.data)
|
|
|
|
assert colo_param.requires_grad == colo_param2.requires_grad
|
|
|
|
|
|
|
|
# __repr__ overload
|
|
|
|
assert 'ColoParameter' in str(colo_param)
|
|
|
|
|
|
|
|
# __torch_function__
|
|
|
|
clone_param = torch.clone(colo_param)
|
|
|
|
assert isinstance(clone_param, ColoTensor)
|
|
|
|
|
2022-07-06 08:15:16 +00:00
|
|
|
|
2022-05-30 09:23:44 +00:00
|
|
|
if __name__ == '__main__':
|
2022-07-06 08:15:16 +00:00
|
|
|
test_multiinheritance()
|