Skip to content

Prefer rich over generic platforms when host capabilities match #6977

Description

@flferretti

Problem description

When declaring both a generic platform (e.g. linux-64) and a rich custom platform (e.g. { name = "gpu-linux-64", platform = "linux-64", cuda = "13.0" }), the selection logic currently determines candidate precedence strictly based on declaration order in the platforms array, as documented in

/// appropriate. Within each subdir bucket, platforms are returned in
/// workspace declaration order (so a custom-named variant declared after
/// the bare subdir-bound platform comes second).
.

I believe users would be less surprised if the richest platform were preferred, especially when matching __cuda (see e.g. #6626 fyi @anthonyylee).

Possible solutions could be:

  1. sort candidates by specificity within the same base arch (e.g. linux-64)
  2. fallback to declaration order for platforms with equal specificity
  3. document this prominently or print a warning/hint when multiple candidates match the host

I'd love to hear what the maintainers think about this. I'd be happy to possibly open a PR

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions