Skip to content

[core] Unstable placement group GPU bundle order #51117

Open

Description

@xvblack

What happened + What you expected to happen

when creating placement group with bundle resource requirements like [{'gpu': 1, 'cpu: 1}] * 64 and 'PACK' strategy, we are expecting the created bundle index to align with gpu node-rank order, like [node1 * 8, node2 * 8, ...], but sometimes the order is wrong, like [node1, node2 * 7, node2, node1 * 7].

we doubt the root cause is the unstable bundle resource sorting here:

BundleSchedulingPolicy::SortRequiredResources(
. after the sorting, the bundle order is effectively random since std::sort is not guaranteed to be stable, therefore the 'PACK' allocator would pack bundles randomly into one node.

we verified this hypothesis by using resource requirements guarantee sorting order, like [{'gpu': 1, 'cpu': 1 - 0.0001 * i} for i in range(64)], in which case the bundle index is correct. so we suggest replacing the std::sort with std::stable_sort shall solve this issue?

Versions / Dependencies

ray 2.43.0

Reproduction script

bundles = [{"GPU": 1, "CPU": 1} for _ in range(64)]
pg = placement_group(bundles, strategy="PACK")
ray.get(pg.ready())
table = placement_group_table(pg)
print(table)

Issue Severity

Medium: It is a significant difficulty but I can work around it.

Activity

  1. added
    bug
    triage
    on Mar 6, 2025
  2. added
    core
    on Mar 6, 2025
  3. jjyao commented on Mar 10, 2025

    @jjyao
    Contributor

    @xvblack, PG doesn't provide such order guarantee. If you need that order guarantee, you need to do something your self.

  4. added
    question
    P1
    and removed
    bug
    triage
    on Mar 10, 2025
  5. SumanthRH commented on Mar 11, 2026

    @SumanthRH
    Contributor

    Adding a comment on this issue hoping this gets added as a feature.

    Currently, because of no order guarantees, user code ends up writing some reordering logic after placement group creation. Most RL frameworks built on top of Ray write this reordering logic themselves at the moment. Examples include OpenRLHF, SkyRL, NemoRL and SLIME.

    Having either

    1. the order guarantee for strategy='PACK' or
    2. An explicit flag to provide ordered bundles (placement_group(bundles, strategy='PACK', preserve_pack_order=True))

    would be very helpful.

    I am not sure how much overhead is present in guaranteeing the ordering (I would assume it's low), but if possible, I would prefer PACK to provide stable ordering by default.

  6. jeffreywang88 commented on Mar 13, 2026

    @jeffreywang88
    Contributor

    Providing a utility to sort bundles within a PG as a simple workaround: #61715.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1community-backlogcorequestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions