Skip to content

Fix[io]: xgmi suballocation offset#479

Closed
maning00 wants to merge 4 commits into
mainfrom
fix-xgmi-suballocation-offset
Closed

Fix[io]: xgmi suballocation offset#479
maning00 wants to merge 4 commits into
mainfrom
fix-xgmi-suballocation-offset

Conversation

@maning00

Copy link
Copy Markdown
Contributor

Motivation

Closes #415.
ref: #416

XgmiBackendSession transfers computed remote addresses from the IPC-remapped
allocation base without accounting for the offset of the registered region
within that allocation. hipIpcGetMemHandle/hipIpcOpenMemHandle are keyed to the
allocation base, so registering a sub-region (e.g. a per-layer view of one
paged KV-cache allocation, as PD-disaggregation KV connectors do) produced a
remote pointer pointing at the allocation base instead of the registered
region.

Concretely this caused BatchRead/BatchReadWrite to either move the wrong bytes
(silent corruption, StatusCode::SUCCESS) or, when the mis-computed pointer fell
outside the mapped range, to be classified as host memory by
hipPointerGetAttributes and trigger a CPU memcpy over a device address inside
hipMemcpyPeerAsync -> SIGSEGV.

Fix: record the registered pointer's offset within its allocation
(MemoryDesc::ipcOffset, computed via hipMemGetAddressRange at registration) and
add it back to the remapped base on the importing side. ipcOffset is 0 for
whole-allocation registrations, so existing callers are unaffected.

Repro (pure mori + torch): register a sub-region at base+OFF on one GPU and
XGMI BatchRead it from another -> returns zeros before, correct data after.
Two-process XGMI test that registers a sub-region (offset view) of a larger
allocation on one GPU and batch_reads it from another process/GPU, then checks
the bytes. Before the offset fix the reader gets the allocation base instead of
the registered region, so the data mismatches. Must be cross-process: a single
process serves remote memory via the same-process direct pointer, which already
carries the offset. Skips when fewer than 2 GPUs are visible.
@maning00

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merged with latest main. The only conflict was in include/mori/io/common.hpp in MemoryDesc — resolved by keeping both the ipcOffset field (from this PR) and the fabric-related fields (fabricHandle, vpodId, vpodPpodId, fabricOffset, fabricAllocSize) added in main, and including all of them in MSGPACK_DEFINE. Commit: 4fadd05.

@maning00 maning00 closed this Jul 16, 2026
@maning00
maning00 deleted the fix-xgmi-suballocation-offset branch July 16, 2026 02:45
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.

MoRI-IO XGMI backend: BatchRead ignores the base offset of a registered sub-region (silent data corruption; SIGSEGV in production)

3 participants