[Placement Group]Add detached support for placement group. (#13582)

This commit is contained in:
DK.Pino
2021-01-27 18:51:26 +08:00
committed by GitHub
parent d2963f4ee1
commit 7f6d326ad8
15 changed files with 209 additions and 21 deletions
+36
View File
@@ -252,6 +252,42 @@ Note that you can anytime remove the placement group to clean up resources.
ray.shutdown()
Placement Group Lifetimes
-------------------------
.. tabs::
.. group-tab:: Python
By default, the lifetimes of placement groups are not detached and will be destroyed
when the driver is terminated (but, if it is created from a detached actor, it is
killed when the detached actor is killed). If you'd like to keep the placement group
alive regardless of its job or detached actor, you should specify
`lifetime="detached"`. For example:
.. code-block:: python
# first_driver.py
pg = placement_group([{"CPU": 2}, {"CPU": 2}], strategy="STRICT_SPREAD", lifetime="detached")
ray.get(pg.ready())
The placement group's lifetime will be independent of the driver now. This means it
is possible to retrieve the placement group from other drivers regardless of when
the current driver exits. Let's see an example:
.. code-block:: python
# second_driver.py
table = ray.util.placement_group_table()
print(len(table))
Note that the lifetime option is decoupled from the name. If we only specified
the name without specifying ``lifetime="detached"``, then the placement group can
only be retrieved as long as the original driver is still running.
.. group-tab:: Java
The lifetime argument is not implemented for Java APIs yet.
Tips for Using Placement Groups
-------------------------------
- Learn the :ref:`lifecycle <ray-placement-group-lifecycle-ref>` of placement groups.