Repository navigation
fix: coordinate distributed physical KV mapping outcomes - #455
shipiyouniao wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a cross-process serialization boundary around physical KV growth so that concurrent engines sharing the same physical GPU don’t admit overlapping growth transactions from the same stale free-memory snapshot. It keys a file lock by the GPU PCI bus ID, refreshes mem_get_info under that lock, and keeps the lock held across the full batch mapping call; it also documents the shared lock-directory requirement for multi-container deployments.
Changes:
- Add a GPU-PCI-bus-ID keyed file lock to serialize physical KV growth admissions across processes.
- Re-check free memory headroom under the lock immediately before mapping, and hold the lock through the full batch map.
- Document
KVCACHED_PHYSICAL_GROWTH_LOCK_DIRusage/constraints in the example.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/01_simple_two_models/README.md | Documents the new lock directory env var and the shared-filesystem requirement. |
| csrc/inc/gpu_vmm.hpp | Exposes a backend-agnostic wrapper for querying GPU PCI bus ID. |
| csrc/inc/allocator.hpp | Tracks bytes-per-offset to compute per-transaction required physical growth. |
| csrc/allocator.cpp | Implements the physical-growth guard (file lock + headroom admission) and applies it around batch mapping. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
da50021 to
ff5e813
Compare
|
The problem is real. I reproduced it on an A100 through the normal Below is my understanding, feel free to correct me if sth is wrong:
|
|
Thanks, I agree with the sequencing and cost concern. Your reproduction also confirms that the fatal gap is not the Python rollback itself, but The abort-to-exception part is already covered by #418 together with the VMM batch rollback it requires: failures from physical allocation, mapping, or access setup restore the zero-page mapping and roll back earlier mappings in the batch. The exception can then reach I will close this admission-lock PR and treat #418 followed by #453 as the first-line fix. After #418 lands, admission control should only be reconsidered if colocated pressure tests show repeated allocation misses causing measurable starvation or throughput loss. This keeps |
|
Reopened this as a draft and collected the new correctness, starvation, and performance evidence in #467. The rollback-only path still reaches repeated physical-page OOM under sustained colocated pressure, while the narrower admission variants we tested regress throughput or fairness. I am keeping the original transaction boundary here as the best current reference design, not as a merge-ready conclusion. |
ff5e813 to
fd8bfd4
Compare
fd8bfd4 to
7bf39db
Compare
7bf39db to
f6253a2
Compare
|
@RixinLiu This has been substantially reworked and is ready for another protocol review. Your earlier concerns are now addressed as follows:
The strict same-configuration A/B result is 4034.74 versus 4098.53 tok/s aggregate makespan throughput (+1.58%), with 822/822 successful requests. The two fault-injection cases also completed without restarts, CUDA errors, or unreconciled mappings. The exact final commit was rebuilt on a T4 and passed the C++ suite, 231 CPU tests, MyPy on Python 3.9-3.13, 83 applicable GPU/VMM tests (1 skipped), and a same-GPU two-process reserve/map/unmap smoke. The PR remains a draft only because its prerequisite changes are still open; the current transaction and admission design is ready for review. |
ad4472c to
38060c2
Compare
38060c2 to
0d0e9c5
Compare
0d0e9c5 to
d189e1c
Compare
11daee6 to
143bc58
Compare
Co-authored-by: 石皮幼鸟 <2960474346@qq.com>
Concurrent TP/PP KV growth can leave one worker mapped while another rejects a reservation or loses its reply. This PR coordinates prepare/commit/finalize outcomes, retains confirmed mappings for the same page batch, and fails closed when bounded state queries cannot establish an outcome. Successful peers do not physically unmap their mappings as compensation. Native reservations continue to use #487's per-GPU grants/refunds.
A generic native commit exception remains terminal unless the protocol has established its outcome; it is not assumed to be a retained partial map. Completed operations survive response loss through the registry. Mapping and device synchronization remain outside shared budget bookkeeping.
The merge with current main routes resize through
RuntimeControl.RetainedResizeErrorkeeps the published revision pending and permits allocation to adopt the retained batch before retrying. This applies both when consuming a revision and when completing a deferred shrink. It neither acknowledges the revision early nor reports the recoverable batch as quarantined. A newer publication can replace the pending revision.Before this refresh, the PR's retry handling lived in the legacy watcher path:
After integrating main's runtime-control authority:
The refresh preserves main's control-worker commands, logical limits, lifecycle/readiness state, offload copy pins, retirement fences, pending-copy clear protection, and the charged null page under a zero quota. Both test manifests retain their additions. Six constructed regressions cover retained resize during initial application, an existing shrink and deferred completion, with and without a newer revision.
Tests from #574 remain the independent commit
2cc3240, preserving their original author and co-author. #488 and #489 remain optional successors.Private validation of
b0fb7857480208fae76a2f69417e99340b42deda: Python 3.10, 3.11, 3.12 and 3.13 CPU runs each passed 1,670 tests with 15 skips. The rebuilt native extension passed 112 tests on one T4; three tests requiring two GPUs were skipped. C++ checks, all-file pre-commit and MyPy targets 3.10-3.13 passed. The source archive was verified byte-for-byte against this commit.Dedicated Codex review identified two pre-existing P2 availability concerns for further review: idle resize does not itself drive retained-batch recovery, and a retained batch that cannot fit may block a smaller fresh allocation. They are unchanged by this conflict refresh. Constructed single-GPU probes used simulated peers and stopped preallocation after creating the retained batch; they support the local code paths, not a production or multi-GPU reproduction. These concerns remain unresolved, and #488/#489 are not claimed to cover them.
#467's controlled same-parameter A/B is historical evidence for the original design's performance parity. It is not performance or multi-GPU TP/PP acceptance evidence for this head.
Closes #467