ray.util.placement_group#

ray.util.placement_group(bundles: List[Dict[str, float]], strategy: str = 'PACK', name: str = '', lifetime: str | None = None, _max_cpu_fraction_per_node: float = 1.0, _soft_target_node_id: str | None = None) PlacementGroup[source]#

Asynchronously creates a PlacementGroup.

Parameters:
  • bundles – A list of bundles which represent the resources requirements.

  • strategy

    The strategy to create the placement group.

    • ”PACK”: Packs Bundles into as few nodes as possible.

    • ”SPREAD”: Places Bundles across distinct nodes as even as possible.

    • ”STRICT_PACK”: Packs Bundles into one node. The group is not allowed to span multiple nodes.

    • ”STRICT_SPREAD”: Packs Bundles across distinct nodes.

  • name – The name of the placement group.

  • lifetime – Either None, which defaults to the placement group will fate share with its creator and will be deleted once its creator is dead, or “detached”, which means the placement group will live as a global object independent of the creator.

  • _max_cpu_fraction_per_node – (Experimental) Disallow placing bundles on nodes if it would cause the fraction of CPUs used by bundles from any placement group on the node to exceed this fraction. This effectively sets aside CPUs that placement groups cannot occupy on nodes. when max_cpu_fraction_per_node < 1.0, at least 1 CPU will be excluded from placement group scheduling. Note: This feature is experimental and is not recommended for use with autoscaling clusters (scale-up will not trigger properly).

  • _soft_target_node_id – (Private, Experimental) Soft hint where bundles of this placement group should be placed. The target node is specified by it’s hex ID. If the target node has no available resources or died, bundles can be placed elsewhere. This currently only works with STRICT_PACK pg.

Raises:
  • ValueError – if bundle type is not a list.

  • ValueError – if empty bundle or empty resource bundles are given.

  • ValueError – if the wrong lifetime arguments are given.

Returns:

Placement group object.

Return type:

PlacementGroup