-
Notifications
You must be signed in to change notification settings - Fork 292
burst prefix-cache affinity for prompt-sharing requests #1727
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6ed4842
refactor(prefix): extract block-hashing into shared prefixhash package
ezrasilvera e753285
feat(prefix): add burst prefix cache producer for grouped requests
ezrasilvera a176185
feat(prefix): add inter-group longest-prefix placement to burst producer
ezrasilvera 2e68af5
feat(prefix): co-locate prefix-sharing requests, not just identical g…
ezrasilvera fa49a2d
remove duplications
ezrasilvera 2496eed
fix(burstprefix): stop longest-prefix walk at first unheld block
ezrasilvera 771bca0
refactor(burstprefix): stabilize prefix key and share hash encoding
ezrasilvera cc34a61
feat(burstprefix): log when assigned replica is absent from request pods
ezrasilvera 1d1956f
feat(burstprefix): cap batch size with maxBatchSize config
ezrasilvera 60222a5
feat(burstprefix): log per-request batch window wait time
ezrasilvera f01d0e6
fix(burstprefix): reject window and prefix-token misconfigurations
ezrasilvera 4ead43b
perf(burstprefix): precompute prefix-block counts for unit sorting
ezrasilvera aef2bcd
perf(burstprefix): avoid throwaway slice when placing units
ezrasilvera d6f8f3b
docs(burstprefix): explain the less tiebreaker signal choice
ezrasilvera 0b01d36
docs(burstprefix): use cluster-DNS placeholder in deploy sample
ezrasilvera 2c4f47b
test(burstprefix): set maxBatchSize in producer construction tests
ezrasilvera 29398df
test(burstprefix): cover cancelled-context and second-window paths
ezrasilvera 75a1f41
test(burstprefix): cover single-replica and cap-overflow placement
ezrasilvera 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Sample EPP config: burst prefix cache pipeline | ||
| # token-producer -> burst-prefix-cache-producer -> prefix-cache-scorer | ||
| # | ||
| # Co-locates bursts of prompt-sharing requests (e.g. RL rollout group samples) | ||
| # onto shared replicas so a shared prefix is prefilled once instead of scattered | ||
| # across replicas on a cold cache. | ||
| apiVersion: llm-d.ai/v1alpha1 | ||
| kind: EndpointPickerConfig | ||
| plugins: | ||
| - type: token-producer | ||
| parameters: | ||
| modelName: hf-repo/model-name # set to the model used in the vLLM deployment | ||
| vllm: | ||
| url: http://localhost:8000 | ||
| - type: single-profile-handler | ||
| - type: decode-filter | ||
| - type: burst-prefix-cache-producer | ||
| parameters: | ||
| windowDurationMs: 100 # batch window T | ||
| maxPerReplica: -1 # k; -1 sends all samples of a group to one replica | ||
| minColocateBlocks: 0 # >0 co-locates distinct groups sharing >= N leading blocks; 0 = load-balanced | ||
| - type: prefix-cache-scorer | ||
| parameters: | ||
| prefixMatchInfoProducerName: burst-prefix-cache-producer | ||
| - type: load-aware-scorer | ||
| - type: max-score-picker | ||
| schedulingProfiles: | ||
| - name: default | ||
| plugins: | ||
| - pluginRef: decode-filter | ||
| - pluginRef: prefix-cache-scorer | ||
| weight: 2.0 | ||
| - pluginRef: load-aware-scorer | ||
| weight: 1.0 | ||
| - pluginRef: max-score-picker | ||
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
72 changes: 72 additions & 0 deletions
72
pkg/epp/framework/plugins/requestcontrol/dataproducer/burstprefix/README.md
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,72 @@ | ||
| # Burst Prefix Cache Producer | ||
|
|
||
| **Type:** `burst-prefix-cache-producer` | ||
|
|
||
| A request-level data producer that co-locates bursts of prompt-sharing requests | ||
| so a shared prefix is prefilled once instead of scattered across replicas on a | ||
| cold cache. | ||
|
|
||
| ## Problem | ||
|
|
||
| When many requests that share a prompt arrive at the same instant (for example | ||
| the `n` group samples of an RL rollout step), every replica's prefix cache is | ||
| still cold, so a cache-state scorer scores them all zero and load balancing | ||
| spreads them. The shared prompt is then prefilled redundantly on several | ||
| replicas and the prefix-cache benefit is lost. | ||
|
|
||
| ## What it does | ||
|
|
||
| Requests arriving within a configurable window are assigned jointly: | ||
|
|
||
| 1. Each request's prompt is hashed into prefix blocks (shared `prefixhash`). | ||
| 2. Requests with an identical prompt prefix are grouped. An identical group of | ||
| more than one member is always a placement unit; a single request becomes a | ||
| unit only when `minColocateBlocks > 0` and it shares at least that many leading | ||
| blocks with some other request in the batch. | ||
| 3. Units are steered onto a replica (or a bounded set of replicas), filling one | ||
| replica up to `maxPerReplica` before spilling to the next least-loaded replica. | ||
| Identical groups are placed first and kept whole, so the proven same-prompt | ||
| co-location is the firm structure; prefix-sharing units then attach to it. A | ||
| unit prefers a replica that already holds a unit sharing at least | ||
| `minColocateBlocks` leading blocks and is still under its fair share of the | ||
| batch (prefix co-location bounded by balance, so a shared prefix is prefilled | ||
| once without stampeding prefix-sharing units onto one replica); otherwise units | ||
| are balanced across replicas. Longer-prefix units are placed first so shorter | ||
| units match against the richest set of already-placed prefixes. | ||
| 4. The producer emits `PrefixCacheMatchInfo` with a full match on the assigned | ||
| replica and zero elsewhere. | ||
|
|
||
| A request that overlaps no other in the batch, and any prefix-less request, | ||
| receives no affinity (scored zero everywhere), leaving it to other scorers. | ||
| With `minColocateBlocks == 0` only identical groups are placed. | ||
|
|
||
| ## Scoring | ||
|
|
||
| This producer emits `PrefixCacheMatchInfo`; it does not score. Reuse the | ||
| `prefix-cache-scorer` and point it at this producer: | ||
|
|
||
| ```yaml | ||
| - type: prefix-cache-scorer | ||
| parameters: | ||
| prefixMatchInfoProducerName: burst-prefix-cache-producer | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| | field | default | meaning | | ||
| |---|---|---| | ||
| | `windowDurationMs` | 100 | batch window T in milliseconds | | ||
| | `maxPerReplica` | -1 | max samples of one group per replica (k); -1 = unlimited (whole group to one replica) | | ||
| | `blockSizeTokens` | 64 | token block size for prefix hashing | | ||
| | `maxPrefixTokensToMatch` | 0 | cap on matched prefix tokens; 0 uses the default block cap | | ||
| | `minColocateBlocks` | 0 | min shared leading blocks for inter-unit co-location and for a single request to gain an affinity; 0 disables both (only identical groups are placed, purely load-balanced) | | ||
|
|
||
| ## Operational notes | ||
|
|
||
| - The producer adds up to `windowDurationMs` of latency per request while a | ||
| window fills; its producer timeout is extended to cover the window. | ||
| - Co-location is decided within a single window from the request prompts. Identity | ||
| (the samples of one prompt) is matched exactly; partial overlap between distinct | ||
| prompts is matched to `minColocateBlocks` leading blocks. Cross-step warm-cache | ||
| reuse is left to the persistent (approximate or precise) prefix cache producer, | ||
| which can run alongside this one. |
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.