Repository navigation
[2/3] [Store] Add EGM-backed Store pool over NVLink - #3335
Conversation
|
Current Store head is |
|
Very interested in this on GB300 NVL72. We run PD-disaggregated serving there with MNNVL/IMEX and fabric-handle KV transfer already in production, and a store pool reachable over NVLink instead of RDMA would be a major win for cross-engine prefix restore at long context. Happy to run the provider/consumer validation flow on real GB300 hardware and report results here if useful. |
Thanks a lot for offering to help with the validation — this would be extremely valuable. A real GB300 NVL72 environment with MNNVL/IMEX already in production is especially interesting for this PR. The current validation branch was prepared around the Provider/Consumer flow on GB200/NVL72, so having the same path exercised independently on GB300 would give us very useful additional coverage. Please feel free to run the validation flow and report the results here. Correctness and teardown behavior are the most important parts, and any transfer latency/bandwidth numbers would also be very helpful. Really appreciate you volunteering the hardware and time for this. |
a94583d to
687b9b1
Compare
687b9b1 to
74c6145
Compare
0d8d0be to
7933975
Compare
|
Rebased this on the refreshed prerequisite and kept main’s new Store sources and shared allocation header. The EGM code did not need any further changes. |
d2e25b4 to
1a9a6c8
Compare
|
Rebased onto main now that #2966 is merged, so this is back to a Store-only diff. Cleanup-pending mounts are no longer eligible for heartbeat remount, and an overlap rejection won't unregister an existing buffer. I also serialized close/retry and changed final-failure retention to keep only unsafe allocations, so the Client can shut down. The added failure-path tests pass in CUDA-on and CUDA-off builds; fresh CI has been triggered. |
There was a problem hiding this comment.
The EGM ownership model still makes sense. However, most of the Store-side complexity in this revision is there so that each step can be injected in unit tests; production does not need it. Two facts already in the tree make most of it unnecessary:
NvlinkTransportrecognizes HOST_NUMA ranges by exact address (FindExactOwnedRange), so an EGM chunk can be mounted through the ordinaryClient::MountSegment(ptr, size, "nvlink").- The existing global-segment path already has a teardown order:
~Clientunmounts every entry inmounted_segments_, and RealClient frees the backing memory afterwards.NvlinkHostNumaAllocationis already an RAII owner whose destructor callsRelease().
Suggested shape:
- Add an
nvlinkcase toClient::InitTransferEngine, next to ascend/ubshmem/sunrise_link, and drop the manual TE factory. - Allocate EGM chunks as one more branch of the existing allocation loop in
setup_internal. Hold them instd::vector<std::unique_ptr<NvlinkHostNumaAllocation>>, mount them through the sameMountSegmentcall, and release them afterclient_.reset(). - On release failure, leak and log, as
setup_segment_memory_must_leak_already does.
With that, the following can be deleted: client_internal.h, the SegmentMountOperations seams, the EgmStorePoolHooks/allocation interface, the retryable Setup/Rollback/Teardown state machine, the cleanup-pending setup guard, and most of egm_store_pool_test.cpp. The Store part should shrink substantially. Details inline.
This partly revisits my earlier comments. Injecting a pre-built TE and sharing a caller-supplied-ID mount transaction ended up needing more seams than they save; a transport case in InitTransferEngine plus the existing MountSegment is simpler.
| // The underlying Client is already initialized even if the pool | ||
| // rolled back completely. Retain the pool marker so another setup is | ||
| // rejected until close() tears down that Client. | ||
| egm_store_pool_ = std::move(pool); |
There was a problem hiding this comment.
The whole cleanup-pending lifecycle follows from letting Teardown fail partway and making it retryable:
- the pool is kept as a marker after a failed setup (here);
- re-setup is rejected (L1505);
- the destructor calls
RetainAllocationsForProcessLifetime; close()andensure_can_setupchange instore_py.cpp;test_store_setup_lifecycle.pyis added to cover it.
The existing segment path handles a release failure by leaking and logging (setup_segment_memory_must_leak_). Could EGM do the same? Then none of the above is needed.
There was a problem hiding this comment.
The retry machinery and global setup guard are gone. Close is now terminal: it reports a cleanup error, clears both Python native references and continues closing other resources. Repeated setup semantics are tracked separately in #4294.
I kept an explicit EGM-only unmount before releasing each owner. Client destruction logs unmount failures but cannot report them back, so relying on destruction alone could free memory after an unconfirmed Master cleanup. Failed or ambiguous mounts and failed unmounts retain their allocation until process exit; CUDA release failures do the same. FileStorage workers are stopped first, since they hold a Client reference and may access those segments. There is no retry queue or background recovery.
Leaving this open for your review of those local safety checks.
There was a problem hiding this comment.
Agreed on the explicit unmount: ~Client can't report failures back, so it isn't enough to decide whether the memory is safe to free.
One simplification: the unmount loop and the release loop could be merged. Release() only requires the transport unregister to be complete, and UnmountSegment already does that (Master unmount + TE unregister), so each owner can be released right after its unmount succeeds rather than waiting for client_.reset(). That drops the if (!owner) continue in both loops and the duplicated first-error bookkeeping:
for (auto it = egm_segment_ptrs_.rbegin(); it != egm_segment_ptrs_.rend(); ++it) {
auto &owner = *it;
auto unmounted = client_->UnmountSegment(owner->base(), owner->length());
if (!unmounted) {
// Failed mounts may have no Client record; retain the memory.
LOG(ERROR) << ...;
record_error(unmounted.error());
(void)owner.release();
continue;
}
if (auto released = owner->Release(); !released.ok()) {
LOG(ERROR) << ...;
record_error(ErrorCode::INTERNAL_ERROR);
(void)owner.release();
}
}
egm_segment_ptrs_.clear();Unless something between the unmount and client_.reset() can still touch those ranges, which I couldn't find. If there is something, a comment saying why the two phases are separate would help.
There was a problem hiding this comment.
Addressed the first three suggestions. I kept the two-phase cleanup because Client’s background replica copy/move workers may still hold local source slices after UnmountSegment. Unmount removes registration but does not wait for those workers. Added a comment explaining why backing memory stays alive through Client teardown, without claiming this is a GPU completion barrier.
1a9a6c8 to
3df7569
Compare
|
@Aionw, I've reworked this around the existing Store path. The earlier version had grown a separate lifecycle around EGM, with interfaces used mainly by the tests. I agree that was too much machinery for adding another kind of segment backing. NVLink now uses normal transport initialization. EGM allocation and mounting run in the existing segment loop, before the IPC/HTTP servers start, and RealClient owns the native HOST_NUMA allocations directly. The factory, allocation adapter, hooks, caller-supplied UUID transaction and retryable-close state machine are gone. I kept the Close still checks each EGM unmount result: Generic mount/MR rollback remains outside this PR; related work is in the separate, still-open #2336. The Python repeated-setup guard is also removed, with that API decision tracked in #4294. Tests now focus on config/capacity rules and real Client initialization. CI is green, including the full CTest sweep and docs build. This revision has not been rerun on GB200; the earlier hardware results aren't validation of the new cleanup behavior. Could you take another look, particularly at the EGM-only cap and explicit unmount checks? I've left those two inline discussions open for your confirmation. |
| auto mount_result = | ||
| client_->MountSegment(ptr, mount_size, protocol, seg_location); | ||
| tl::expected<void, ErrorCode> mount_result; | ||
| try { |
There was a problem hiding this comment.
Is this try/catch here because only the EGM path needs to handle a throw? For non-EGM segments it just rethrows. The EGM handling in the catch also looks redundant to me:
MountSegmentAndGetIdinserts intomounted_segments_only after the Master mount succeeds. If the mount fails or throws before that point, the Client has no record for this range.- On failure, the ConfigDict path calls
tearDownAll_internal(). There,UnmountSegment(base, len)fails because the record is missing, and teardown already responds by releasing the owner so the memory is retained until the process exits. That is the same outcome as this catch block. - The one case where the outcomes differ is when the record was already inserted and
EnsureStorageControlPlaneStarted()then throws. Teardown could unmount and free that memory safely, but this catch leaks it.
Could we drop this try/catch, along with the EGM-specific release/pop in the !mount_result branch below, and rely on teardown's existing rule that a failed unmount retains the allocation? A short comment in teardown noting that failed mounts have no Client record would make the leak path explicit. The catch (...) { tearDownAll_internal(); throw; } in the ConfigDict overload (L1535) could go too, keeping only the !result teardown.
There was a problem hiding this comment.
Removed the inner catch and the early release()/pop_back() on mount failure. The owner stays in the cleanup list, so teardown can reclaim it when a Client record exists. A missing record or failed unmount still retains the allocation; there's a short comment at that point.
I kept the outer ConfigDict catch. FileStorage construction can throw after EGM segments have been mounted, while the Python wrapper still owns the native client. That catch runs the same terminal teardown and rethrows; without it, those resources stay live until the caller closes or destroys the wrapper. This keeps exception cleanup immediate without adding retry state. Does that boundary look reasonable to you?
There was a problem hiding this comment.
Yes, that boundary makes sense. FileStorage construction can throw after the EGM segments are mounted, and the inner cleanup is gone now, so keeping only the outer ConfigDict catch is fine.
3df7569 to
85e41ff
Compare
85e41ff to
3cb69f9
Compare
Install torch 2.14.0 in the PG CPU test environment so the loader selects a backend included in the wheel. Keep all PG tests and their runner condition unchanged.
|
@ykwd @stmatengss Could you review this PR? CI is green, and #3431 depends on it. |
| ptr, AscendSegmentDeleter{this->protocol}); | ||
| } | ||
| } else if (this->protocol == "sunrise_link") { | ||
| if (!egm_config.enabled) { |
There was a problem hiding this comment.
Nit: wrapping the whole deleter dispatch in if (!egm_config.enabled) { ... } re-indents ~40 lines of unrelated ascend/sunrise/ub/hugepage/vram code. Could EGM just be the first branch of the existing chain instead? The behavior is the same and the diff gets a lot smaller:
if (egm_config.enabled) {
// Owned by egm_segment_ptrs_.
} else if (this->protocol == "ascend" || this->protocol == "ubshmem") {
...|
|
||
| if (!seg_numa_nodes.empty()) { | ||
| if (egm_config.enabled) { | ||
| // Adopt even a partial Create result before handling failure. |
There was a problem hiding this comment.
The partial owner is pushed into egm_segment_ptrs_ and then popped on every failure path: it is either released here or release()d to leak, so it never stays in the list. A local owner that is pushed only on success would avoid the emplace/pop pair and this comment:
std::unique_ptr<NvlinkHostNumaAllocation> owner;
auto status = NvlinkHostNumaAllocation::Create(
egm_numa_nodes[egm_node_index], segment_size, alignment, owner);
if (!status.ok()) {
LOG(ERROR) << "EGM allocation failed: " << status;
if (owner && !owner->Release().ok()) {
LOG(ERROR) << "EGM partial allocation cleanup failed; "
"retaining until process exit";
(void)owner.release();
}
return tl::unexpected(ErrorCode::INTERNAL_ERROR);
}
ptr = owner->base();
mapped_size = owner->length();
egm_segment_ptrs_.push_back(std::move(owner));| uint64_t quota_bytes = 0); | ||
|
|
||
| private: | ||
| friend class RealClient; |
There was a problem hiding this comment.
This friendship is back, and as far as I can see its only use is the TENT/NVLink check at real_client.cpp:1091 reading client_->transfer_engine_. Making RealClient a friend opens up all of Client's private state for a single read. Could Client expose a narrow const query for this instead, for example one that reports whether the classic engine has a given transport installed?
|
Let's wait CI to pass |
|
@ykwd Could you rerun the failed CI jobs? The Python 3.12 wheel build was interrupted by a runner shutdown (exit 137). Thanks! |
Description
Add a default-off, Provider-owned EGM Store pool for RFC #2914. HOST_NUMA
allocations are mounted as ordinary NVLink Store segments; the Master schema,
placement policy and Consumer Put/Get API are unchanged.
This is [2/3]: #2966 supplies the merged Transfer Engine prerequisite,
this PR adds the Store pool, and #3431 enables direct remote GPU reads. This
branch is based on
main; #3431 remains its child.Implementation
enable_egm_store_poolenables the pool;egm_numa_nodesselectsautoora comma-separated NUMA list. EGM requires
protocol=nvlink, nonzero globalcapacity and
local_buffer_size=0. The parsed config is passed explicitlythrough a private setup overload; auto-discovery is a named mode, not an empty
node-list sentinel. Positional setup keeps EGM disabled.
nvlinkwithdiscovery disabled. An EGM Provider checks the actual engine before allocating:
it must be classic Transfer Engine with NVLink installed, not TENT or a
different transport selected by discovery.
services start. RealClient directly owns the native HOST_NUMA allocations.
Capacity is rounded down to the largest Store/CUDA alignment, divided across
the selected nodes and balanced into chunks using the existing helper.
max_mr_sizeapplies only to the EGM branch, not all NVLink registrations.local services and EGM offload workers, unmounts EGM segments, then
releases backing memory. A failed unmount or CUDA release retains the affected
allocation until process exit and logs the error; other cleanup continues.
close()reports failure but clears the Python client's native references.Calling it again does not retry resource recovery.
record, cleanup can unmount and release the allocation; a missing record or
failed unmount retains it. The outer setup catch also covers later exceptions
such as FileStorage construction, then rethrows. This does not promise
synchronous removal of an uncertain remote record.
The earlier factory/hooks, caller-supplied UUID transaction, retry state machine
and global Python setup guard have been removed. Generic mount/MR failure cleanup
stays with #2336; the Python repeated-setup contract is tracked in #4294.
Configuration
Use
MC_MS_AUTO_DISC=0on both Provider and Consumer for explicit NVLink setup.If discovery is enabled,
MC_FORCE_MNNVL=1selects MNNVL on hosts with RDMAHCAs; the EGM Provider still checks what was actually installed. Full
Provider/Consumer examples are in the updated Python API and supported-protocols
documentation.
Scope and review size
One logical Store commit, 15 files, +790/-52 lines (before the simplification:
+2,257/-61). No Master, TransferMetadata, RDMA/TENT, wire-schema or public C++
signature changes. The GB200 harness is separate from this production branch.
How Has This Been Tested?
git diff --check.Local validation uses the composed stack at #3431, on Linux ARM64 with CUDA
driver stubs where needed. It does not replace either PR's full CI matrix or
MNNVL hardware validation. The previous revision's results are not reused.
The earlier upstream CMake formatting issue is fixed in the new base, so no
hook exception is needed. Repository-wide formatting is not a gate. Local
Sphinx validation was blocked by a dependency download; the strict Sphinx
build, complete CTest sweep and CI Gate have passed in GitHub Actions for this
revision.
No GB200 rerun was performed for this review update. Real MNNVL allocation,
transfer and terminal cleanup still need hardware evidence; earlier GB200
results are historical support, not validation of this implementation.
Module
mooncake-store)mooncake-integration)Type of Change
Checklist
AI Assistance Disclosure
Codex assisted with the implementation, independent code review, tests and PR
preparation. The human submitter remains responsible for reviewing and defending
every changed line.