Skip to content

Reduce compute io overhead - #107

Draft
TedThemistokleous wants to merge 32 commits into
mainfrom
reduce_compute_io_overhead
Draft

Reduce compute io overhead#107
TedThemistokleous wants to merge 32 commits into
mainfrom
reduce_compute_io_overhead

Conversation

@TedThemistokleous

Copy link
Copy Markdown
Collaborator

Update MIGraphX EP to further refine hip graph, direct bind modes and other items to reduce overall latency

Was running into cases where we ran into lots of allocs and other items regarding the hot compute path.

Doing things to ensure we're preserving zero-copy for outputs, direct binding to allow hip graph to just run replay and performing prewarming for the hip graph combined with caching for IO, captures and state.

Simplified the compute to a direct bind - > staging -> eager path similar to the built in EP to further reduce overall latency.

With the regular hipMemCpy we're just syninc to the host slowing things down.
Removes item from hot path that causes overhead of a bunch of CPU bound work stalling before we can send anything to the GPU for compute
…rhead for large input models

Effects batch < concurrency runs.
Removes the lookup overhead and movs most thing sto a unordeed_map lookup instead of Map. Clean up existing logic for cached values based on hash
Correctnes guard for compute threads
… lookups

We're doing 3-4 lookups of O(n) for inputs, now things are reduced to one O(n) lookup now in compute. Done via caching staging inputs and outputs.
Saves constant O(n) lookups each inference run. Instead we reuse teh result until otherwise reset
… launches and output scatters in the hot compute path
Checks to heavy handed and not needed since inputs should be GPU resident at the point this is checked
…put/get_shaoe/length() lookup

Cleans up items we don't need to keep checking per inference and just rely on a single compare + lookup. Reduces overhead per inference useful for smaller models in the steady state path
Make this more maintainble for each mode of direct, staging and eager.

Cleanup some of the copy/zeroing logic as well for hipgraph runs to reuse shared code
…unction and seperate paths

We have direct bind, stagged and eager mode now in the compute path
Reuse buffers, and drop extra lookup calls to getShape() by looking for initial dimension when we're in dynamic batching mode
Only do memset on startup so we're not constantly blockign CPU hot path so we aren't wasting cycles memsetting regions we just end up slicing out. This matters for first run/capture since we want a known state but that can be handled on initial allocation/startup prior to the hot compute() path
remove hip enqueue on hot path via hipMemsetAsyc for scratch

Eliminate hash pass on every batch size change

remove 1 alloc + free call for GatherInputshapesandBatch
Remove 1 heap alloc for extra outputs

Remove 1 call per input for tensor data

precompute bound_output_bytes and use that instead of calling shape::bytes
Remove PadInputTensor and associated signature in header

simplify no_padding flag creation

Mirror CopyStagingOutputstoOrt to use hipMemCpyAsync instead of hipmemCpyWithstream
leverage indexing so we don't have to do a bunch of map lookups
…ry for H2D DMA

Ensure we're leveraging pinned memory from io_bound inputs so the DMA from H2D avoids a memcpy reducing overall latency

The added reductions here reduce pointer checks as well as the shape scans to reduce overhead if we know IO is pinned and we're in a steady state. This avoids O(N) calls and just performs a lookup
…ned memory

Make the logic to coalesce trigger based on host/device memory and not whether the inputs are paged or pinned. This allows us to always collapse the N dim input copies to one larger H2D copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants