-
Notifications
You must be signed in to change notification settings - Fork 256
feat(zmq): piggyback a scheduler-load snapshot on slim output batches #1079
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -712,10 +712,26 @@ class BatchTokenIDOutSlim(BaseBatchReq, kw_only=True): | |
| # DP the batch itself names its rank. Appended field: defaults to 0 so | ||
| # older peers on either side stay compatible. | ||
| engine_index: int = 0 | ||
| # Piggybacked scheduler-load snapshot from the producing rank, sampled at | ||
| # send time. The pickle-mode GetLoad poll has no msgpack transport (control | ||
| # replies are dropped on this wire), so the output batch is the only | ||
| # in-band load channel; an external frontend uses these for least-loaded | ||
| # routing across a DP group. Same sources as the per-iteration Prometheus | ||
| # snapshot: running = resident request states, waiting = scheduler queue | ||
| # depth, and the KV ratio's numerator/denominator carried as exact page | ||
| # counts. Appended fields: all default to 0 so older peers stay | ||
| # compatible; a 0 kv_total_pages means "no snapshot" to the frontend. | ||
| num_running: int = 0 | ||
| num_waiting: int = 0 | ||
| kv_active_pages: int = 0 | ||
| kv_total_pages: int = 0 | ||
|
Comment on lines
+724
to
+727
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.
In msgpack mode this struct is encoded as an Useful? React with 👍 / 👎. |
||
|
|
||
| @classmethod | ||
| def from_full( | ||
| cls, out: BatchTokenIDOut, engine_index: int = 0 | ||
| cls, | ||
| out: BatchTokenIDOut, | ||
| engine_index: int = 0, | ||
| load: tuple[int, int, int, int] | None = None, | ||
| ) -> "BatchTokenIDOutSlim": | ||
| # Token source: ``out.output_ids`` — the not-yet-sent slice of each | ||
| # request's generated ids. NOT ``out.decode_ids``: that is the | ||
|
|
@@ -729,8 +745,13 @@ def from_full( | |
| "BatchTokenIDOut.output_ids is None; the msgpack wire needs " | ||
| "the per-request generated token ids" | ||
| ) | ||
| num_running, num_waiting, kv_active_pages, kv_total_pages = load or (0, 0, 0, 0) | ||
| return cls( | ||
| engine_index=engine_index, | ||
| num_running=num_running, | ||
| num_waiting=num_waiting, | ||
| kv_active_pages=kv_active_pages, | ||
| kv_total_pages=kv_total_pages, | ||
| rids=list(out.rids), | ||
| output_ids=[list(ids) for ids in out.output_ids], | ||
| finished_reasons=[_finish_type(fr) for fr in out.finished_reasons], | ||
|
|
||
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.
For terminal batches,
send_pyobj()is called fromstream_output()before theFinishEvent/AbortEventreturned bypost_process_forward_op()is applied withadvance_forward(), soscheduler.active_kv_pages()still includes pages for requests that are being finished in that same batch. Because the msgpack path only publishes load snapshots on output batches, a rank that just became idle can leave the frontend with a stale nonzero KV ratio until some later output, which can make least-cache routing avoid capacity that was already freed; send a post-advance snapshot or subtract the pending terminal changes from this sample.Useful? React with 👍 / 👎.