mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-04 02:26:51 +00:00
[booster] implemented the cluster module (#3191)
* [booster] implemented the cluster module * polish code
This commit is contained in:
36
colossalai/cluster/device_mesh_manager.py
Normal file
36
colossalai/cluster/device_mesh_manager.py
Normal 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
|
Reference in New Issue
Block a user