Skip to content

[Stream] Elide transfers in the stream dialect when resources are accessible on participating affinities. #20853

Open

Description

@benvanik

Similar to the existing execution compatibility queries a AffinityAttr::getMemoryCompatibility (or something like it) would allow for passes to adjust their transfer ops or remove them entirely. Its exact design is still TBD and will likely be a stand-in controlled by a compiler flag to start but could use whatever #20854 adds.

A new pass that ran prior to MaterializeCopyOnWritePass could perform affinity analysis and detect transfers that are from/to devices that are indicated as having shared access. Before COW it's safe to elide the transfers as they are there mostly for type refinement and affinity changes.

Since the transfers are load-bearing to correct IR prior to resource lifetime assignment a new op or a new transfer attribute may be required to indicate that the transfer is not needed for correctness. Alternatively, the pass may ignore any transfer that is perform a usage cast.

Activity

  1. self-assigned this
    on May 19, 2025
  2. added
    compiler/dialects
    on May 19, 2025
  3. changed the title [-][Stream] Elide of transfers in the stream dialect when resources are accessible on participating affinities.[/-] [+][Stream] Elide transfers in the stream dialect when resources are accessible on participating affinities.[/+] on May 19, 2025
  4. ziereis commented on May 22, 2025

    @ziereis
    Contributor

    I also started working on this and created a draft implementation for this here: ziereis#1. The PR is currently against my own branch for the topology attribute as this is needed for this.

  5. benvanik commented on May 22, 2025

    @benvanik
    CollaboratorAuthor

    Neat start! There's some issues it's likely to run into with affinity analysis later on in the pipeline that I'm working on now, but this will be fine standalone for now as it will hopefully help us get some more useful IR (I've just been hacking things together by hand).

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