mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-05-08 16:38:15 +00:00
* [npu] setup device utils (#5047) * [npu] add npu device support * [npu] support low level zero * [test] update npu zero plugin test * [hotfix] fix import * [test] recover tests * [npu] gemini support npu (#5052) * [npu] refactor device utils * [gemini] support npu * [example] llama2+gemini support npu * [kernel] add arm cpu adam kernel (#5065) * [kernel] add arm cpu adam * [optim] update adam optimizer * [kernel] arm cpu adam remove bf16 support
29 lines
939 B
Python
29 lines
939 B
Python
import pytest
|
|
|
|
import colossalai
|
|
from colossalai.legacy.utils.memory import colo_device_memory_capacity, colo_set_process_memory_fraction
|
|
from colossalai.testing import spawn
|
|
from colossalai.utils.device import get_current_device
|
|
|
|
|
|
def _run_colo_set_process_memory_fraction_and_colo_device_memory_capacity():
|
|
frac1 = colo_device_memory_capacity(get_current_device())
|
|
colo_set_process_memory_fraction(0.5)
|
|
frac2 = colo_device_memory_capacity(get_current_device())
|
|
assert frac2 * 2 == frac1
|
|
|
|
|
|
def run_dist(rank, world_size, port):
|
|
colossalai.legacy.launch(config={}, rank=rank, world_size=world_size, host="localhost", port=port, backend="nccl")
|
|
_run_colo_set_process_memory_fraction_and_colo_device_memory_capacity()
|
|
|
|
|
|
@pytest.mark.dist
|
|
@pytest.mark.parametrize("world_size", [3, 4])
|
|
def test_memory_utils(world_size):
|
|
spawn(run_dist, world_size)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_memory_utils(world_size=2)
|