Skip to content

Add dynamic flow.tensor.update (and other) ops to reduce readbacks #1160

Open

Description

@benvanik

Current flow.tensor.update lowers to hal.command_buffer.copy_buffer, which is itself based on vkCmdCopyBuffer. vkCmdCopyBuffer requires that the source and destination data regions are known at the time the command is recorded into the command buffer, which means that if the flow.tensor.update is sourcing offsets from computed values will involve a host readback.

Instead, we could synthesize a dynamic copy executable for flow.tensor.update with dynamic arguments and then use the normal target backend lowerings to compile it and dispatch it. Instead of then mapping to hal.command_buffer.copy_buffer we'll just have a hal.command_buffer.dispatch that we can turn into an indirect dispatch (if shape is unknown) or pass in the offsets as arguments stored in other buffers.

Trying first to make the offsets static (improved by #1159) is best as the vkCmdCopyBuffer is easier to profile and inspect, however compared to avoiding the host round trip there's almost no amount of performance degradation a custom copy kernel would impose that would not make it a worthwhile transformation.

It's worth noting that many Vulkan implementations don't have dedicated command buffer copy operations (except when issuing on a dedicated DMA queue) and themselves emulate the copies with dispatched kernels. This would just be us doing the same.

Activity

  1. added
    compiler/dialects
    enhancement ➕
    on Mar 19, 2020
  2. added
    performance ⚡
    on Nov 22, 2020
  3. self-assigned this
    on Nov 22, 2020
  4. added this to IREE Codegen and removed this from IREE Codegenon May 2, 2022
  5. moved this from Not Started to Backlog in (Deprecated) IREEon Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

compiler/dialectsenhancement ➕performance ⚡

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions