Skip to content

Provider: a media failure names who owns the limit; one total mapping answers it - #2531

Draft
0xkydo wants to merge 2 commits into
devfrom
refactor/media-failure-disposition
Draft

0xkydo wants to merge 2 commits into
devfrom
refactor/media-failure-disposition

Conversation

@0xkydo

@0xkydo 0xkydo commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When preparing an image or a video for a model fails, the provider has three answers: the request itself is at fault (400), this Mac could not build the submission (a retryable 503 the coordinator reroutes), or the decoder failed just now. Which one was chosen by a cascade of as? casts with a default of "retry", copied into three catch chains in the scheduler.

One error case, towerBudgetExceeded(String), carried both the model artifact's own fixed limit and the operator's and the device's limits, and the default made all of them a retried 503. #2191 fixed that for one limit.

This PR makes the answer a property of the error, chosen once:

  • MediaLimitOwner (artifact, operatorLimit, device) is now part of that error, stated at each of 11 throw sites.
  • EngineV2VisionPrefillError.disposition is a switch with no default:. A new error case does not compile until its answer is chosen.
  • MediaFailure.outward is the one mapping the single-Mac route and the two pair routes share, replacing the three catch chains.

Nothing a coordinator sees changes. Status, failure code, error reason, message text and telemetry are byte-identical for every error that can occur today.

Linked issue

Part of #2524 (decision 4: a cause is a value with one renderer). Independent of the other PRs in the epic.

Before

flowchart LR
  classDef bad fill:#cf222e,stroke:#82071e,color:#ffffff
  classDef ok fill:#1a7f37,stroke:#0f5323,color:#ffffff
  classDef step fill:#0969da,stroke:#0a3069,color:#ffffff
  T["Media preparation throws"]:::step --> R{"Which route"}
  R -- "single Mac" --> C1["Catch chain, copy 1"]:::step
  R -- "GLM pair" --> C2["Catch chain, copy 2"]:::step
  R -- "Qwen pair" --> C3["Catch chain, copy 3, no refusal event"]:::step
  C1 --> F{"clientFault cast ladder"}
  C2 --> F
  C3 --> F
  F -- "a listed case" --> A["400, the request is at fault"]:::ok
  F -- "default" --> B["Retried 503, whoever owns the limit"]:::bad
Loading

Behaviour: an artifact's own limit and this Mac's limit shared one error case and one answer. Code flow: three copies of the chain; the Qwen pair's missing refusal event was a fact about which copy you were in.

After

flowchart LR
  classDef bad fill:#cf222e,stroke:#82071e,color:#ffffff
  classDef ok fill:#1a7f37,stroke:#0f5323,color:#ffffff
  classDef step fill:#0969da,stroke:#0a3069,color:#ffffff
  classDef note fill:#9a6700,stroke:#633c01,color:#ffffff
  T["Media preparation throws, the limit's owner in the error"]:::step --> O["MediaFailure.outward, one function"]:::step
  O --> D{"disposition: switch with no default"}
  D -- "client fault" --> A["400, the request is at fault"]:::ok
  D -- "decode unavailable" --> U["503 media_memory_unavailable"]:::ok
  D -- "construction refusal" --> P{"route publishes refusal events"}
  P -- "single Mac, GLM pair" --> E["Event, then 503 capacity_busy"]:::ok
  P -- "Qwen pair" --> Q["503 capacity_busy, no event: stated, not accidental"]:::note
  N["New error case"]:::step --> X["Does not compile until it has an answer"]:::bad
Loading

Behaviour: identical for every request. Code flow: one mapping; the routes' one difference is a named property; who owns a limit is in the type.

What is pinned, and what is deliberately left wrong

MediaFailureDispositionTests drives 47 errors through the 3 routes: 141 answers, each a status, a failure code, an error reason, the outward text and the whole telemetry event. A pin taken on the previous code and the output after the change are byte-identical (cmp reports no difference).

Six answers look wrong. Each is a status or a reason the coordinator sees, so each flip needs platform review and is a change of its own. They are listed by name in the test, with an exact count, so the list can only shrink:

Known divergence Today What it arguably should be
artifactTowerLimitIsRetried An artifact-owned tower limit is a retried 503 A 400: every provider refuses it the same way
disabledVideoIsRetried A model whose config disables video answers a retried 503 A 400
pairImageRefusalIsUnmapped A raw pair error (pair stopping or unready) is a 500 here and a 400 at submission The same answer on both paths
qwenPairPublishesNoRefusalTelemetry The Qwen pair publishes no refusal event An event, as the other two routes publish
superCapacityCoversDeterministicRefusals Nemotron Super answers a retried 503 for deterministic causes too A 400 for those
templateFailureKeepsTheRefusalStatus A template failure during media preparation is a 503; the text path answers 500 One answer

Test plan

  • Pin first: 22 tests green on unmodified dev (5ce4b99783) with the three chains transcribed into the test, then green after. The 141-line pin file is byte-identical before and after
  • DARKBLOOM_RELEASE_ENVIRONMENT=prod swift build --jobs 6 --build-tests: complete
  • swift test --skip-build --no-parallel --filter 'MediaFailureDispositionTests|MediaLimitOwnerTests|VisionTowerBudgetTests|EngineV2VisionRoutingTests|DistributedQwenMediaIngressTests|GLMClusterTensorParallelMediaTests|VideoReaderFailureMappingTests|GLM5NextMediaReservationTests': 152 tests in 20 suites pass (rerun independently after the refactor pass)
  • Wider covering run: 232 tests in 31 suites pass, the same suites green on unmodified source; 18 CapacityQuoteEngine tests pass
  • Route wiring through the real scheduler: a construction failure on the Qwen pair is refused without a refusal event, and on the GLM pair with exactly one
  • make docs-check (216 OK), make changelog-check (63 valid), make docs-impact-check BASE=origin/dev (OK)
  • Whole provider suite, GPU and live suites: not run locally; CI

Would it have caught #2191? Partly, and the PR should not claim more. #2191's throw enforced the smaller of the artifact's and the operator's limit, which cannot be written now without stating an owner: that part is compile-time. But an artifact-owned limit answering 503 is one of the six listed divergences today, because three other artifact limits share that answer. So until the artifact answer flips, #2191's case would have appeared as a named entry in that list, not as a red build. #2153 is decode logic and is not covered.

Refactor pass

Done by an independent reviewer, second commit. No production logic changes.

  • Equivalence checked against dev. The reviewer compared outward with the three original chains cast by cast: identical through all five casts, differing only in telemetry, the model id and the request read for the media kind, each kept.
  • All 11 owners are classified correctly.
  • Two holes in the oracle closed. The divergence count was a ceiling, which let a corrected slot be refilled; it is exact now. And a walk over an error type forced a switch arm, not a row, so a wrong link dropped a row silently; a new test counts each walk's rows (shown red by skipping one link).
  • A comment and a doc sentence that overclaimed ("the three routes that prepare media") are corrected: MiMo's native media and Nemotron Super map their own failures.

Limitations and cautions for the follow-up flips

  • Do not flip .artifact to 400 wholesale. At two sites (GLM5NextVisionBudget.swift near lines 43 and 57) and in admit's overflow, the artifact owner fires only for an unusable artifact config or grid, never for an oversized request. A blanket flip would blame callers for an artifact defect. Only the 960,000-patch aggregate is a limit on the request.
  • conflictingPlaceholderIds is the same class: an artifact defect that fails every video request on every provider. The table marks it not artifact-owned, so it is in effect an unlisted seventh divergence.
  • A new error arm that nothing links, with the row count not raised, still passes. Closing that needs a CaseIterable mirror of each error enum.
  • Three owners, not four: no throw site enforces a live-memory limit through this error. That class is decodeUnavailable and the typed mediaMemoryUnavailable.
  • Not touched: MiMoV26EncodedMediaIngress.swift keeps its default arms, and the three parallel switches in ProviderLoop+ErrorMapping.swift are unchanged.

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
  • Yes — described above and matching side updated

Documentation impact

  • Canonical documentation updated: docs/architecture/inference.md (rule "native inference")
  • No documentation needed — reason:

No changelog fragment: nothing observable changes.

🤖 Generated with Claude Code


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

0xkydo and others added 2 commits November 22, 2026 04:35
… answers it

Whether a failed media preparation is the request's fault (400), this Mac
busy (a retried 503) or a decoder fault was chosen by a cascade of casts
with a default of "retry", copied into three catch chains. One error case,
towerBudgetExceeded(String), carried both the artifact's own 32,000-patch
limit and the operator's and the device's limits, and the default made all
of them a retried 503 (#2191).

MediaLimitOwner (artifact, operator, device) is now part of that error, and
each throw site states it. EngineV2VisionPrefillError.disposition is a
switch with no default, so a new case does not compile until its answer is
chosen. MediaFailure.outward is the one mapping the single-Mac route and the
two pair routes share; the one difference between them, that the Qwen pair
publishes no refusal event, is an explicit property of the route.

Nothing a coordinator sees changes. MediaFailureDispositionTests drives 47
errors through the three routes; all 141 answers (status, code, reason, text
and telemetry event) are byte-identical to a pin taken on the previous code.
Six answers that look wrong are listed by name in the test and left as they
are: each is a status or reason the coordinator sees, so each flip is a
reviewed change of its own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ence count, a walk that keeps its rows)

Independent behaviour-preserving cleanup. No production logic changes.

- The table's known divergences were held to a ceiling (at most six), which
  let a corrected slot be refilled with another. The count is exact now.
- A walk over an error type forced a switch arm, not a row: a wrong link
  dropped a row and nothing failed. eachWalkKeepsItsRows counts the rows of
  each walk. Shown red by skipping one link, then reverted.
- "The three routes that prepare media" was false: MiMo's native media and
  Nemotron Super map their own failures. The header, the doc and the test
  say which three share this mapping.
- A comment at one throw site still said it refuses retriably; the
  disposition decides that now.

The reviewer compared outward with the three chains on dev cast by cast:
identical through all five casts, differing only in telemetry, the model id
and the request read for the media kind, each kept. All eleven owners are
classified correctly.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@0xkydo 0xkydo added the area:provider Provider (Rust, runs on Apple Silicon) label Nov 22, 2026
@vercel

vercel Bot commented Nov 22, 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 22, 2026 1:33pm UTC
darkbloom-status Ready Ready Preview Nov 22, 2026 1:33pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 22, 2026 1:33pm UTC

Request Review

@0xkydo 0xkydo added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 22, 2026
@github-actions github-actions Bot removed the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 22, 2026

This branch was successfully deployed

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

Labels

area:provider Provider (Rust, runs on Apple Silicon)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant