Repository navigation
[Perf] scheduler: Send the per-request output stats only when they may have changed - #47178
Conversation
…keeps the latest per request; rust mode keeps its per-step token columns
… decode rows of an extend batch; test the prebuilt, dllm and finish-rule sites; trim comments
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
…rough req methods; read scheduler time stats through a request state property
…ach retraction and the finished row; drop the stale-flag mark sites
…r names http request headers here
…ved stats through a request state method
… comments that restated it
…s that covered nothing of their own
…n readers instead of re-reading the request state
…t only when they change
|
/tag-and-rerun-ci |
|
/rerun-test test_output_streamer_customized_info.py test_output_streamer_logprobs.py test_tokenizer_manager_rid_cleanup.py test_multi_tokenizer_mixin.py test_setwise_score_mixin.py test_ray_wrappers.py test_deferred_output.py test_req_time_stats.py test_flat_raw_top_logprobs.py test_retraction_order.py test_io_struct.py test_metrics.py test_basic_sanity.py test_srt_endpoint.py test_multi_tokenizer.py test_skip_tokenizer_init.py test_customized_info_streaming.py test_tracing.py test_embeddings_api.py registered/disaggregation/test_disaggregation_basic.py test_retract_decode.py test_retract_decode_logprob.py |
|
🚀 🚀 🚀 🚀 |
# Conflicts: # python/sglang/srt/managers/scheduler_components/output_streamer.py # test/registered/unit/managers/test_output_streamer_logprobs.py
prompt_tokens,cached_tokens,cached_tokens_details, the retraction count, the image/audio/video token counts, and the scheduler time stats) now travel together as oneRequestOutputStatsinrequest_stats. A request sends it on its first output, on its first output after each retraction, and on its finished row; other rows carryNone, and the field isNonewhen no row carries one.Req.take_request_stats_due()decides: it comparesretraction_countwith the retraction count of the last stats sent (Req.request_stats_retraction_count) and records the send. No other code marks anything, so a new output path cannot skip a send. A value that changes between outputs other than across a retraction shows only on the finished output; the cases today are listed below.RequestOutputStatsinReqState.request_stats(ReqState.update_request_stats) and buildsmeta_info, metrics and span attributes from it. A row that arrives before its request's stats, which only a late row of an aborted request whose rid was reused can do, is dropped with a warning, as a row for a missing state already is.retraction_counts,cached_tokens_details,time_statsand the media token counts are removed as per-row lists fromBatchTokenIDOutput,BatchStrOutputandBatchEmbeddingOutput. Rust server mode still fillsprompt_tokens,cached_tokensand the media counts per step, whichpush_generationreads.The finished output's
meta_info, all metrics and the finished-request span attributes are the same as before, and so is every output of a request that is never retracted, is not dLLM, and sees no HiCache storage attach or detach. For those three cases, outputs before the finished one keep the stats values sent last:cached_tokensandcached_tokens_details, which change with each block.num_retractionsis current from the first output after the retraction, butqueue_time, the storage waits, and after a PD-decode re-bootstrap the cached tokens, change again later and show only on the finished output.storagekeys ofcached_tokens_details.Verification
A differential test drove 20000 random request lifecycles (prefill, chunked prefill, decode with stream intervals 1-3, retraction and re-prefill, PD-decode prebuilt, dLLM blocks, embeddings, metrics on and off, Rust mode) through the real scheduler output path, detokenizer and tokenizer manager on main and on this PR. Finished outputs, metrics calls, span attributes and Rust payload columns matched exactly, and so did every earlier output except the stats values listed above for retracted and dLLM requests.
Micro benchmark
A steady decode step on the CPU only: 512 requests that have all emitted before, one new token each, built by the real
_GenerationStreamAccumulator, then pickled and unpickled as the default IPC does. Main and this PR ran interleaved, 3 rounds of 200 steps each; each value is the minimum over rounds.CI States
Latest PR Test (Base): 🚫 Run #40953106559
Latest PR Test (Extra): ❌ Run #40953106875
Latest PR Test (AMD ROCm 10): ⏳ Run #40953106536