[booster] implemented the cluster module (#3191)

* [booster] implemented the cluster module

* polish code
This commit is contained in:
Frank Lee
2023-03-22 14:11:54 +08:00
committed by GitHub
parent 019a847432
commit e3ad88fb48
4 changed files with 274 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
from colossalai.device.device_mesh import DeviceMesh
class DeviceMeshManager:
"""
Device mesh manager is responsible for creating and managing device meshes.
"""
def __init__(self):
self.device_mesh_store = dict()
def create_device_mesh(self, name, *args, **kwargs) -> DeviceMesh:
"""
Create a device mesh and store it in the manager.
Args:
name (str): name of the device mesh
*args: args for DeviceMesh
**kwargs: kwargs for DeviceMesh
"""
# TODO(Yuliang): replace *args, **kwargs with explicit arguments
if name not in self.device_mesh_store:
device_mesh = DeviceMesh(*args, **kwargs)
self.device_mesh_store[name] = device_mesh
return device_mesh
else:
raise ValueError(f'Device mesh {name} already exists.')
def get(self, name: str) -> DeviceMesh:
pass
def destroy(self):
pass
def destroy_all(self):
pass