Repository navigation
Conversation
XpuRuntime took one global mutex on every QueryPointer, Copy, AllocHost and FreeHost, and Copy waited once per slice, so the MemcpyWorkerPool paid a full submit-and-wait round trip for every small op. - context_/queues_ are written once in Init() and published through an atomic ready_ flag (release/acquire); everything else reads them without the lock. mu_ now serialises Init() only. - AcceleratorDevice gains CopyAsync()/Synchronize(). The default runs Copy() synchronously, so CUDA and the other vendors are unchanged. The XPU override keeps the memcpy events in a thread-local list and Synchronize() waits for them once. A copy to or from pageable host memory still waits at once: the driver copies it before submit returns, and holding its event only cost time. - The memcpy worker batches a task's accelerator copies and waits once. On failure or exception it still waits for every copy already started before reporting TRANSFER_FAIL. Ops come from caller slices that can overlap (e.g. READ destinations), so a task whose ops share written bytes falls back to waiting per op. - Init/DeviceIndexOf/Copy/AllocHost/FreeHost also catch non-SYCL exceptions (e.g. std::bad_alloc) and report failure. - Device memory on a GPU without a queue is no longer copied on device 0's queue: it is reported as device memory with device_id -1, the copy fails, and a warning is logged once per such GPU. SetContext now records negative ids so Copy can reject them. Add xpu_accelerator_device_test: 16-thread QueryPointer+Copy, one task of 1024 x 4 KiB mixed H2D/D2H ops (pageable and pinned host), a batch whose middle op fails (started copies are finished when it returns), overlapping ops, fault injection (std::bad_alloc, sycl::exception), and the owner-index helper on fake devices. Perf, Arc Pro B60 x8, oneAPI 2026.1, median of 5 interleaved runs: QueryPointer, 16 threads: 0.43 -> 0.85 M calls/s 1024 x 4 KiB task, pinned host: 5.66 -> 4.22 ms 1024 x 4 KiB task, pageable host: 7.04 -> 7.11 ms (no change) QueryPointer is now bounded by sycl::get_pointer_device itself (about 0.97 M calls/s at 16 threads in isolation). Signed-off-by: KP, Jeeja <jeeja.kp@intel.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ae0de505a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
Improves Intel XPU (SYCL) Store transfer throughput by removing a global runtime lock from pointer checks and enabling batched async copies with a single synchronization point. Adds XPU-specific unit tests and updates the memcpy worker to batch accelerator transfers when safe.
Changes:
- Add
CopyAsync()/Synchronize()to the accelerator device API and implement XPU batching via per-thread pending SYCL events. - Update
MemcpyWorkerPoolto batch accelerator copies per task, with an overlap check to preserve correctness. - Add a new XPU accelerator device test suite and wire it into the test build when
USE_XPUis enabled.
| File | Description |
|---|---|
| mooncake-store/include/device/accelerator_device.h | Introduces CopyAsync/Synchronize API for batched copies. |
| mooncake-store/include/device/xpu_accelerator_device_internal.h | Adds testable internals: owner lookup, once-per-key helper, fault injection. |
| mooncake-store/src/device/xpu_accelerator_device.cpp | Removes hot-path locking, adds runtime publishing via atomic flag, implements async copy batching + fault injection. |
| mooncake-store/src/transfer_task.cpp | Batches per-task accelerator copies when operations don’t overlap; synchronizes pending copies before task completion/failure. |
| mooncake-store/tests/xpu_accelerator_device_test.cpp | Adds concurrency, batching, failure, overlap, and owner-lookup unit tests for XPU. |
| mooncake-store/tests/CMakeLists.txt | Registers the new XPU test binary under USE_XPU. |
Review effort: Lite
Review follow-up. MemcpyOperationsOverlap computed range ends as begin + size; a range that wrapped past the top of the address space got an end below its begin, so the sweep could miss an overlap and allow batching. A wrapping range now counts as overlapping. MemcpyOperationsOverlap is declared in transfer_task.h so it can be unit-tested on its own: transfer_task_test gains host-only cases for disjoint, adjacent, shared-read, zero-length, write/write, read-after-write in both op orders, self-overlapping and wrapping ops. With the guard removed, WrappingRangePreventsBatching fails. Signed-off-by: KP, Jeeja <jeeja.kp@intel.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


Title: [Store] Batch XPU copies and drop the global lock from pointer checks
Description
The Store's Intel XPU accelerator device ran every copy one at a time behind a single lock:
XpuRuntimetook one global mutex on everyQueryPointer,Copy,AllocHostandFreeHost, so all Store transfer threads took turns.Copywaited once per slice, so the memcpy worker paid a full submit-and-wait round trip for every small op.Changes:
context_andqueues_are written once inInit()and published through an atomicready_flag (release/acquire). Every other method reads them without the lock;mu_now only serialisesInit().AcceleratorDevicegainsCopyAsync()/Synchronize(). The default implementation callsCopy()synchronously, so CUDA and the other vendors are unchanged. The XPU override keeps the memcpy events in a thread-local list and waits once inSynchronize(). A copy to or from pageable host memory still waits at once: the driver finishes such a copy before submit returns, so holding its event only added overhead (it measured 8% slower).TRANSFER_FAIL, because the caller may free the buffers. Ops come from caller slices, which can overlap (e.g. READ destinations), so a task whose ops share written bytes falls back to waiting per op.Init,DeviceIndexOf,Copy,AllocHostandFreeHostalso catch non-SYCL exceptions (e.g.std::bad_alloc) and return failure. SYCL messages and the type of astd::exceptionare logged.device_id = -1, the copy fails, and a warning is logged once per such GPU.SetContextnow records negative ids so thatCopycan reject them. The owner lookup is a pure helper (xpu_accelerator_device_internal.h) so it can be unit-tested without a second GPU.Suggested Merge Priority
P0 — Urgent
P1 — High
P2 — Normal: Routine bug fix, validated performance/compatibility improvement, or new feature for a confirmed use case## Module
Mooncake Store (
mooncake-store)Type of Change
How Has This Been Tested?
Hardware: 8× Intel Arc Pro B60, oneAPI 2026.1 (Level Zero V2 adapter).
Test commands:
Accuracy
New
mooncake-store/tests/xpu_accelerator_device_test.cpp(12 tests, all pass):ConcurrentQueryPointerAndCopyManySmallOpsInOneTask/{Pageable,Pinned}MemcpyWorkerPooltask of 1024 × 4 KiB mixed H2D/D2H ops completes with correct bytes, 20 repetitionsFailedBatchWaitsForStartedCopiesTRANSFER_FAIL, and ops 0–31 are fully written at the moment it returnsOverlappingOpsRunInOrderCopyFaultsReturnFailurestd::bad_allocandsycl::exceptionfromCopy/CopyAsyncreturn false and do not throwCopyWithNullPointerFailsCopyWithoutDeviceQueueFailsdevice_id-1 or out of range makes the copy fail instead of running on device 0EveryGpuMapsToItsIndexXpuOwnerQueueIndexTest.*Existing suites:
transfer_task_test15 passed, 3 skipped (they needMC_USE_TENT, unrelated);runtime_accelerator_test9/9.Known limit: on this driver,
OverlappingOpsRunInOrderstill passes when the overlap fallback is disabled, because the out-of-order queue happens to serialise overlapping USM copies. SYCL does not guarantee that ordering, so the fallback stays.Performance
Same machine. Main and branch runs alternated, 5 runs each; each value is the median of the 5. A task value is the median of 20 tasks.
mainQueryPointer, 16 threads × 20k callsPinned host memory is the realistic case:
AllocatePinnedHosthands outsycl::malloc_hostbuffers.QueryPointeris now bounded bysycl::get_pointer_deviceitself, which manages about 0.97 M calls/s at 16 threads on its own.Test results:
Checklist
Signed-off-bytrailer certifying the DCO./scripts/code_format.shAI Assistance Disclosure
No AI tools were used
AI tools were used (specify below)
P3 — Low