← Back to Pull requests

feat: model SGLang's scheduler receive interval in replay #1104

Open
simone-chen opened this pull request with 650 lines diff across 8 files
View on GitHub
simone-chen simone-chen commented on Dec 02, 2026 11:43 UTC
Author

Summary

SGLang's --scheduler-recv-interval N makes the scheduler read new requests from its socket only when a counter of per-iteration weights reaches N. A request that arrives while decode batches run therefore waits 0 to N-1 decode iterations before scheduling can see it. AISim's SGLang replay read every arrival at the next pass. InferenceX recipes for H200 and B200 run SGLang v0.5.23 with --scheduler-recv-interval 10 (B300 and GB300 use 1), so replay missed about 50-110 ms of TTFT per request at concurrency 8 and above on those systems.

This PR models the receive skipper in the SGLang scheduler emulation, from the v0.5.23 source:

  • New field workers.<role>.scheduler.scheduler_recv_interval (Python SchedulerPredictionConfig.scheduler_recv_interval, native sglang.scheduler_recv_interval). The default is 1, which is SGLang's default (arg_groups/fields/schedule.py:204-207). Values below 1 are rejected.

  • With an interval above 1, each scheduler iteration adds the weight of the previous batch's forward mode: decode, target-verify and no batch add 1, and any other mode adds 1000 (environ.py:675-678). The iteration whose counter reaches the interval reads the socket and resets the counter (scheduler_components/recv_skipper.py). So a prefill is always followed by a receive.

  • Requests not yet read wait in an unreceived queue. They count for readiness and draining, but scheduling, metrics and the FPM queue snapshot cannot see them, as in SGLang.

  • Attention DP: every rank adds the group's synced mode (dp_attn.py:688-693).

  • Idle: SGLang's idle loop spins through iterations that each add 1. Replay prices those at zero time. A pass that starts after idle virtual time, or after the whole group drained, reads at once. Within one instant, the empty iterations count one by one, so queued work or the end of a prefill/decode-interval block can run first.

  • Interval 1 behaves exactly as before. The native config omits the default.

  • The field is rejected on vLLM and TRT-LLM, on a disaggregated decode worker, and with AFD (both Python and native).
  • Engine accounting:

  • An unread request can be cancelled; it retires exactly once, and a repeated cancel is a no-op.

  • At the end of a run, an unread arrival is received at the same instant and completes.

  • The ratio reset ignores unread requests, as SGLang's idle check ignores the socket.

  • No new per-pass scans: the cost is a constant per pass and per received request.
  • Not modelled

  • The delay a receive interval adds to aborts. Replay cancels at once; in SGLang an abort for a received request is read on the same schedule, so a waiting request can be prefilled first.

  • The CPU time of idle iterations.

  • Weights overridden with SGLANG_SCHEDULER_RECV_SKIPPER_WEIGHT_*.

  • Mixed prefill and decode batches, which replay does not form.
  • Attribution

  • Translated from SGLang, with header and THIRD_PARTY_NOTICES.md entry: crates/core/src/engine/scheduler/sglang/recv_skipper.rs. Its source is sgl-project/sglang v0.5.23, commit 297e54fd105e974cdf401e5b4d20253a22c16f90, files python/sglang/srt/managers/scheduler_components/recv_skipper.py and python/sglang/srt/environ.py, Apache-2.0. Both notice copies are byte-identical, and scripts/ci/check_packaged_legal_files.py passes.

  • Behaviour cited by line reference only, no code adapted: sglang/core.rs, engine/config.rs, sglang/tests.rs, crates/core/tests/engine.rs, and docs/replay/engine/workers.md.

  • Wiring only: the remaining files.
  • Evidence

    The mechanism was found by comparing InferenceX AgentX truth runs for Qwen3.8-Flash-Next with replay:

  • Server-side excess: the truth's excess between SGLang's request receive and the scheduler's queue and prefill histograms grew with the decode step time, as interval/2 x step predicts. At H200 concurrency 12/14/16 it was +91/+99/+107 ms against 94/109/130 predicted. On interval-1 points it was within plus or minus 13 ms.

  • Step captures: at interval 10, prefills that join a running decode do so after an exact multiple of 10 decode steps 80-100 % of the time. At interval 1 the rate is 9-15 %.
  • End-to-end, on a scoring branch that carries this change on the Qwen3.8 model stack:

  • Gate counts: of 26 InferenceX AgentX points, TTFT points within gate went from 5 to 9 (e2e) and from 5 to 10 (quantile).

  • Interval-1 points: the 14 points with interval 1 were bit-identical.

  • TTFT e2e at interval 10: H200 concurrency 12 went from 19.5 % to 10.3 %, and B200 concurrency 8 from 21.7 % to 8.7 %.
  • Docs

    docs/replay/engine/workers.md gets a field-table row and a section, "SGLang receive interval".

    Tests

  • 27 new Rust tests:

  • - the skipper weights;
    - delays at interval 2 and 10;
    - receive after a prefill;
    - idle and drained resets;
    - a host-loop case where requests are blocked on KV;
    - prefill/decode-interval deferral;
    - attention DP;
    - cancellation while unread;
    - draining;
    - interval 1 against hand-computed admission times.
  • 21 Python tests covering config, lowering and end-to-end replay.

  • Results:

  • - Rust lib 3677 passed; all 25 test binaries 4016 passed.
    - Replay/engine Python 1922 passed.
    - cargo fmt --check, ruff, the doc-link check and the legal-files check are clean.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: None requested Review duration: 4080m
    All Vouch review confidence checks passed
    Residual risk 0.36 = Change Risk (0.64) × (1 − Review Confidence (0.44)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.64 · 650 lines diff across 8 files
    0.64
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 comments
    "Review active on #1104"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    simone-chen simone-chen
    Labels
    risk: medium confidence: 44.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 64% (MEDIUM) · Higher = larger blast radius
    64%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.2% · Lower = rushed or shallow review
    44.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 35.7% · Moderate risk
    35.7%