Skip to content

[Stream] Add a mechanism for denoting device-device link topology for transfer elision when NUMA. #20854

Closed

Description

@benvanik

Currently all devices are assumed NUMA and that transfers are required for performance to avoid high latency/low throughput across limited links. In both homogeneous and heterogeneous cases we may want to elide some of those transfers when it's either known not to be profitable (relative to an extra allocation and copy) or when the user wants to explicitly avoid them. There are issues with potentially needing cache management operations that aren't currently lowered but for the initial #20851 work they will be ignored. In order to elide transfers in #20853 there must be a way to know the relationship between any arbitrary sets of devices in the compiler. There's still some potential to support runtime-dynamic optional transfers but it's way outside the scope for now.

To allow the AffinityAttr queries to work with only local information each device target will need a way to denote how it communicates with other devices. Unfortunately today the only place this information is available is the HAL device analysis and that's not readily accessible from stream. A new interface of some kind is likely required to annotate the top-level module with the device topology in a way that stream can query. stream.topology = #hal.device.topology<...> implementing IREE::Stream::AffinityTopologyAttr or something. Queries in stream passes can then always find that attribute and use it when resolving the information.

Activity

  1. self-assigned this
    on May 19, 2025
  2. added
    compiler/dialects
    on May 19, 2025
  3. ziereis commented on May 21, 2025

    @ziereis
    Contributor

    i would start working on this if its fine with you?

  4. benvanik commented on May 21, 2025

    @benvanik
    CollaboratorAuthor

    I think it's a bit underspecified for now to start work on, unfortunately. If you want to share ideas here and discuss the design that'd be great, though!

  5. ziereis commented on May 21, 2025

    @ziereis
    Contributor

    Sounds good! So what i thought has to be done is to add an attribute that would look something like this:

      stream.topology = #hal.device.topology<
            links = [
              {[@device_a, @device_b], transfer_required = false},
              {[@device_a, @device_c], transfer_required = true},
              .....
            ]
          >
    

    Im also not exactly sure how this should look like and if the links should be uni- or bidirectional. Maybe you already have something in mind?

    and then a have an Interface like you mentioned, so something like IREE::Stream::AffinityTopologyAttr that has a function like requiresTransfer(AffinityAttr src, AffinityAttr dst) that uses the info in the attribute.

    This way the follow up pass for eliding the transfers could get the attribute from the module and the src/dst hal.device.affinity attributes that are attached to the stream.async.transfer and use this as eligibility check for removing the transfer.

  6. benvanik commented on May 21, 2025

    @benvanik
    CollaboratorAuthor

    (this looks like what I was imagining! will respond in a bit - thanks for taking the challenge :)

  7. ziereis commented on May 22, 2025

    @ziereis
    Contributor

    Thanks, i also opened a draft PR here #20885 if you want to directly take a look :)

  8. added a commit that references this issue on Jun 4, 2025
    c07bfb4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

compiler/dialects

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions