Repository navigation
helios/scheduler: price first-output waiting age on incumbent decode rounds - #662
Closed
flare-autobot wants to merge 1 commit into
Closed
flare-autobot wants to merge 1 commit into
flare-autobot wants to merge 1 commit into
Conversation
…rounds Under the balanced scheduler policy (`decode_age_price = 0.1`), active decoding streams accumulate waiting-age utility scaled by their batch-feasible reference wait while waiting prompts accumulate none. When a returning or newly arrived prompt competes against a large active decode cohort (for example, 8 to 31 concurrent decoders on models without mixed prefill-decode graphs), the prompt must wait for its token-service fairness price to ramp up over multiple seconds before winning a prefill slot. If an interior conversation-anchor checkpoint splits a single-chunk prompt into a main chunk, a boundary snapshot, and a short tail, the prompt incurs that wait twice because progress resets its waiting state while its service price drops on the first chunk. This change closes the asymmetry inside the shared Helios scheduler and the Python utility reference simulator without adding configuration flags, CLI options, model branches, or `ServicePrice` exemptions: - `helios/src/scheduler/service.rs`: Extend delivery-reference selection with `delivery_references_and_decode_batch`, returning the incumbent decode cohort's fastest round work-time `b_served * T_dec` (in stream-ms, or `0.0` when no measured decoder is active). Using `b_served = min(B, K_dec)` from incumbent decoders only keeps waiting prompts from amplifying each other under oversubscribed bursts (`K > B`) or small-batch catalogs. - `helios/src/scheduler/utility.rs` and `helios/src/scheduler/policy.rs`: Add `LaneValue::first_output_value` and `LaneValue::prefill_within`. When `decode_age_price > 0.0` and `b_served * T_dec > 0.0`, each waiting prompt with `max_new_tokens > 0` receives waiting-age credit `decode_age_price * (b_served * T_dec) * age_ms * frac`, where `frac = 1.0` when the step finishes the prompt and `frac = work / initial_prefill` on non-finishing chunks. The credit is carried through prerequisite and two-stage continuation scoring (`Init`, `Restore`, `Vision`, `Snapshot`) without adding waiting prompts to the common waiting-cost penalty sum. - `helios/src/scheduler.rs` and `helios/src/server/runtime.rs`: Track `RequestAccounting::first_output_wait_ns`. Preserve it across a prefill chunk stopped strictly by an armed `RetentionRole::Anchor` cut when the prompt otherwise fit in a single eligible prefill graph, while continuing to charge all measured token service truthfully in `observe_service`. Carry `last_output_ns` across preemption and forced-reasoning readmission so readmitted streams age from their most recent output rather than stale original arrival time. - `scripts/scheduling_sim/utility.py` and `helios/src/scheduler/policy_tests.rs`: Mirror the zero-knob formula in `UtilityScheduler` and add unit tests for policy/zero-decoder/score-only inertness, `b_served * T_dec` scaling, anchor-cut wait-clock preservation, and readmission wait clamping. Expected benefit: - Under `--scheduler-policy balanced`, reduce returning-prompt TTFT behind 8 to 31 active decoders from multi-second stalls to sub-second latency while keeping incumbent decode gap distributions bounded under oversubscribed and small-batch bursts. - Under `--scheduler-policy throughput` (`decode_age_price = 0.0`), zero-decoder workloads, and score-only `prompt_logprobs` (`max_new_tokens = 0`), remain completely inert. All previously exported model cores load and serve unchanged. Supporting evidence and limitations: - Prototype commit prepared for early design review prior to running the Linux Rust test suite, Python simulator regression suite, TLA+ conformance checks, and served GPU A/B benchmarks. All offline simulator projections and full verification runs remain to be executed and reported before marking ready for review. Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com> Design-Signed-Off-By: yatesdr; design-review=2e5b
Collaborator
Author
|
Closing duplicate draft opened under the wrong account; reopening under yatesdr. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
Under
--scheduler-policy balanced(decode_age_price = 0.1), active decoding streams accumulate waiting-age utility scaled by their batch-feasible excluded wait (decode_age_price * reference_delivery_ms * (age_ms + horizon_ms)), while prompts waiting for their first output accumulate no waiting-age utility.When a returning prompt or newly arrived prompt competes against a large active decode cohort on a model without mixed prefill-decode graphs (for example, 8 to 31 active decoders on DeepSeek-V4.1-Flash), the prompt must wait multiple seconds for its token-service fairness price (
ServicePrice) to ramp high enough to displace a full-batch decode round. When an interior conversation-anchor checkpoint splits a single-chunk prompt (for example, 204 uncached tokens cut at 202 into a main chunk, a boundarySnapshot, and a 2-token tail), the prompt suffers a double stall: the main chunk chargesServicePrice, then resets progress so theSnapshotand 2-token tail stall again behind the decode cohort.This problem is complementary to two other open scheduler changes:
checkpoint_extra_work_fraction; even when an anchor split is skipped (unsplit single-chunk prompt) or legitimately budgeted (multi-turn or higher extra-work allowance), a waiting prompt still faces the waiting-age asymmetry against active decoders.Why this formulation (
decode_age_price * (b_served * T_dec) * age_ms * frac)One fastest incumbent decode round advances
b_served = min(B, K_dec)active decoding streams in durationT_decms (b_served * T_decstream-ms of decode progress). Scaling a waiting prompt's first-output age credit by the existingdecode_age_pricecoefficient andb_served * T_dec:PolicyConfig::decode_age_price(0.1inbalanced,0.0inthroughput). Remains 100% inert under--scheduler-policy throughput, when no measured decoder is active (K_dec == 0), and on score-onlyprompt_logprobsrequests (max_new_tokens == 0).b_served = min(B, K_dec)rather than total resident concurrencyK_totalorK_total / b. Queued prompts never amplify each other, andK > BorB = 1bursts cannot trigger runaway consecutive prefills.age_ms(notage_ms + horizon_ms, so dividing by duration prefers faster graphs and never distorts zero-age chunk choice),frac = 1.0on steps that finish the prompt, and fixed-denominatorfrac = work / initial_prefillon non-finishing chunks (linear inwork, matching coalescing amortization so non-finishing chunks never favor smaller inefficient capacities). Omitted from the common waiting-cost penalty sumT / 2 * sum(age_price)so waiting prompts never artificially shorten prefill or decode chunks.ServicePriceexemption: All measured token service remains charged truthfully inobserve_service. To eliminate the double stall across a forced interior anchor cut without leaking intothroughputor zero-decoder schedules, onlyfirst_output_wait_nsis preserved when a prefill stops strictly at an armedRetentionRole::Anchorboundary on a prompt that otherwise fit in a single eligible prefill graph.What changed (before / after)
Total prototype diff:
7files (+374 / -16,~105net production Rust lines acrosshelios,0new CLI/config flags,0new graph kinds,0Protobuf/ABI changes).helios/src/scheduler/service.rsdelivery_referencesreturned only per-slotDeliveryReference.delivery_references_and_decode_batch, returning the same per-slot references plus the incumbent decode cohort's fastest round work-timeb_served * T_dec(in stream-ms, or0.0when no measuredDecode/Speculativestream is active). Reuses the existing single pass with no extra cost scans.helios/src/scheduler/utility.rs&helios/src/scheduler/policy.rsLaneValue::prefillscored prefill lanes solely from token service value, intrinsic token value, and coalescing bonus; waiting prompts received no waiting-age credit.LaneValue::first_output_valueandLaneValue::prefill_within. Inlane_values, non-terminal prompts withconsumed_tokens < prompt_tokens,max_new_tokens > 0,decode_age_price > 0.0, andincumbent_decode_batch_ms > 0.0computeage_msfromfirst_output_wait_ns(projected across any pipelined in-flight prefill submission'sexpected_finish_ns) and receiveunit * decode_age_price * incumbent_decode_batch_ms * age_ms. Applied inlane_value_for_tokens_withinandnext_progressso prerequisites (Init,Restore,Vision,Snapshot) and two-stage continuations carry first-output urgency automatically without adding to the common waiting-cost sum.helios/src/scheduler.rs&helios/src/server/runtime.rsRequestAccountingtrackedarrival_nsandlast_progress_ns; any prefill completion advancedlast_progress_ns, and readmitted requests only carriedarrival_ns.RequestAccounting::first_output_wait_nsandRequestScheduler::set_first_output_wait. On completion of a prefill stopped strictly at an armedRetentionRole::Anchorcut whenfits_single_prefill_from(request, start)holds,first_output_wait_nsis preserved whilelast_progress_nsandServicePriceupdate normally.runtime.rscarriesCarried::last_output_nsacross preemption and forced-reasoning readmission so readmitted streams age from their most recent output publication rather than stale original arrival time.scripts/scheduling_sim/utility.py&helios/src/scheduler/policy_tests.rsUtilitySchedulerand added four unit tests covering policy/zero-decoder/score-only inertness,b_served * T_decscaling and chunk fraction behavior, anchor-cut wait-clock preservation withoutServicePriceexemption, and readmission wait clamping.Model core compatibility: No Protobuf, ABI, or prepared-graph changes. Previously exported model cores load and serve without re-export.
Expected benefit (offline simulator projections)
Projected behavior from an offline Python simulator calibrated to
origin/mainprefill-rebase semantics (decode_age_price = 0.1, DeepSeek-V4.1-Flash timing table plus adversarial oversubscribed and small-batch stress cases). These are offline simulator projections, not yet measured on the compiled Rust prototype or GPU hardware:origin/mainmodel)202+2anchor split),K=8decoders1,204 msTTFT (max_gap 66.8 ms)432 msTTFT (max_gap 60.1 ms)2.8×lower TTFT202+2anchor split),K=16decoders2,132 msTTFT (18,117dec tok)482 msTTFT (18,169dec tok)4.4×lower TTFT202+2anchor split),K=31decoders3,377 msTTFT528 msTTFT6.4×lower TTFT32dec /B=4/16prompts)p99 147 ms,max 158 ms,TTFT 3,026 msp99 158 ms,max 169 ms,TTFT 2,747 msconsec_pre = 1, no runaway starvation4dec /B=1/24prompts)p99 305 ms,max 307 ms,consec_pre 7p99 305 ms,max 307 ms,consec_pre 7--scheduler-policy throughput(decode_age_price = 0.0)0.0Supporting evidence and limitations
05d6b602) onorigin/main(a3c80e19) with design review and DCO trailers.Open items before marking ready for review
decode_age_price * (b_served * T_dec) * age_ms * frac(reusingdecode_age_pricewith zero new knobs) is the right scaling and policy boundary.first_output_wait_nson forcedRetentionRole::Anchorcuts (while keepingServicePricetruthful) is desired alongside PR helios/scheduler: budget interior conversation-anchor splits against checkpoint_extra_work_fraction #660 (budgeted_anchor) and PR helios/scheduler: explore smaller prefill chunks under active age-priced streams #661 (smaller prefill chunk exploration).set_first_output_wait/Carried::last_output_nsfor readmission matches the intended preemption semantics.cargo test --locked --releaseacrosshelios(--features runtime-core,server),flare,flare-cli, andheliopausecheck; fix any warnings or edge cases.pytest tests/test_scheduling*.pyandscripts/scheduling_sim/workloads.pyacross all workloads, includingthroughputparity (0.0) and oversubscribed/small-batch stress cases.flare runA/B benchmarks againstorigin/main(returning-agent + concurrent decode workload on exported cores, plus interaction check with helios/scheduler: budget interior conversation-anchor splits against checkpoint_extra_work_fraction #660/helios/scheduler: explore smaller prefill chunks under active age-priced streams #661 if merged).docs/scheduling-theory.md,docs/scheduling-utility.md, anddocs/scheduling-runtime-design.md, and runverification/helios-lifecycle/check.py(TLA+ TLC + observed Rust traces + auxiliary conformance tests) before converting from draft to ready.Discord: flare-autobot