feat: asynchronous hierarchical KV swap - #185
Open
drunkcoding wants to merge 21 commits into
Open
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Contributor
Author
|
Momus plan review: [OKAY] after 2 review rounds. Executable documentation QA was added in commit 0a49bfe. |
Replace the blocking swap-out/swap-in buffers with per-generation KV records, block ownership tracking, and event-driven transfer submission in PagedKVCache. Async mode reserves pinned leases or destination blocks, holds GPU blocks until DMA completion, and uses generation-keyed tombstones so cancellation never targets recycled storage. Sync mode keeps the existing blocking pageable round-trip and never constructs a pinned pool. Adapt three pre-existing tests that probed the removed internal fields to the new record structure.
Replace the blocking preempt/recover path with an event-driven, group-atomic scheduler. schedule() now polls KV transfer completions once per cycle and advances per-request swap group records through OUT_IN_FLIGHT -> HOST_RESIDENT -> IN_IN_FLIGHT phases before any queue transition. Preemption reserves and submits a whole group at once, returns backpressure without mutating state on reservation failure, and never frees GPU blocks while an async D2H is in flight (sync completions free immediately). Swap-in recovery runs after waiting admission so resident work is not starved, restores each member's saved prior status, and evicts a group to _waiting on retry exhaustion. has_work() now accounts for swapped groups and pending transfers; has_runnable_work() gates the engine loop on GPU-ready sequences. Add fake-async-backend scheduler tests covering evicting-block reuse, H2D-gated decode readiness, and the six group atomicity/retry rules, and adapt the OOM recovery edge-case test to the new recovery entrypoint.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Contributor
Author
|
Task 5–10 implementation and verification update (
External prerequisites/blockers:
The PR remains draft; no merge/ready/force operation was performed. |
added 2 commits
August 29, 2026 14:17
_initialize_model read args.kv_swap_* directly, so any caller whose args Namespace predates the kv-swap flags (e.g. existing watchdog init paths) crashed with AttributeError, aborting model init. Use getattr with the documented defaults, matching the existing getattr at the reload path.
drunkcoding
marked this pull request as ready for review
September 2, 2026 21:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements event-driven GPU↔pinned-host KV swap for serving while retaining the default synchronous pageable-buffer path.
Scope
ExternalKVStoreremains a protocol-only extension boundaryNon-goals
No external/distributed store, SSD/RDMA/object-storage backend, multi-node protocol, or KV quantization.
Verification
pre-commit run --all-files: PASSEnvironment blockers
localhost:8000;test_oai_chat_completions.pyandtest_oai_completions.pyfail collection withConnectError: [Errno 111] Connection refusedwhen that external prerequisite is absent.status=BLOCKEDbecause the shared Hugging Face cache path is not writable (PermissionError); parser, config conversion, percentile, and schema tests pass.Type of Change
Checklist