mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-06-16 19:00:11 +00:00
* [legacy] remove outdated codes of pipeline (#4692) * [legacy] remove cli of benchmark and update optim (#4690) * [legacy] remove cli of benchmark and update optim * [doc] fix cli doc test * [legacy] fix engine clip grad norm * [legacy] remove outdated colo tensor (#4694) * [legacy] remove outdated colo tensor * [test] fix test import * [legacy] move outdated zero to legacy (#4696) * [legacy] clean up utils (#4700) * [legacy] clean up utils * [example] update examples * [legacy] clean up amp * [legacy] fix amp module * [legacy] clean up gpc (#4742) * [legacy] clean up context * [legacy] clean core, constants and global vars * [legacy] refactor initialize * [example] fix examples ci * [example] fix examples ci * [legacy] fix tests * [example] fix gpt example * [example] fix examples ci * [devops] fix ci installation * [example] fix examples ci
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
import pytest
|
|
import torch
|
|
from common_utils import tensor_equal
|
|
|
|
import colossalai
|
|
from colossalai.tensor import ColoParameter, ColoTensor
|
|
from colossalai.testing import free_port
|
|
|
|
|
|
@pytest.mark.skip
|
|
def test_multiinheritance():
|
|
colossalai.legacy.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'
|
|
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)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
test_multiinheritance()
|