Find the placement group bundle index of an actor

I can figure out the placement group where a given actor is scheduled by doing ray.util.current_placement_group() , but how might I get the index of the bundle it has been scheduled to? One can search for a Node ID in ray.util.placement_group_table(pg), but this only works if exactly one bundle is scheduled per node.

@pwang1234 Welcome to the Ray community.

If there is a single bundle, then by default it’s index will be 0. But you can assign index as part of the argument. Here is the code that shows it:

@ray.remote(num_cpus=0, num_gpus=1)
class Actor:
    def __init__(self):
        pass

    def ready(self):
        pass


# Create a GPU actor on the first bundle of index 0.
actor2 = Actor.options(
    scheduling_strategy=PlacementGroupSchedulingStrategy(
        placement_group=pg,
        placement_group_bundle_index=0,
    )
).remote()

# Verify that the GPU actor is scheduled.
ray.get(actor2.ready.remote(), timeout=10)

Here’s some relared info: Placement Groups — Ray 2.9.1

What about the case where the actor is already scheduled onto the placement group, supposing that it’s placed into the first free bundle? How would I find the index that the actor is scheduled onto then?

Or failing that, is there any way to figure out the consumption of the various resources per bundle?