Skip to content

fix(provider): a stale slow prefill estimate stops refusing after three deadline refusals - #1956

Draft
jonathan308 wants to merge 8 commits into
devfrom
fix/deadline-refusal-streak-expiry
Draft

jonathan308 wants to merge 8 commits into
devfrom
fix/deadline-refusal-streak-expiry

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A deadline_unreachable refusal admits nothing, so it measures nothing. On an ordinary engine, a slow isolated-prefill sample that has gone stale can therefore keep refusing an idle Mac until the existing 30-minute idle expiry. After three such refusals in a row, the provider now admits the next request of at most 1,024 prompt tokens that finds the Mac idle without a time projection, and that request's prefill replaces the estimate. A longer prompt is still refused until a small request has remeasured the Mac.

What was wrong

Before a request starts, the bridge builds a first-token admission policy from its measured rates and the engine projects whether the first token can arrive before the first-content deadline (EngineV2Bridge.targetFirstTokenDeadlineAdmission, provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+Admission.swift).

dev already ages that evidence (#1541): IsolatedPrefillAdmissionRate.resolve restores an idle Mac at nominal posture to its calibration anchor once the sample is older than 120 seconds, and drops the projection once an idle Mac's sample is older than 30 minutes. Native block engines have their own bounded recovery probe (#1287).

The gap is between those two rules. An ordinary engine keeps a stale slow sample in force for up to 30 minutes when:

  • it has no calibration anchor,
  • its anchor is itself slow, or
  • the Mac is off nominal posture, where the anchor is not restored.

Every request refused in that window leaves the estimate exactly as it was, because only an admitted request produces a prefill sample.

What changes

  • DeadlineRefusalStreak (provider-swift/Sources/ProviderCore/Inference/Performance/Deadline/AdmissionRateEstimators.swift) counts consecutive refusals and holds a retry interval.
  • EngineV2Bridge.recordDeadlineRefusal counts a refusal only when the isolated prefill rate alone explains it: ordinary engine, idle Mac, a bounded projection that priced nothing but this request's prompt (no decode work ahead of it), no reviewed calibration, no native-media rate.
  • Any engine admission ends the streak (projected admission, ordinary submit, and the admission-then-cancel path).
  • After three counted refusals, targetFirstTokenDeadlineAdmission returns no policy for the next request when all of these hold:
    • the prompt is at most 1,024 tokens (PrefillEvidenceRecovery.maximumPromptTokens, the limit the native recovery probe of fix(provider): recover expired prefill evidence on idle native engines #1287 already uses),
    • the isolated-prefill aggregate is older than the existing 120-second freshness window,
    • no fresh prompt-size bucket covers this prompt,
    • the Mac is idle apart from this request, so its prefill is an isolated sample,
    • no admission ended a full streak in the last 120 seconds.
  • That request takes the path a request with no measured rate already takes: ordinary engine.submit, absolute expiry still enforced. Its isolated prefill replaces the expired aggregate (existing applyRateObservation behavior) and later requests are projected from the new rate.
  • DARKBLOOM_TTFT_ADMISSION_FIXES=0 turns this off with the other estimator corrections.

Why a size limit: without a projection only the absolute deadline ends the request, and that deadline grows with the prompt. A Mac that is honestly too slow for long prompts would run one long prompt to its deadline every 120 seconds where it refused at once before. A small prompt is enough to remeasure the rate, and its worst case is short. A prompt over the limit is refused from the expired evidence as before and leaves the streak full, so the next small prompt is the one admitted.

Why a refusal count and not a new age bound: age bounds already exist (120 seconds and 30 minutes), and age alone cannot tell a Mac that is slow from one whose single sample was. The count is the signal that the estimate is the thing refusing; the 120-second freshness window, reused unchanged, keeps a current measurement authoritative. Why three: one refusal can be one long prompt, and two can be a client's retry of it.

What does not change

  • A request whose absolute deadline has already passed is still refused before any engine submission (regression test added).
  • Evidence newer than 120 seconds, aggregate or prompt-size bucket, refuses as measured however many requests it refuses.
  • Generated output: this is admission only. No sampling, template, cache or decode code is touched.
  • Memory and capacity admission: unbounded (fail-closed) projections, physical-capacity refusals included, never count toward the streak, and the admitted request goes through the same capacity checks as any ordinary submit.
  • Native block engines, reviewed calibrations and native-media requests.
  • Attestation, security, owner pause and "me first".
  • Wire protocol: no field, enum value or frame changes. The admitted request reports the existing projection = not_attempted, projection_reason = unmeasured_prefill.

Linked issue

None.

Test plan

All runs are unit tests with scripted engines or the in-memory toy fixture model. No real model weights were loaded, no benchmark was run and the whole suite was not run (shared Mac, GPU in use).

Commands, from provider-swift/:

  • swift test --filter 'AdmissionRateEstimatorTests'
    • on unchanged dev: 17 of 17 passed
    • on the first tests commit, sources unchanged: 25 tests, 4 failed (each with deadlineUnreachable thrown where the request should be admitted), 21 passed
    • on the first fix commit: 26 of 26 passed
    • on the second tests commit: 27 tests, 1 failed (the fresh prompt-size bucket case), 26 passed
    • on the second fix commit: 27 of 27 passed
    • on the third tests commit (the size limit), sources unchanged: 29 tests, 2 failed (a prompt over the limit was admitted), 27 passed
    • on the head's Swift sources: 29 of 29 passed
  • swift test --filter 'EngineMeasurementOrderingTests|AdmissionRateEstimatorTests|ObservedRateDeadlineAdmissionTests|PrefillEvidenceRecoveryTests|PrefillEvidenceRecoveryStateTests|EngineV2PrefillSamplingTests|EngineDeadlineRetirementBridgeTests|EngineProfileCancelTests|DeadlineDecisionBridgeTests|EngineTransferredRetirementWorkTests|DecodeInterleaveDeadlineAdmissionTests|FirstContentDeadlineTests|CancelledSettlementLifecycleTests' on the head's Swift sources: 97 tests in 15 suites passed
  • make changelog-check: 68 valid fragments
  • make docs-impact-check BASE=origin/dev: coverage OK
  • make docs-check: 211 files OK

New cases in AdmissionRateEstimatorTests:

  • three idle refusals over a stale slow sample: the fourth request is admitted by ordinary submit, its prefill becomes the estimate, later requests are projected at the new rate
  • after a full streak a prompt of 1,025 tokens and one of 30,000 are still refused, and the next prompt of 1,024 tokens is admitted
  • a slow calibrated Mac sent only 30,000-token prompts refuses all five and never submits one unprojected
  • the admitted request measures the Mac as slow: refusals resume at the measured rate
  • the admitted request ends before its prompt completes: no second unprojected admission inside the retry interval
  • a full streak waits while other work is pending, then admits once the Mac is idle
  • an expired absolute deadline is refused whatever the streak, before any engine submission
  • a fresh slow sample keeps refusing through six requests
  • a fresh prompt-size bucket keeps refusing over a stale aggregate
  • kill switch off: refusals never expire the estimate
  • refusals beside another model's work are not counted
  • the streak's counting, reset and retry interval

Not run: the full provider suite, SDK tests, GPU or real-weight tests, benchmarks, a live provider.

Components touched

  • provider-swift (Swift CLI)
  • native runtime / MLX
  • landing (Next.js)
  • enclave (Swift)
  • CI / provider release
  • docs

Protocol / interface changes

  • No protocol/interface changes

Documentation impact

  • Canonical documentation updated: docs/architecture/inference.md (deadlines), docs/architecture/hardware-support.md (deadline admission rates), docs/developer/test.md, docs/reference/configuration.md (DARKBLOOM_TTFT_ADMISSION_FIXES), docs/reference/prediction-decision-telemetry.md (projection_reason).

Changelog

  • Added changelog.d/deadline-refusal-streak-expiry.md and ran make changelog-check.

Risks

  • A Mac that really is too slow for the prompts it is sent admits one request of at most 1,024 prompt tokens per loaded model every 120 seconds without a projection. That request can miss its first-content deadline where it would have been refused at once. The deadline itself still bounds it.
  • A Mac that is sent only prompts longer than 1,024 tokens is not helped: it keeps refusing from the stale estimate until a small request arrives or the existing 30-minute idle expiry, as on dev today.
  • The limit is the native probe's constant, not a value tuned for this path.
  • An admitted request that hits the prefix cache, runs beside other work that arrives after it, or is cancelled before its prompt completes produces no isolated sample. The stale estimate then stays and the next attempt waits out the retry interval.
  • Refusals from a fresh sample count toward the streak. They change nothing while the sample is fresh; once it is older than 120 seconds the next idle request of at most 1,024 prompt tokens is admitted without three further refusals.
  • Pair (distributed) engines are ordinary engines under this rule. Their unprojected path keeps its own origin-anchored deadline checks.

Rollout

  • Affects only provider builds that include this change, which means the next provider release after 0.10.11. Providers on 0.10.11 and earlier behave as before.
  • No coordinator change is needed and none is assumed: nothing on the wire changes, so old and new providers and coordinators interoperate.
  • Rollback without a release: set DARKBLOOM_TTFT_ADMISSION_FIXES=0 (this also turns off the other estimator corrections from fix(provider): correct the deadline-admission rate estimators #1541).
  • This PR merges nothing into a release and publishes nothing.

Notes for reviewers

  • Refusal detail in the frame. Not added. Profiled requests already carry projected_service_us, remaining_us, submit_remaining_us, prefill_tps and decode_tps in deadline_decision. A rate-source label, or a distinct projection_reason for a streak-driven admission, needs a new closed-enum value mirrored in the platform repository, so it belongs in a coordinated change.
  • 0.10.10 to 0.10.11. I read the diff between the two tags for anything feeding this estimator or the gate. Neither changed, and the SDK pin's diff does not touch ContinuousBatchingV2. Two inputs to the gate did change: GPT-OSS high reasoning effort is no longer rewritten to medium, and an explicit max_tokens beyond the single-Mac window is now cut to fit where it was refused. Both can lengthen how long a row holds a slot, which a queued target's projection charges. That is the projection working as designed, so nothing is changed here; those refusals have decode work ahead of the target or a busy Mac and are deliberately not counted by the streak.
  • targetFirstTokenDeadlineAdmission stays a pure read of bridge state for the paths this change touches; the streak is mutated only in the submission path.
  • The base is dev at the owner's direction.

Before And After

Before: observable behavior and code flow

flowchart TD
    R["Request with a first-content deadline"] --> A{"Absolute deadline passed?"}
    A -- yes --> X["Refuse: expired_before_submit"]
    A -- no --> P["targetFirstTokenDeadlineAdmission builds a policy from the isolated prefill rate"]
    P --> E{"Engine projection fits the deadline?"}
    E -- yes --> ADM["Admit: prefill is measured and updates the estimate"]
    E -- no --> REF["Refuse: deadline_unreachable"]
    REF --> N["Nothing measured: stale slow estimate unchanged"]
    N --> R
Loading

After: observable behavior and code flow

flowchart TD
    R["Request with a first-content deadline"] --> A{"Absolute deadline passed?"}
    A -- yes --> X["Refuse: expired_before_submit"]
    A -- no --> S{"Full streak of 3, prompt at most 1,024 tokens, aggregate older than 120 s, no fresh bucket, Mac idle, no retry interval running?"}
    S -- yes --> O["No policy: ordinary engine.submit, absolute expiry only"]
    O --> M["recordAdmission: streak reset, 120 s retry interval starts"]
    M --> U["Isolated prefill replaces the expired estimate"]
    S -- no --> P["Policy from the measured rate"]
    P --> E{"Engine projection fits the deadline?"}
    E -- yes --> ADM["Admit: recordAdmission resets the streak"]
    E -- no --> REF["Refuse: deadline_unreachable"]
    REF --> C{"recordDeadlineRefusal: idle Mac, bounded projection of this prompt only, no calibration, no native media?"}
    C -- yes --> INC["Streak plus one, capped at 3"]
    C -- no --> SAME["Streak unchanged"]
Loading

Refactor Pass

A dedicated refactor subagent reviewed the diff against the repository's style rules, with the invariants above and the focused test command.

  • Outcome: three identifier renames on DeadlineRefusalStreak (recordRefusal, recordAdmission, expiresStaleEvidence), committed separately. It judged the guards, call sites, comments and test helpers fine as written and left the two similar guards unshared because they read different inputs.
  • Its validation: incremental build, then AdmissionRateEstimatorTests 26 of 26.
  • It also noted that the streak checked the aggregate's age only, while a calibration cell wider than one row refreshes a prompt-size bucket without the aggregate. That is fixed in the last two commits, test first.
  • Focused validation after the pass was 27 of 27 and 95 tests in 15 suites.

Review Follow-up

A second read-only review of the pushed head found that the unprojected admission had no size bound: on a Mac whose stale estimate is honest, three long prompts refused in a row let the fourth run to its deadline, once every 120 seconds. The last two commits add the 1,024-token limit, test first. The tests that exercise the admission now submit a 1,000-token prompt. Final validation is the 29 of 29 and 97-test results in the test plan.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

jonathan308 and others added 6 commits November 9, 2026 21:33
…ate in force

A refused request starts no work, so it measures nothing. On an ordinary
engine with one slow isolated-prefill sample and no calibration anchor,
every later request is projected at that sample's rate and refused until
the 30-minute idle expiry, however old the sample is.

Add failing tests for the intended rule through the real submission path
with a scripted engine (no model, GPU or real throughput):

- three refusals on an idle Mac with evidence older than the freshness
  window are followed by an admission that remeasures the rate;
- a Mac that remeasures as slow goes back to refusing;
- an admitted request that measures nothing does not reopen admission
  straight away;
- a full streak waits for an idle Mac.

And guards that already hold and must keep holding: a request whose
absolute deadline has passed is refused, fresh slow evidence keeps
refusing, the kill switch keeps the previous behavior, and refusals
beside another model's work are not counted.

Co-Authored-By: Claude <noreply@anthropic.com>
A deadline_unreachable refusal admits nothing, so it measures nothing. On
an ordinary engine an isolated prefill estimate that refuses an idle Mac
could therefore only be replaced by the idle rules of
IsolatedPrefillAdmissionRate: the calibration anchor after 120 s at
nominal posture, or no projection after thirty minutes. With no anchor,
with an anchor that is itself slow, or off nominal posture, one slow
sample kept refusing long prompts for the full thirty minutes.

DeadlineRefusalStreak counts consecutive refusals that only the isolated
prefill rate explains: ordinary engine, idle Mac, a bounded projection of
nothing but this request's own prompt, no reviewed calibration and no
native media. After three with no admission in between, evidence older
than the 120 s measurement freshness window stops blocking the next
request that finds the Mac idle. That request is submitted like one with
no measured rate, so its absolute deadline still applies, and its
isolated prefill replaces the expired estimate. Fresh evidence refuses
as measured. An admission that ends a full streak starts a 120 s retry
interval, so a Mac that really is too slow gets one such admission per
interval even when the request ends before it measures.

Unbounded (fail-closed) projections never count, so memory admission is
unchanged. Native engines keep their own recovery probe.
DARKBLOOM_TTFT_ADMISSION_FIXES=0 turns the rule off with the other
estimator corrections. No wire or output change.

Co-Authored-By: Claude <noreply@anthropic.com>
Document the rule in the deadline section of the inference architecture
page and in the hardware-support page's deadline admission rates, list the
new cases in the test guide, extend the DARKBLOOM_TTFT_ADMISSION_FIXES row
and note that `unmeasured_prefill` also covers a measured rate the provider
set aside as expired. Add the changelog fragment.

Co-Authored-By: Claude <noreply@anthropic.com>
The dedicated refactor pass renamed three methods on DeadlineRefusalStreak:
`refused()` to `recordRefusal()`, `admitted(at:)` to `recordAdmission(at:)`
and `estimateExpired(at:)` to `expiresStaleEvidence(at:)`. The first two
mutate and read as queries in the past participle; the third is also true
while evidence is fresh, so it should not sit beside
`isolatedPrefillEvidenceExpired()` under a name that claims the same thing.
Identifiers only: conditions, order and mutation points are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
… streak

A calibration cell wider than one row refreshes its prompt-size bucket
without touching the isolated-prefill aggregate. The refusal streak checks
only the aggregate's age, so with such a bucket fresh it would set aside a
measurement made seconds ago. This test fails until the next commit.

Co-Authored-By: Claude <noreply@anthropic.com>
The refusal streak set aside the isolated-prefill estimate whenever the
aggregate was older than the freshness window. A calibration cell wider
than one row refreshes its prompt-size bucket and not the aggregate, so a
measurement made seconds ago in this prompt's size domain could be set
aside with it. The streak now also requires that no fresh bucket covers
the prompt, which keeps "fresh evidence refuses as measured" true for both
sources the projection reads.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 10, 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 10, 2026 10:45am UTC
darkbloom-status Ready Ready Preview Nov 10, 2026 10:45am UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 10, 2026 10:45am UTC

Request Review

jonathan308 and others added 2 commits November 10, 2026 02:34
… only

A full refusal streak admitted the next request of any size without a
time projection. A Mac that is honestly too slow for long prompts would
then run one long prompt to its first-content deadline every 120 seconds
where it used to refuse at once.

Pin the limit the native recovery probe already uses
(`PrefillEvidenceRecovery.maximumPromptTokens`, 1,024 tokens):

- a prompt over the limit is still refused after a full streak, and the
  streak stays full for the next small prompt;
- a slow calibrated Mac refuses long prompts however many it refuses.

The streak tests now submit a 1,000-token prompt so they stay inside the
limit. The two new tests fail until the next commit.

Co-Authored-By: Claude <noreply@anthropic.com>
…only

After a full refusal streak the next request on an idle Mac was submitted
without a time projection whatever its size. Only the absolute deadline
ends such a request, and that deadline grows with the prompt, so a Mac
that is honestly too slow for long prompts ran one long prompt to its
deadline every retry interval where it refused at once before.

The unprojected admission now takes a prompt of at most
PrefillEvidenceRecovery.maximumPromptTokens (1,024), the limit the native
recovery probe already uses. A small prompt is enough to remeasure the
rate. A longer prompt is refused from the expired evidence as before and
leaves the streak full, so the next small prompt is the one admitted.

A Mac that is sent only longer prompts is not helped by the streak: it
refuses until a small request arrives or the 30-minute idle expiry, as
before this branch.

Docs and the changelog fragment state the limit.

Co-Authored-By: Claude <noreply@anthropic.com>
@jonathan308

Copy link
Copy Markdown
Collaborator Author

Held for 0.10.13 (not closed). The independent review (review-1956-1957.md) found the code correct and bounded, but a replay over 55 h of production showed about zero gain: 6 of the 7 decisions it would have changed admit requests that were already out of time. Must-fix before it ships: (1) don't admit unprojected, and don't count a refusal, when the request's remaining first-content budget is below a floor (e.g. ≥ 5 s); (2) count only refusals that stale evidence explains (isolatedPrefillEvidenceExpired() at pricing, and a rate below the anchor). Details and tests in the review's §5.

This branch was successfully deployed

3 active deployments
Preview – d-inference-landing — b4e1d942 Deployed Nov 10, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — b4e1d942 Deployed Nov 10, 2026 by vercel[bot]
Preview – darkbloom-status — b4e1d942 Deployed Nov 10, 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