Skip to content

feat(hipfile): Break up fallback async ios into smaller chunks reusing a single bounce buffer - #10787

Merged
zbyrne merged 6 commits into
developfrom
users/zbyrne/hipfile/chunk-fallback-async
Aug 31, 2026
Merged

zbyrne merged 6 commits into
developfrom
users/zbyrne/hipfile/chunk-fallback-async

Conversation

@zbyrne

@zbyrne zbyrne commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

The plan is to potentially lower the memory footprint of an async workload by reusing a single bounce buffer for all async IOs performed on a stream. To accommodate this the IOs may need to be broken into smaller chunks that fit on the bounce buffer.

Technical Details

  • Introduce HIPFILE_ASYNC_BUFFER_SIZE environment variable for controlling the bounce buffer size.
  • Add a pinned bounce buffer to hipFile::Stream to be used by async IOs on that stream.
  • Modify Fallback::async_io to queue many copies of the host and kernel functions to perform large IOs using the bounce buffer.

Issue Tracking

JIRA ID: AIHIPFILE-235

Test Plan

Running unit tests and system tests on Rowlet.

Test Result

Tests pass.

Submission Checklist

@zbyrne
zbyrne requested a review from a team as a code owner August 26, 2026 18:48
Copilot AI lite review requested due to automatic review settings August 26, 2026 18:48
@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/hipfile/src/amd_detail/async.cpp, projects/hipfile/src/amd_detail/backend/asyncop-fallback.cpp, projects/hipfile/src/amd_detail/backend/asyncop-fallback.h, projects/hipfile/src/amd_detail/backend/fallback.cpp, projects/hipfile/src/amd_detail/backend/fallback.h (+13 more); no test file found
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a per-stream pinned “bounce buffer” for fallback async I/O and updates the fallback async path to split large transfers into multiple chunked CPU-copy + kernel-copy steps, controlled by a new HIPFILE_ASYNC_BUFFER_SIZE environment variable.

Changes:

  • Add HIPFILE_ASYNC_BUFFER_SIZE configuration/environment plumbing and expose it via Configuration::asyncBufferSize().
  • Allocate and retain a pinned async buffer in hipFile::Stream, and plumb buffer host/dev pointers + size through IStream.
  • Update fallback async I/O and memcpy kernel logic to operate on chunked transfers; adjust unit/system tests accordingly.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
projects/hipfile/src/amd_detail/environment.h Adds constrained unsigned-integral Environment::get overload and async buffer env var declaration.
projects/hipfile/src/amd_detail/environment.cpp Removes old unsigned-int specialization and adds async_buffer_size() accessor.
projects/hipfile/src/amd_detail/configuration.h Adds Configuration::asyncBufferSize() API.
projects/hipfile/src/amd_detail/configuration.cpp Implements async buffer size lookup (default 1 MiB).
projects/hipfile/src/amd_detail/stream.h Extends IStream with async buffer getters; adds async buffer members to Stream.
projects/hipfile/src/amd_detail/stream.cpp Allocates pinned per-stream async buffer and exposes getters.
projects/hipfile/src/amd_detail/backend/asyncop-fallback.h Refactors AsyncOpFallback to use stream-owned bounce buffer and track per-chunk byte counts.
projects/hipfile/src/amd_detail/backend/asyncop-fallback.cpp Switches async op construction to reuse stream async buffer; removes per-op bounce allocation.
projects/hipfile/src/amd_detail/backend/memcpy-kernel.hip Updates kernel to copy only a single chunk and coordinate chunk sizing via chunk_bytes_copied.
projects/hipfile/src/amd_detail/backend/fallback.h Declares new async_io_advance host function.
projects/hipfile/src/amd_detail/backend/fallback.cpp Chunks fallback async I/O by stream buffer size; adds per-chunk advance host function; updates cpu-copy logic.
projects/hipfile/src/amd_detail/async.cpp Stops clearing op shared_ptr members in completeOp (resource lifetime change).
projects/hipfile/test/amd_detail/mconfiguration.h Mocks Configuration::asyncBufferSize().
projects/hipfile/test/amd_detail/mstream.h Mocks new IStream async buffer methods.
projects/hipfile/test/amd_detail/configuration.cpp Adds tests for async buffer size env var parsing/defaulting.
projects/hipfile/test/amd_detail/environment.cpp Adds unsigned-integral overload coverage (contains a test-name typo).
projects/hipfile/test/amd_detail/stream.cpp Updates stream tests for async buffer allocation and adds failure-path coverage.
projects/hipfile/test/amd_detail/async.cpp Updates async fallback tests for stream-owned bounce buffer and chunked async behavior.
projects/hipfile/test/system/async.cpp Updates system tests for chunked kernel semantics and new op fields.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@zbyrne
zbyrne force-pushed the users/zbyrne/hipfile/chunk-fallback-async branch from 8a18e3e to 075271c Compare August 26, 2026 19:27
Comment thread projects/hipfile/test/system/async.cpp Resolved
Comment thread projects/hipfile/test/system/async.cpp Resolved
@gaoikawa

Copy link
Copy Markdown
Contributor

RE: Introduce HIPFILE_ASYNC_BUFFER_SIZE environment variable for controlling the bounce buffer size.

Since we're adding a new env variable, we should document it on the env variable page. Ex: https://rocm.docs.amd.com/projects/hipFile/en/latest/reference/hipFile-environment-variables.html

@john00003 john00003 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Async path was unfamiliar to me, but I got to learn a ton about it (and how our mocking works) while working through this, thanks for the help with that. LGTM I commented on everything that came to my mind.

@zbyrne
zbyrne force-pushed the users/zbyrne/hipfile/chunk-fallback-async branch from 5966564 to 0df656c Compare August 31, 2026 18:42
@zbyrne
zbyrne requested a review from a team as a code owner August 31, 2026 18:42
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 31, 2026
@zbyrne
zbyrne force-pushed the users/zbyrne/hipfile/chunk-fallback-async branch from b56f47f to 442909e Compare August 31, 2026 20:19
Comment thread projects/hipfile/test/system/async.cpp Dismissed
Comment thread projects/hipfile/test/system/async.cpp Dismissed
Comment thread projects/hipfile/test/system/async.cpp Dismissed
Comment thread projects/hipfile/test/system/async.cpp Dismissed
@zbyrne
zbyrne merged commit 88f5ea3 into develop Aug 31, 2026
106 of 107 checks passed
@zbyrne
zbyrne deleted the users/zbyrne/hipfile/chunk-fallback-async branch August 31, 2026 21:02
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation organization: ROCm project: hipfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants