-
Notifications
You must be signed in to change notification settings - Fork 265
feat(server): add prefix cache to paged concurrency (qwen AR) #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Graffioh
wants to merge
4
commits into
Luce-Org:main
Choose a base branch
from
Graffioh:codex/paged-prefix-cache-ar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8aaa6ae
feat(server): add prefix cache to paged concurrency
Graffioh 0493354
fix(server): harden concurrent prefix cache protocol
Graffioh 171015f
refactor(server): simplify paged prefix cache ownership
Graffioh ca218d5
fix(server): harden paged prefix checkpoints
Graffioh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // Model-neutral checkpoint protocol for continuous-batching prefix reuse. | ||
| // | ||
| // The scheduler owns token-prefix lookup and LRU policy. A SeqEngine receives | ||
| // only opaque checkpoint identities and logical token positions. The concrete | ||
| // engine owns checkpoint payloads and cache-layout-specific copies. Copied | ||
| // pages today and a shared-page/radix engine later use the same protocol. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <string> | ||
|
|
||
| namespace dflash::common { | ||
|
|
||
| struct PrefixStoreRef { | ||
| uint64_t id = 0; | ||
| int tokens = 0; | ||
|
|
||
| bool empty() const { return id == 0 && tokens == 0; } | ||
| bool valid() const { return id != 0 && tokens > 0; } | ||
| }; | ||
|
|
||
| inline bool operator==(PrefixStoreRef a, PrefixStoreRef b) { | ||
| return a.id == b.id && a.tokens == b.tokens; | ||
| } | ||
|
|
||
| inline bool operator!=(PrefixStoreRef a, PrefixStoreRef b) { | ||
| return !(a == b); | ||
| } | ||
|
|
||
| struct PrefixCaptureTicket { | ||
| uint64_t id = 0; | ||
| PrefixStoreRef checkpoint; | ||
|
|
||
| bool valid() const { return id != 0 && checkpoint.valid(); } | ||
| }; | ||
|
|
||
| inline bool operator==(const PrefixCaptureTicket & a, | ||
| const PrefixCaptureTicket & b) { | ||
| return a.id == b.id && a.checkpoint == b.checkpoint; | ||
| } | ||
|
|
||
| inline bool operator!=(const PrefixCaptureTicket & a, | ||
| const PrefixCaptureTicket & b) { | ||
| return !(a == b); | ||
| } | ||
|
|
||
| struct PrefixStorePlan { | ||
| PrefixStoreRef restore; | ||
| PrefixCaptureTicket capture; | ||
| }; | ||
|
|
||
| struct PrefixStoreAdmission { | ||
| PrefixStoreRef restored; | ||
| PrefixStoreRef invalidated; | ||
| PrefixCaptureTicket capture; | ||
| // True only after the engine begins validating/copying a requested | ||
| // restore. Keep this independent from the result references: malformed | ||
| // references must still count as attempts and be rejected by the caller. | ||
| bool restore_attempted = false; | ||
| // Wall time spent validating/copying a requested restore. Non-zero for | ||
| // both successful restores and invalidations so operators can see stalls. | ||
| uint64_t restore_elapsed_us = 0; | ||
|
|
||
| bool malformed_restore_state() const { | ||
| const bool has_result = !restored.empty() || !invalidated.empty(); | ||
| return restore_attempted != has_result || | ||
| (!restored.empty() && !restored.valid()) || | ||
| (!invalidated.empty() && !invalidated.valid()); | ||
| } | ||
| }; | ||
|
|
||
| struct PrefixStoreEvent { | ||
| enum class Status { | ||
| none, | ||
| saved, | ||
| failed, | ||
| }; | ||
|
|
||
| Status status = Status::none; | ||
| PrefixCaptureTicket ticket; | ||
| std::string error; | ||
| // Actual committed payload size. Present only for `saved`. | ||
| size_t bytes = 0; | ||
| // Wall time spent in the capture attempt, including a failed copy. | ||
| uint64_t elapsed_us = 0; | ||
|
|
||
| bool attempted() const { return status != Status::none; } | ||
| }; | ||
|
|
||
| } // namespace dflash::common | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.