trinity.common.models.allocator module#

Allocator module for managing inference engines.

class trinity.common.models.allocator.BundleResult(bundles: List[Dict[str, float]], actor_bundle_map: Dict[str, int], bundle_actor_map: Dict[int, str])[源代码]#

基类:object

Data class for storing the result of bundle allocation.

bundles: List[Dict[str, float]]#
actor_bundle_map: Dict[str, int]#
bundle_actor_map: Dict[int, str]#
__init__(bundles: List[Dict[str, float]], actor_bundle_map: Dict[str, int], bundle_actor_map: Dict[int, str]) → None#
class trinity.common.models.allocator.Allocator(config: ExplorerConfig)[源代码]#

基类:object

Allocator class for managing inference engines.

__init__(config: ExplorerConfig)[源代码]#

Initialize the Allocator.

get_actor_name(role: str, engine_id: int, node_id: int) → str[源代码]#

Generate a unique actor name based on the model config, engine ID, and node ID.

property placement_group_name: str#

Generate a descriptive name for the inference model placement group.

allocate_bundles() → BundleResult[源代码]#

Allocate bundles for the rollout model and auxiliary models based on the configuration.

analyze_placement_group(pg: PlacementGroup, bundle_result: BundleResult)[源代码]#
async create_engine(config: InferenceModelConfig, role: str, engine_id: int) → ModelWrapper[源代码]#
async create_all_models() → Tuple[List[ModelWrapper], List[List[ModelWrapper]]][源代码]#

Create all model actors for the rollout model and auxiliary models based on the configuration.

get_model(config: InferenceModelConfig, role: str, engine_id: int) → ModelWrapper[源代码]#

Get the model actor for the given role and engine ID.

async trinity.common.models.allocator.get_model_wrapper(actor_cls, config: InferenceModelConfig, pg: PlacementGroup, actor_bundle_list: List[Tuple[str, int]]) → ModelWrapper[源代码]#

Get the Ray actor wrapper for the inference model.

Creates Ray actors with appropriate GPU allocation and distributed communication setup based on the inferred launch mode.

参数:
  • actor_cls -- The actor class to instantiate (e.g., vLLMRolloutModel, SGLangRolloutModel).

  • config (InferenceModelConfig) -- The model config.

  • pg (PlacementGroup) -- The placement group for the actors.

  • actor_bundle_list (List[Tuple[str, int]]) -- The list of (actor_name, bundle_id) tuples for distributed setup.

返回:

A wrapper for the model actors with distributed communication setup.

返回类型:

ModelWrapper

async trinity.common.models.allocator.get_external_model_wrapper(config: InferenceModelConfig) → ModelWrapper[源代码]#

Get the ModelWrapper for the external model.