rlightning.utils.placement.placement_manager¶
Global Resource Manager for resource-aware component scheduling.
This module provides a singleton GlobalResourceManager that: 1. Reads global configuration and generates ComponentScheduling 2. Discovers and manages global node resources 3. Plans resource pools based on placement strategy (disaggregate/colocate) 4. Creates Ray placement groups for components 5. Tracks component distribution across nodes
- class rlightning.utils.placement.placement_manager.GlobalResourceManager[source]¶
Bases:
objectSingleton resource manager for global resource management.
This manager orchestrates the following workflow: 1. Initialize with configuration and scheduling requirements 2. Discover cluster resources via ResourcePoolPlanner 3. Plan resource pools based on placement strategy 4. Create placement groups via the selected strategy 5. Track component distribution for monitoring
- Usage:
manager = GlobalResourceManager.get_instance() manager.initialize(placement_config, scheduling) strategy = manager.get_scheduling_strategy(“train”, worker_index=0)
- get_component_distribution() Dict[str, Dict[str, Dict[str, Any]]][source]¶
Return mapping of node_id -> {component_type: {“count”: N, “ids”: […]}}.
Format is aligned with ResourcePoolPlacementStrategy._node_component_distribution.
- classmethod get_instance() GlobalResourceManager[source]¶
Get the singleton instance..
- Returns:
The singleton GlobalResourceManager instance.
- get_placement_config() Config | None[source]¶
Get the placement configuration.
- Returns:
The placement configuration object.
- get_pool_for_component(component_type: str) ResourcePool | None[source]¶
Get the resource pool containing a specific component type.
- get_resource_planner() ResourcePoolPlanner | None[source]¶
Get the resource planner instance.
- get_resource_pools(pool_name: str = None) Dict[str, ResourcePool][source]¶
Get the planned resource pool by pool_name.
- get_scheduling() ComponentScheduling | None[source]¶
Get the component scheduling requirements.
- Returns:
The component scheduling object.
- get_scheduling_strategy(component_type: str, worker_index: int = 0) Any[source]¶
Get Ray scheduling strategy for a component.
- Parameters:
component_type – Type of component (“train”, “eval”, “buffer”, “env”).
worker_index – Index of the worker within its type.
- Returns:
Ray scheduling strategy (PlacementGroupSchedulingStrategy or “DEFAULT”).
- get_storage_to_train_workers() Dict[int, List[int]] | None[source]¶
Get storage -> train worker mapping from the active strategy.
- Returns:
Dictionary mapping storage indices to train worker indices.
- Raises:
RuntimeError – If PlacementManager is not initialized.
- initialize(cluster_cfg: ClusterConfig, scheduling: ComponentScheduling, config_path: str | None = None) None[source]¶
Initialize the placement manager with configuration.
This method performs the following steps: 1. Store configuration and scheduling requirements 2. Discover cluster resources 3. Validate scheduling requirements against available resources 4. Plan resource pools based on placement strategy 5. Create placement groups via the selected strategy 6. Track initial component distribution
- Parameters:
cluster_cfg – Cluster configuration, including placement settings.
scheduling – Component scheduling requirements.
config_path – Optional path to the configuration file.
- property is_initialized: bool¶
Check if the placement manager is initialized with a strategy..
- Returns:
True if a strategy has been set.
- refresh_component_distribution() Dict[str, Dict[str, int]][source]¶
Refresh and return the current component distribution across nodes.
This queries Ray’s actor registry to get real-time distribution.
- save_yaml_config(cluster_config_path: str, filename: str = 'resource_pool_auto.yaml', subdir: str = 'resource_pool') str[source]¶
Save current resource_pool yaml to disk.
- property strategy: PlacementStrategy | None¶
Get current placement strategy.
- Returns:
The current PlacementStrategy instance or None.
- rlightning.utils.placement.placement_manager.get_global_resource_manager() GlobalResourceManager | None[source]¶
Get the initialized global resource manager singleton instance.
- Returns:
GlobalResourceManager if initialized, None otherwise.