Skip to content

Price a new slot's deadline requests from the requests it is decoding; deadline decode rate follows the 32-token rule - #2675

Closed
jonathan308 wants to merge 5 commits into
feat/decode-rate-age-on-heartbeatfrom
fix/new-slot-deadline-decode-rate
Closed

jonathan308 wants to merge 5 commits into
feat/decode-rate-age-on-heartbeatfrom
fix/new-slot-deadline-decode-rate

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two changes to the decode rate that first-content deadline admission uses. Nothing a heartbeat carries changes.

  1. A new slot prices deadline requests from the requests it is decoding. Before its first completed request, a slot has no decode rate. A request with a first-content deadline that arrived while another request was decoding was refused: the projection had decode work and no rate (decode_rate_unavailable), then deadline_unreachable. Until the first sample, an uncalibrated policy now takes the slowest delivered cadence among the requests decoding on the slot (EngineV2Bridge.liveDecodeCadence): tokens after the first emission over the time since the first token, once a request has 8 such tokens. It is charged per row (no step shape), which overcharges a batch. The engine's projection decides as before, so a cadence that predicts a miss still refuses. With no request past 8 tokens, the decode rate stays unavailable. A calibrated policy is unchanged, and so is any policy with DARKBLOOM_TTFT_ADMISSION_FIXES=0 (no decode rate, no step shape, as on the base).
  2. The deadline decode rate follows the published rate's 32-token rule once a counted request has moved it. decodeEwmaCounted records whether a counted sample (32 tokens or more, or calibration) has moved observedDecodeTpsEwma since it last restarted. It resets with ewmaInitialized, on calibration or when the decode evidence expired. Until a counted sample arrives, every completed request moves the rate exactly as on the base, with the same alpha and restart rule, so a short-only slot's rate follows its replies. After that, a reply shorter than 32 tokens moves neither the rate nor the measured decode step. This rule isn't under DARKBLOOM_TTFT_ADMISSION_FIXES; it applies with the fixes on or off.
Commit What it does
ecb2aa1867 32-token rule for the deadline decode rate (narrowed in ab34fd0b08); tests; docs and changelog
c010cabea8 Live-cadence decode rate before the first sample; tests; docs and changelog
32056d64c6 Use the live cadence only with the deadline admission fixes on (DARKBLOOM_TTFT_ADMISSION_FIXES); with them off the policy is exactly the base's; test
14a5cf9326 Merge of #2672 4fd38a1a64 (this PR's base). Its only conflict was in docs/developer/serving-performance-qualification.md, and both paragraphs are kept
ab34fd0b08 Short replies move the deadline rate until a counted request has (previously they couldn't move it once a short reply had set it, so a short-only slot kept its first reply's rate); tests

The heartbeat and performance_measurements stay byte-identical

This PR is based on #2672, and the comparison is against that base. Line numbers are at this head; EngineV2Bridge+RateObservations.swift moved by 3 lines in ab34fd0b08.

  • observed_decode_tps comes only from publishedDecodeTps, through DecodeRateIdleAge.published (EngineV2Bridge+Capacity.swift:225-228), with the age taken from performanceMeasurements.observationAge("decode"). feat(provider): the heartbeat sends the published decode rate's own age #2672's observed_decode_tps_age_ms (:238-239) reads that value and publishedDecodeAt, which this PR doesn't touch. publishedDecodeTps is written only in updatePublishedDecodeTps (EngineV2Bridge+Accounting.swift:207-221). Its only caller (EngineV2Bridge+RateObservations.swift:72-74) keeps the same condition, calibration || value.setsPublishedDecode.
  • performance_measurements is fed by performanceMeasurements.observe (EngineV2Bridge+RateObservations.swift:79, unconditional for every sample as before) and EngineV2Bridge+Measurements.swift:55,186,191. None of these changed.
  • What changed is read only by admission. observedDecodeTpsEwma, observedDecodeStep and decodeEwmaCounted are read only by admission (decodeEwmaCounted only by the update rule itself); the first two are read only at EngineV2Bridge+Admission.swift:123-127. liveDecodeCadence (EngineV2Bridge+Admission.swift:149) reads active and is called only at :128, only with the fixes on. The wire ewma_initialized is the prefill flag (EngineV2Bridge+Capacity.swift:191, isolatedPrefillEwmaInitialized), not this one.

So the published rate, its idle age and performance_missing on the coordinator are unchanged in every state. The visible effect is fewer deadline_unreachable refusals on a new slot. A request's own profile reports the decode rate that priced its decision, as before.

Linked issue

None. These are follow-ups to #2626/#2627 (not merged) and #2628.

Test plan

  • Red control: Red control for #2675: tests without the change (do not merge) #2676 (head 951bceb261): the new and updated tests on the same base (feat(provider): the heartbeat sends the published decode rate's own age #2672 4fd38a1a64), without the change. It must fail at exactly these 4 tests: NewSlotDecodeCadenceAdmissionTests.admitsAtLiveCadence, NewSlotDecodeCadenceAdmissionTests.refusesWhenCadencePredictsMiss, DecodeRateSampleLengthTests.shortRequestMovesNeitherRate, DecodeRateSampleLengthTests.firstShortReplyStartsTheDeadlineRate. Guard tests that pass there: noRowPastMinimumStaysUnavailable, fixesOffStaysUnavailable, shortReplyRestartsAnExpiredDeadlineRate, shortOnlySlotDeadlineRateFollowsShortReplies. (EngineMeasurementOrderingTests is back to the base's text and is no longer in the set.)
  • CI (dev) and SDK 27 on the exact head.
  • New suite NewSlotDecodeCadenceAdmissionTests. A real EngineV2 has one row frozen mid-decode (suspendStepExecutionAtCountForTesting), so the new prompt's steps carry decode work. The bridge has no decode sample:
    • admitsAtLiveCadence: a decoding row at 20 tok/s; the policy's rate is that cadence with no step shape, and the engine admits with decode work in the projection;
    • refusesWhenCadencePredictsMiss: rows at 100 and 1 tok/s; the slower one prices admission, and the engine refuses deadline_unreachable from a bounded projection longer than the 1 s budget;
    • noRowPastMinimumStaysUnavailable: a row with 7 tokens after its first; the decode rate stays nil and the engine refuses with decode_rate_unavailable, as before;
    • fixesOffStaysUnavailable: with the admission fixes off, a row at 20 tok/s gives no decode rate and no shape, and the engine refuses with decode_rate_unavailable, as before.
  • DecodeRateSampleLengthTests:
    • shortRequestMovesNeitherRate (was shortRequestMovesOnlyTheDeadlineRate): after a counted 101-token request, an 11-token one moves neither rate; the age still refreshes;
    • shortOnlySlotDeadlineRateFollowsShortReplies (guard): 11-, 5- and 3-token replies give 100, then 0.3·40 + 0.7·100, then 0.3·20 + 0.7·that, as on the base;
    • firstShortReplyStartsTheDeadlineRate: a short reply starts the rate, a counted 33-token one moves it, and a short one after that leaves it. Its old expectation (a short after a short leaves the rate) froze a short-only slot's rate at its first reply; that sequence now behaves as on the base;
    • shortReplyRestartsAnExpiredDeadlineRate (guard): after the evidence expired, a short reply starts the rate again.
  • The existing EngineV2PrefillSamplingTests.shortOnlySlotAdmitsBesideDecodingRow still passes: a short-only slot prices a deadline request beside a decoding row from its measured rate.
  • python3 scripts/changelog.py check, python3 scripts/docs-impact-check.py --base origin/dev

Components touched

  • provider-swift (Swift CLI)
  • docs

Protocol / interface changes

  • No protocol/interface changes. No heartbeat, telemetry or profile field is added or changed.

Documentation impact

  • Canonical documentation updated (docs/architecture/inference.md deadlines, docs/developer/serving-performance-qualification.md)

Changelog

Notes for reviewers

  • The live cadence is local evidence: the requests decoding on this slot now. There is no model or fleet decode rate on the provider at runtime. A reviewed profile already takes the calibrated path and never reaches this code. Waiting between tokens only lowers the cadence. The minimum over rows and the per-row charge both err towards refusing.
  • The 0 ↔ stale observed_decode_tps flap after Stop advertising a stale decode rate from an idle slot #2569 isn't addressed here. Any provider-only change would either publish 0 more often or keep a stale rate. It needs the coordinator to decay a stale published rate.

Before And After

flowchart TD
  subgraph Before
    A1[deadline request, another row decoding] --> B1{decode EWMA?}
    B1 -->|none: new slot| C1[decode_rate_unavailable -> deadline_unreachable]
    B1 -->|yes| D1[projection priced]
    S1[short reply after the first] --> E1[moves deadline EWMA]
  end
  subgraph After
    A2[deadline request, another row decoding] --> B2{decode EWMA?}
    B2 -->|none| L2{a row has >=8 tokens after its first?}
    L2 -->|yes| D2[projection priced at the slowest live cadence, per row]
    L2 -->|no| C2[decode_rate_unavailable -> deadline_unreachable]
    B2 -->|yes| D3[projection priced]
    S2[short reply after the first] --> E2[deadline EWMA unchanged]
  end
Loading

Refactor Pass

There was no separate refactor pass. decodeCharge gains one optional input and returns the same results whenever it is nil.

…nce it has a sample

Deadline admission's decode rate (observedDecodeTpsEwma and the measured
decode step) now follows the published rate's rule: after its first sample a
request that generated fewer than 32 tokens leaves it unchanged. Any completed
request still starts it, on a new slot or after the decode evidence expired,
so a slot that serves only short replies keeps a decode rate and is priced for
deadline requests as before.

Only deadline admission reads this rate. The heartbeat's observed_decode_tps,
the rate's age and performance_measurements are unchanged.

Two existing tests asserted that a second short reply moved the deadline
rate; they now assert it stays at the first sample's value.
Before its first completed request a slot has no decode rate, so a request
with a first-content deadline that arrived while another request was decoding
was refused (decode_rate_unavailable, then deadline_unreachable). Until that
first sample, an uncalibrated policy now takes the slowest delivered cadence
among the requests decoding on the slot: tokens after the first emission over
the time since the first token, once a request has 8 such tokens. It is charged
per row, which overcharges a batch. The engine's projection decides as before,
so a cadence that predicts a miss still refuses; with no such request the
decode rate stays unavailable.

Only deadline admission reads it. The heartbeat's observed_decode_tps and
performance_measurements are unchanged, and a calibrated policy is unchanged.
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference-landing Ready Ready Preview Nov 24, 2026 4:04pm UTC
darkbloom-status Ready Ready Preview Nov 24, 2026 4:04pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 24, 2026 4:04pm UTC

Request Review

With DARKBLOOM_TTFT_ADMISSION_FIXES=0 a slot without a decode sample builds
exactly the previous policy (no decode rate, no step shape), so a deadline
request beside a decoding row is refused with decode_rate_unavailable as
before. New test: the fixes off on a new slot with a decoding row.
Conflict in docs/developer/serving-performance-qualification.md only: both paragraphs kept (the heartbeat rate's age, then the new slot's decode rate).
@jonathan308
jonathan308 changed the base branch from dev to feat/decode-rate-age-on-heartbeat November 24, 2026 16:01
@jonathan308 jonathan308 added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 24, 2026
@github-actions github-actions Bot removed the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 24, 2026
…st has

Short replies kept a short-only slot's deadline decode rate at its first
reply: they refreshed the decode evidence, so it never expired, and never
moved it. The rate now remembers whether a counted sample (32 tokens or more,
or calibration) has moved it since it last restarted (decodeEwmaCounted, reset
with ewmaInitialized on calibration or expiry). Until one has, every reply
moves it exactly as before; from then on only counted samples do.

Tests: a short-only slot's rate follows its short replies (as on the base);
firstShortReplyStartsTheDeadlineRate now expects a short reply after a
counted one to leave the rate, not after a short one, which encoded the
freeze; EngineMeasurementOrderingTests is back to the base's text (two short
replies blend as before).
@jonathan308

Copy link
Copy Markdown
Collaborator Author

Closing: this branch's head (ab34fd0) is already contained in dev.

@jonathan308 jonathan308 closed this Dec 2, 2026

This branch was successfully deployed

3 active deployments
Preview – d-inference-landing — ab34fd0b Deployed Nov 24, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — ab34fd0b Deployed Nov 24, 2026 by vercel[bot]
Preview – darkbloom-status — ab34fd0b Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant