Repository navigation
feat(policies): route least_load by token-work expected-wait #1647
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -90,6 +90,8 @@ def _convert_loads_to_protobuf( | |||||||||
| cache_hit_rate=result.cache_hit_rate, | ||||||||||
| utilization=result.utilization, | ||||||||||
| max_running_requests=result.max_running_requests, | ||||||||||
| # Queued token-work: waiting-queue tokens not served from cache. | ||||||||||
| num_waiting_uncached_tokens=result.num_waiting_uncached_tokens, | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With the released Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Nit: A defensive
Suggested change
|
||||||||||
| ) | ||||||||||
|
|
||||||||||
| # Add optional sections using CopyFrom for proper protobuf assignment | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -312,17 +312,27 @@ pub enum PolicyConfig { | |
| #[serde(rename = "power_of_two")] | ||
| PowerOfTwo { load_check_interval_secs: u64 }, | ||
|
|
||
| /// Least-load policy: routes to the worker minimizing | ||
| /// `in_flight + kv_pressure_weight * k/(1-k)` — the real-time in-flight request count plus | ||
| /// a convex KV-cache pressure term from the load monitor. | ||
| /// See `policies/least_load.rs`. | ||
| /// Least-(token-)work policy: routes to the worker minimizing the expected | ||
| /// wait `(queued_tokens + inflight_tokens) / throughput + kv_pressure_weight * k/(1-k)` | ||
| /// — token-work drain time plus a convex KV-cache pressure barrier, computed | ||
| /// from the load monitor with in-flight correction. See `policies/least_load.rs`. | ||
| #[serde(rename = "least_load")] | ||
| LeastLoad { | ||
| #[serde(default = "default_least_load_interval")] | ||
| load_check_interval_secs: u64, | ||
| /// KV-pressure weight (request-equivalents per unit of M/M/1 congestion). | ||
| /// KV-pressure weight `λ_t` (seconds): the time-cost of KV contention, | ||
| /// commensurate with the expected-queue-wait term. | ||
| #[serde(default = "default_least_load_kv_pressure_weight")] | ||
| kv_pressure_weight: f64, | ||
| /// Mean prefill length (tokens) used to estimate in-flight token-work | ||
| /// when a request's token count is unknown at routing time. | ||
| #[serde(default = "default_least_load_mean_prefill")] | ||
| mean_prefill_tokens: u32, | ||
| /// Fallback generation throughput (tokens/s) for the expected-wait term | ||
| /// when a backend reports no live `gen_throughput`. Set to the fleet's | ||
| /// per-replica generation rate; co-tunes with `kv_pressure_weight`. | ||
| #[serde(default = "default_least_load_throughput")] | ||
| default_throughput: f64, | ||
| }, | ||
|
|
||
| #[serde(rename = "bucket")] | ||
|
|
@@ -402,7 +412,15 @@ fn default_least_load_interval() -> u64 { | |
| } | ||
|
|
||
| fn default_least_load_kv_pressure_weight() -> f64 { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Nit: The default changed from |
||
| 1.5 | ||
| 0.15 | ||
| } | ||
|
|
||
| fn default_least_load_mean_prefill() -> u32 { | ||
| 1024 | ||
| } | ||
|
|
||
| fn default_least_load_throughput() -> f64 { | ||
| 2000.0 | ||
| } | ||
|
|
||
| impl PolicyConfig { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields are inserted before
max_idle_secseven though this struct explicitly says new parameters must be appended to avoid breaking positional_Router(...)callers. Any caller built against the previous signature that passes positional arguments afterblock_sizenow hasmax_idle_secsparsed asleast_load_kv_pressure_weightand subsequent arguments shifted, which can produce type errors or silently wrong routing configuration.Useful? React with 👍 / 👎.