Skip to content

Provider 0.10.2: prepare release; explain why a model load cannot reclaim memory - #1603

Merged
Gajesh2007 merged 172 commits into
masterfrom
fix/explain-unreclaimable-load-memory
Oct 25, 2026
Merged

Gajesh2007 merged 172 commits into
masterfrom
fix/explain-unreclaimable-load-memory

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1592 (base release/provider-0.10.2-features) so it ships in provider 0.10.2. Merge after #1592; then #1600 (release) is restacked on this PR. After #1592 squash-merges, this PR retargets to master.

Summary

When a model load is refused for memory, the refusal and darkbloom status now say why resident memory could not be reclaimed. This PR only adds diagnostics. Autopilot policy, eviction, holds and load-gate decisions do not change.

  • Refusals keep their existing text first and end with . Not evictable: <model> (<GB>: <reasons>). For example: Not evictable: glm-5.3-flash (171.3 GB: Autopilot hold until 2026-10-25T18:31:01Z; 1 request in flight; adopted by Autopilot outside the selected models).
  • False "actively serving" fixed. When only a hold or a transition blocked the load, the refusal used to end with and all loaded models are actively serving, even though the model was idle. It now says and no loaded model can be evicted, followed by the list.
  • Daemon state records eviction_exclusions (each non-evictable model and why) and the live serving_selection.
  • darkbloom status adds four lines:
    • Serving outside the enabled model filter, with the reason the model serves;
    • Autopilot placements, with each hold's expiry;
    • Not evictable for a load now;
    • Recorded <age> ago, under the last load error.
  • darkbloom autopilot status adds Adopted (serving outside the selection) and Held: <model> until <UTC> (<left>).

Why

A provider operator saw this refusal for Nemotron 3.5 Super: Insufficient memory (34.8 GB of LOAD room, need 83.6 GB) even after evicting every idle model (16.8 GB reclaimable) — refusing without evicting. At the time, GLM-5.3-Flash was resident and serving, although their enabled_models filter did not include it. Nothing on the machine said why GLM was serving or why it could not be evicted.

The refusal only meant that GLM was not an eviction candidate at that moment. The gate (evictableModelSlots) skips a resident model for any of six reasons and threw away which one applied:

  • an Autopilot placement hold;
  • requests in flight;
  • a local request;
  • an unload in progress;
  • a retained MTP-upgrade target;
  • a pin while Autopilot protects pins.

Reproduction: two causes, one status

UnreclaimableLoadMemoryTests reproduces the refusal byte for byte under both hypotheses. It runs CPU-only, with the real ProviderLoop, the real Autopilot command path and Super's real LOAD gate, on a scripted 256 GB machine with inert slots and no weights. The real CLI binary, run against the daemon state each scenario writes, reproduces the reported darkbloom status.

  • H1, an Autopilot operation: an admin operation (lease_seconds = 0, hold_seconds = 3600, as the coordinator sends it) adopts GLM outside the selection and holds it. The lease clears, so the phase reads waiting, but GLM keeps serving.
  • H2, a stale selection: GLM was in the daemon's selection when it started, and enabled_models was edited afterwards. A running daemon applies the filter only at its next start.

Once the hold expires, darkbloom status is identical line for line under H1 and H2. While a hold is active, status shows Cold load blocked (memory) instead of the reported Preload skipped (no eviction), so the reported status rules out an active hold at that moment. darkbloom autopilot status tells the two apart:

darkbloom autopilot status H1 (operation) H2 (stale selection)
Already printed before this PR Last transition: succeeded, Reason: coordinator placement, Target: glm-5.3-flash; --json: live.adopted_models: ["glm-5.3-flash"] none of these lines
Added by this PR Adopted (serving outside the selection): glm-5.3-flash, and while held Held: glm-5.3-flash until <UTC> (<left>) none

With this PR, darkbloom status names the cause directly:

  • H1: Serving outside the enabled model filter: glm-5.3-flash (adopted by an Autopilot operation)
  • H2: Serving outside the enabled model filter: glm-5.3-flash (in the running daemon's selection; the saved filter applies after a restart)

Before

Behavior

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
    V["filter: Super, Gemma<br/>resident: Gemma 16.8 GB,<br/>GLM 171.3 GB (outside the filter)"]:::ctx
    V -->|"Super load"| R["Insufficient memory … even after<br/>evicting every idle model …<br/>— refusing without evicting<br/>(no model named, no reason)"]:::bad
    V -->|"Super load, nothing evictable"| R2["Insufficient memory …<br/>and all loaded models<br/>are actively serving<br/>(false: GLM is held, not serving)"]:::bad
    V -->|"darkbloom status"| S["saved filter and warm models:<br/>nothing says why GLM serves"]:::bad
    V -->|"darkbloom autopilot status"| A["no adoption or hold lines"]:::bad
Loading

Code flow

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef code fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
    classDef data fill:#fef3c7,stroke:#b45309,color:#451a03
    classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
    P["evictableModelSlots()<br/>inline filter, six predicates"]:::code
    P -->|"evictable or not"| G["slot cap, evictUntilAvailable,<br/>evictUntilNemotronSuperFits"]:::code
    G -->|"refuse"| T["fixed refusal text<br/>(the reason is dropped)"]:::bad
    D[("DaemonState<br/>warm, advertised,<br/>autopilot snapshot")]:::data --> C["status, autopilot status<br/>(saved filter, warm models)"]:::bad
Loading

After

Behavior

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef ctx fill:#f1f5f9,stroke:#64748b,color:#0f172a
    classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
    V["filter: Super, Gemma<br/>resident: Gemma 16.8 GB,<br/>GLM 171.3 GB (outside the filter)"]:::ctx
    V -->|"Super load"| R["same text, then<br/>Not evictable: glm-5.3-flash (171.3 GB:<br/>Autopilot hold until …Z; 1 request<br/>in flight; adopted by Autopilot …)"]:::good
    V -->|"Super load, nothing evictable"| R2["Insufficient memory …<br/>and no loaded model can be evicted.<br/>Not evictable: glm-5.3-flash (…)"]:::good
    V -->|"darkbloom status"| S["Serving outside the enabled model filter<br/>Autopilot placements (hold expiry)<br/>Not evictable for a load now<br/>Last model-load error … Recorded … ago"]:::good
    V -->|"darkbloom autopilot status"| A["Adopted (serving outside the selection)<br/>Held: glm-5.3-flash until … (… left)"]:::good
Loading

Code flow

%%{init: {"flowchart": {"wrappingWidth": 400}}}%%
flowchart LR
    classDef code fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
    classDef new fill:#cffafe,stroke:#0e7490,color:#083344
    classDef data fill:#fef3c7,stroke:#b45309,color:#451a03
    classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
    X["evictionExclusions()<br/>model → reasons<br/>(same six predicates)"]:::new
    X --> P["evictableModelSlots()<br/>residents without an entry"]:::code
    P --> G["slot cap, evictUntilAvailable,<br/>evictUntilNemotronSuperFits<br/>(decisions unchanged)"]:::code
    X --> Rec["evictionExclusionRecords()<br/>EvictionExclusion.summary"]:::new
    G -->|"refuse"| T["refusal text<br/>+ Not evictable: …"]:::good
    Rec --> T
    Rec --> D[("DaemonState<br/>+ eviction_exclusions<br/>+ serving_selection")]:::data
    D --> C["StatusCommand+Residency,<br/>AutopilotStatusCommand"]:::good
Loading

Colors: grey = situation, indigo = existing code, cyan = new code, amber = daemon state, red = missing or false output, green = new operator-visible output. A refusal and a darkbloom status line come from the same renderer (DaemonState.EvictionExclusion.summary), so they cannot drift apart.

Exact messages from the reproduction (real refusals and real CLI output)
H1 refusal: Insufficient memory (34.8 GB of LOAD room, need 83.6 GB) even after evicting every idle model (16.8 GB reclaimable) — refusing without evicting. Not evictable: glm-5.3-flash (171.3 GB: Autopilot hold until 2026-10-25T18:31:01Z; 1 request in flight; adopted by Autopilot outside the selected models)
H2 refusal: … — refusing without evicting. Not evictable: glm-5.3-flash (171.3 GB: 1 request in flight)
Held only, nothing else resident:
  before: Insufficient memory (53.6 GB of LOAD room, need 83.6 GB) and all loaded models are actively serving
  after:  Insufficient memory (53.6 GB of LOAD room, need 83.6 GB) and no loaded model can be evicted. Not evictable: glm-5.3-flash (171.3 GB: Autopilot hold until …; adopted by Autopilot outside the selected models)

$ darkbloom status            (H1, hold active; excerpt)
Warm models: gemma-4-26b-qat-4bit, glm-5.3-flash
Serving outside the enabled model filter: glm-5.3-flash (adopted by an Autopilot operation)
Autopilot placements: glm-5.3-flash adopted outside the selected models, held until 2026-10-25T18:31:01Z (59m left)
Not evictable for a load now: glm-5.3-flash (171.3 GB: Autopilot hold until 2026-10-25T18:31:01Z; adopted by Autopilot outside the selected models)
Last model-load error: nvidia-nemotron-3.5-super: Insufficient memory (…) — refusing without evicting. Not evictable: glm-5.3-flash (…)
  Recorded 3h0m ago

$ darkbloom autopilot status  (H1, hold active; excerpt)
  Loaded in memory: gemma-4-26b-qat-4bit, glm-5.3-flash
  Adopted (serving outside the selection): glm-5.3-flash
  Held: glm-5.3-flash until 2026-10-25T18:31:01Z (59m left)
  Last transition: succeeded
  Reason: coordinator placement
  Target: glm-5.3-flash

Interface effects

  • Refusal text:

    • The existing text is unchanged and comes first; the tests pin these prefixes. loadErrorStatusCode is unaffected: .modelLoadFailed still maps to 503, and the slot refusal still matches slot.
    • The suffix is added only to slot-cap and eviction-gate refusals (evictUntilAvailable, evictUntilNemotronSuperFits) of loads that may evict, and only when a resident model was excluded.
    • Loads that never evict are unchanged: startup preload, Autopilot operation targets and revision updates.
  • Coordinator: nothing new reaches it. Routed requests carry only the failure code and status (loadInferenceFailure), and failed load_model pushes carry no reason (see follow-up 3).

  • Daemon state (daemon-state.json): two optional, additive keys.

    • serving_selection
    • eviction_exclusions, with model, resident_gb, reasons, hold_expires_at_ms, requests_in_flight and adopted_by_autopilot.

    Older files still decode. Only the CLI and the tests read these keys.

  • No changes to: protocol, heartbeat, telemetry, Autopilot policy, eviction or holds.

  • Docs: model-autopilot.md, hardware-support.md, inference.md, cli-reference.md, troubleshooting.md.

  • Changelog: changelog.d/explain-unreclaimable-load-memory.md.

Validation

Setup. All runs are CPU-only control-plane tests. Each run used a temporary CFFIXED_USER_HOME, HOME, DARKBLOOM_STATE_FILE, loaded-models file and verified-weights file. The sha256 of ~/.darkbloom/usage-history.json and of every top-level file in ~/.darkbloom was unchanged before and after every run.

What "before" means. "Before" is #1592's code at e72d1e2c2 with this PR's tests applied, rebuilt with provider-swift/Sources restored to e72d1e2c2. The counts match the original fail-before run on master (6e7382332). "After" is this PR's head, f0a66f72e, which is #1592 86d16da06 plus this PR. The focused and CLI status runs below were repeated after each merge of #1592: on 6de3cb640, 3d42ff4a6, c1e70fb81, and on a tree identical to f0a66f72e.

CI fix (3d42ff4a6, test-only). The first CI run (6de3cb640) failed 8 of these tests in Provider Unit Tests. Each was a test that runs the admin Autopilot operation, and the operation returned status: failed (InferenceError.modelLoadFailed).

  • Cause: the operation's reserve preflight (reserveRaiseKeepsSurvivorsServiceable → fleetKVBudgetBytes) reads machine memory from the engine slot hooks, or from ProcessInfo.physicalMemory if no hooks are installed. The fixture scripts a 256 GB machine but installed no hooks, so the suites passed only on a 256 GB Mac.
  • Fix: the fixture now installs the hooks with the scripted memory, as the Super managed-slot tests do.
  • Proof: reporting hw.memsize as 24 GiB to the test process (a sysctlbyname interposer) reproduces CI exactly: the same 8 tests fail with the same 25 issues. With the fix, the focused tests pass 53/53 at 8, 16, 24 and 64 GiB and on the real 256 GiB. CI on 3d42ff4a6 was fully green.
Suite Before After
UnreclaimableLoadMemoryTests (H1/H2 reproduction) 6/6 pass (reproduces the report) 6/6
UnevictableResidentReportTests 7/7 fail, 12 issues 7/7
ModelLoadEvictionAndAdmissionTests, ModelLoadRefusalTests (two exact-message assertions updated) 2 fail all pass
Focused provider total 53 tests: 9 fail, 14 issues 53/53
CLI StatusResidencyTests 2/2 fail, 7 issues 2/2
CLI status and uptime format (StatusCommandTests, StatusCommandRunTests: up 10m, up 1h1m) 15/15 15/15
CLI status total 17 tests: 2 fail, 7 issues 17/17
swift test --skip-build --no-parallel --filter 'UnreclaimableLoadMemoryTests|UnevictableResidentReportTests|ModelLoadEvictionAndAdmissionTests|ModelLoadRefusalTests'
swift test --skip-build --no-parallel --filter 'StatusResidencyTests|StatusCommandTests|StatusCommandRunTests'
make docs-check                                                      # 196 file(s) OK
make docs-impact-check BASE=origin/release/provider-0.10.2-features  # 21 changed file(s), coverage OK
make changelog-check                                                 # 27 valid fragment(s)
make changelog-preview                                               # renders this entry

Broader regression on 6de3cb640 (3d42ff4a6 changes only these two suites' fixture):

  • 384 control-plane tests (Autopilot, model loading and refusal, Super managed slot and load gate, MTP upgrade, Qwen4 reclaim, retirement, cold load, startup preload, and Provider 0.10.2 features: Super/GLM prefix caching, logprobs, GLM OpenRouter reasoning fields #1592's prompt-refusal logging): all pass except 2 MiMo tests. Those 2 need the MIMO_V26_SERIAL_LOAD_FIXTURES fixture environment, which is unset here, and fail at XCTUnwrap the same way on master.
  • Full CLI target: 688 of 689 pass. The one failure is ModelsLocationCommandTests.missingEnvironmentImportRefusesWithoutMutation, which picks <temp HOME>/hub under the test harness and fails the same way on the code before the refactor pass.

Limitations

  • Not run: the GPU and native suites, and the full make provider-test.
  • Cold GLM load not exercised on CPU. In the H1 test, GLM is already resident when the operation adopts it. The real load-then-adopt path is covered by the GPU tiny-model suite (AutopilotTinyModelTests), which was not run.
  • Cause on the reporting machine unproven. This PR does not show which hypothesis happened there. That machine's darkbloom autopilot status, start banner or the coordinator's operation records would decide it.
  • Reason still local. The refusal reason still does not reach the coordinator (follow-up 3).
  • Refactor pass not rerun for 3d42ff4a6. The pass below covers the code through 96e4e62f1. The later test-only fixture fix was not re-reviewed by a refactor subagent.

Merge order

Merge after #1592; then #1600 (release) is restacked on this PR.

Refactor pass

Refactor pass: CHANGED (96e4e62f1, independent refactor subagent, behavior-preserving). Status.compactDuration now delegates to the shared DurationFormatting.compact (identical output on 800,019 inputs). The docs and changelog now say exactly which refusals carry Not evictable:: slot-cap and eviction-gate refusals of loads that may evict, listing only the models excluded from eviction. No change to refusal text, daemon-state JSON, Autopilot policy or tests. Focused provider tests 53/53; CLI 687/688, the one failure a temp-HOME ModelsLocationCommandTests case that fails the same way on the pre-refactor code. docs-check, docs-impact-check (origin/master) and changelog-check pass.

Proposed follow-ups (not in this PR)

  1. Retry a skipped startup preload when memory frees. runStartupPreloadGate() runs once per process. A model skipped for memory at start stays unloaded until a request or a restart loads it.
  2. Live-apply enabled_models edits. A running daemon re-reads only Autopilot policy and download settings, so a changed filter waits for a restart. Status now says so.
  3. Carry the refusal reason to the coordinator. InferenceError has no LocalizedError, so a failed load_model reports The operation couldn’t be completed. (ProviderCore.InferenceError error 0.). Coordinate with the platform's load-failure classifier first.

Commits

All are SSH-signed and show as Verified on GitHub.

Commit What
6e7382332 Tests only: the H1/H2 scenario suite, UnevictableResidentReportTests, StatusResidencyTests, and two updated exact-message assertions
8aa42b96f The fix, plus docs and the changelog fragment
96e4e62f1 Refactor pass
80b75f4fd Merge of #1592 at fe4f353db (only conflict: troubleshooting.md's freshness stamp; kept 2026-10-25)
6de3cb640 Merge of #1592 at e72d1e2c2 (prompt-refusal logging; inference.md and cli-reference.md auto-merged with both sides kept)
3d42ff4a6 Test-only CI fix: the fixture pins re-slice memory to its scripted 256 GB machine (no refactor pass rerun for this five-line fixture change)
c1e70fb81 Merge of #1592 at d8e78e204 (GLM request-shape fixes; inference.md and cli-reference.md auto-merged with both sides kept)
f0a66f72e Merge of #1592 at 86d16da06 (MiMo tool-result name fix; inference.md auto-merged with both sides kept)

… on GLM

OpenRouter's provider-readiness test input-video-base64 failed on
glm-5.3-flash with 400 invalid_media. The clip is a variable-frame-rate
QuickTime movie (211 frames in 10.833 s), and GLM5NextProcessor refused it
with unsupported("variable-frame-rate video"), which the scheduler maps to
multimodal_rejected and then invalid_media.

- Bump mlx-swift-lm to the GLM5Next decoder fix: frames are indexed in
  presentation order and timed by the track's average rate, as in the
  reference loader (Layr-Labs/mlx-swift-lm#340).
- Admit data:video/mov (OpenRouter's documented QuickTime label) and
  data:video/x-m4v on the shared media ingest. MemoryBackedVideoAsset
  still identifies MP4 or QuickTime from the bytes.
- Scheduler-level regression test with the real OpenRouter fixtures and a
  label-alias ingest test; docs and changelog fragment.
The Super media binding refused any encoded body over 8 MiB as invalid
input, so OpenRouter's input-video-url readiness test (a 6.9 MB MP4 the
coordinator inlines into a 9.3 MB body) failed with invalid_media.

Raise NemotronSuperServingPolicy.maximumEncodedBodyBytes to 40 MiB, which
holds one part at the shared 25 MiB inline-media cap as base64 and any body
the provider's transports deliver, and make encodedHeaderQuote use it as
its single bound. A body above it now fails as media_too_large. The media
charge quotes and the default prefix bank follow the larger bound.

Add NemotronSuperOpenRouterVideoTests: both OpenRouter readiness clips
pass ingress, inspection, the pinned template's prompt, the media plan and
every frame's decode, and serve on the tiny installed fixture.
…Flash

OpenRouter's reasoning-content-return readiness task carries tools and
returns the model's reasoning on an assistant tool-call turn. GLM refused
it with 400 invalid_request while MiMo and Nemotron Super serve it.

Every GLM-only refusal of a shape both passing families accept is removed:

- strict tool declarations: served without constrained decoding; every
  auto call is already validated against its declared schema before it is
  exposed (ToolConstraintValidation.validate).
- empty-string history arguments read as {} (vLLM, MiMo and Super parity).
- reasoning: null, null reasoning members and include_reasoning: null are
  unset; reasoning.summary/generate_summary levels are no-ops.
- top-level thinking as a Boolean or GLM's API object
  {"type":"enabled"|"disabled","clear_thinking":Bool}.

Reasoning returned as OpenRouter's `reasoning` string or `reasoning_details`
text entries now renders as the template's reasoning_content instead of an
empty thinking block. Contradictions, unknown reasoning members,
preserve_thinking, forced tool choices and hidden reasoning stay refused.
…ests

NemotronSuperOpenRouterVideoTests copied NemotronSuperVideoBindingTests' tiny-fixture video owner (same tower, budget, load lease, context and teardown checks) and its generation-event recorder. Reuse videoOwner(contextLength:), VideoOwner.close() and SuperVideoEvents instead, and drop the unused MLXLMCommon import.

Correct two test comments: the inlined link makes a body of more than 9 MB here (9.39 MB once JSONSerialization escapes slashes, not 9.3), and only invalid input, not every other binding refusal, still leaves as invalid_media.
The 40 MiB encoded-body bound made the 8 MiB case pass ingress; it was refused only by the context bound the next case already covers. Over local HTTP the body bound is unreachable because the 32 MiB upload limit answers 413 first (tested above), and the binding's over-cap refusal is covered by oversizeBodyIsMediaTooLarge.
… the changelog

Required refactor pass; no behavior change.

- Bump libs/mlx-swift-lm 54227bab -> 6aef0a5d (Layr-Labs/mlx-swift-lm#340),
  which removes decodeFrames' frame-rate parameter left unused by the
  variable-frame-rate fix and updates two comments that still described
  constant-frame-rate-only decoding.
- The shared inline-video path also serves MiMo V2.6:
  MiMoV26EncodedMediaIngress calls MediaIngest.decodeVideo directly, so it
  admits the new video/mov and video/x-m4v labels too. Say so in the
  changelog fragment.
Owner decision. OpenRouter sends data:video/quicktime;base64, which every
model already admits: Nemotron Super passed OpenRouter's base64 readiness
test with OpenRouter's label, and the recorded request size fits that
28-character header exactly. The aliases also made the shared ingest accept
labels that Nemotron Super, in the provider and the coordinator, still
refuses.

- MediaIngest.decodeVideo again admits only data:video/mp4;base64 and
  data:video/quicktime;base64; MediaIngest.swift, MediaIngestTests.swift and
  the T-050 threat-model wording match master.
- The routing test keeps the real video/quicktime and video/mp4 readiness
  cases and drops the video/mov variant.
- Docs and the changelog fragment keep only the variable-frame-rate fix.
  The SDK pin and the GLM regression test are unchanged.
…the GLM path

The platform conformance fixtures hold OpenRouter's real tool-test bodies
(orIncidentOmitted, orIncidentAuto): the Boston weather prompt with a
strict, closed-schema get_current_weather tool and reasoning disabled.
Replay both byte for byte (hash-checked), the same body with tool_choice
none, and a five-step tool conversation built from them, through the
coordinator and local decode paths, the tool-stream handler, the GLM
policy and the shipped template. On master's policy every case fails with
"strict tool decoding is not qualified" (invalid_request); with the fix
they render.
Behavior-preserving refactor pass over the reasoning/strict commits. Correct the stale test name in docs/developer/test.md and say the captured requests are held byte for byte and hash-checked, cite RawControls.returnedReasoning precisely, list thinking: null in the changelog, name the conversation helper's merged assistant fields, drop an unused controls binding and a decode that remoteAndLocalInputs already performs.
OpenRouter's response-format-json-object and structured-output tests got
400 invalid_request: GLM's prompt policy refused every JSON
response_format. GLM's native engine refuses sampler token constraints,
so the Flint-style grammar is not available; GLM now follows the
prompt-plus-withheld-validation contract Nemotron Super uses:

- The service's response_format instruction renders through the shipped
  template; json_schema compiles to the shared fail-closed subset
  (compileResponseSchema now also requires explicit types, the check
  Flint already ran after it).
- GLM JSON requests route reasoning through the native channel splitter,
  so reasoning streams while the answer is withheld until generation
  ends. The answer is extracted (fences and surrounding prose removed),
  decoded, checked (root object, or ToolConstraintValidation.satisfies)
  and exposed once; anything else is a content-free 422.
- Withheld output records its generation time on the usage signal, so
  the relay's pre-content deadline and TTFT anchor see the first
  generated token, as they already do for withheld Flint reasoning.
- JSON with tools, unsupported schemas and JSON with image or video input
  stay 400s. No constraint is installed, so these rows keep MTP.
…st-validation

OpenRouter's tool-choice-required and tool-choice-function tests got 400
from the coordinator ("inference-enforced tool_choice (required/named) is
not supported for model glm-5.3-flash"): no provider listed GLM under
tool-constraint protocol v1, and the provider itself refused forced
choice in GLM's prompt policy and in ToolChoiceEnforcementPolicy.

GLM's native engine refuses sampler constraints, so forced choice uses
the structured post-validation strategy Qwen 3.5/3.8 and Nemotron use:

- ToolChoicePromptPolicy's forcing instruction renders through the
  shipped template; a named choice offers only the selected function.
- Forced GLM rows split reasoning on the native typed channel (as JSON
  mode does) and the native GLM parser withholds the call until end of
  stream; ToolConstraintValidation must accept it (function, schema,
  cardinality) before it is exposed. Visible text or a missing,
  malformed, truncated or schema-invalid call is a 422
  tool_noncompliance with nothing exposed.
- The forced strategy requires the native GLM parser.
- Providers advertise the managed GLM identities (glm-5.3-flash and the
  local qualification download) under tool-constraint protocol v1, so
  the coordinator's existing capability gate routes these requests to
  them without a coordinator change.
- Image or video input with a forced choice is refused with 400 before
  any media work, as JSON mode is. No constraint is installed, so these
  rows keep MTP.
GLM5NextManagedLoad now wraps the loaded tokenizer in
GLM5NextThinkingTokenizer, which requires <think> and </think>. The
synthetic managed fixture never gained them, so every opt-in
DARKBLOOM_TEST_GLM5_MANAGED_SYNTHETIC suite that loads it failed with
"tokenizer lacks the <think> tokens" before building an engine. CI does
not run these suites, so the drift went unnoticed.

ordinaryFactoryRunsTextHTTPImageAndProtectedEmbeddedMTP passes again on
an M3 Ultra (17 s).
GLM-5.3-Flash and MiMo V2.6 serve from native-tracked CBv2 engines.
EngineV2.validateRequest refuses a topLogprobs row or a token constraint
on them with an SDK-internal error, which the bridge reported as
"engine_v2 submit failed": a 500 generation_failure. The coordinator
counts 500s as provider sickness, so two logprobs requests cooled every
GLM provider for five minutes and its requests without tools were shed
as 429 "no provider for model ... is available right now", the failure
OpenRouter's top-logprobs test recorded.

EngineV2Bridge.nativeOutputControlRefusal refuses those requests first,
before any service or KV reservation, as the new
MultiModelBatchSchedulerEngineError.unsupportedOutputControl:
400 invalid_request with reason client_error, which never strikes the
breaker. The non-throwing submit path carries the same marker in-band.

GLM5NextLogprobsTests submits logprobs to the protected native GLM
bridge built from the synthetic managed fixture: 500 generation_failure
before, typed 400 after, and the engine keeps serving.
Load admission, KV budgets, cold-load capacity and the doctor/status
"usable now" figure all read SystemMemory.availableBytes, which counted
Mach free + inactive pages. Active file-backed pages counted as used, so
on an M5 Ultra whose page cache held the just-downloaded and re-hashed
GLM weights (vm_stat free 2.4 GB, active 55.7 GB, inactive 208.7 GB) the
provider reported 170.8 GB usable and refused GLM-5.3-Flash's 185.4 GB
cold load until `sudo purge`.

The default `reclaimable` policy now counts free pages plus the
file-backed page cache (external_page_count) and volatile purgeable
pages. Speculative read-ahead pages sit inside both free_count and
external_page_count and are counted once. Anonymous pages, active or
inactive, and compressor pages are never counted. `free-only` is
unchanged.

Tests reproduce host #1's counters (171.0 GiB usable before, refused;
211.5 GiB after, admitted) and keep anonymous and compressed pressure
refused.
The reclaimable policy now takes the larger of the former free +
inactive measure and the page-cache measure (free − speculative +
file-backed + purgeable). The page-cache measure alone gave less on a
shared Mac with much inactive anonymous memory: on an M3 Ultra running
other builds, doctor reported 77.6 GB usable where the former measure
gave 93.0 GB. Taking the maximum keeps that case unchanged while active
page cache still never blocks a load (host #1: 171.0 GiB -> 211.5 GiB).

The page-cache measure itself still counts no anonymous or compressed
memory; tests assert it separately, that the combined figure is exactly
the larger measure, and the busy shared-Mac sample.
…ut-control refusal

#1561 now refuses logprobs and token constraints on native-tracked
engines before submit (EngineV2Bridge.nativeOutputControlRefusal), and
GLM's protected engine is native-tracked. GLM JSON mode and forced
tool_choice are prompt-steered and validated after generation, so they
must reach that engine with neither.

The capability tests now record every submission the scheduler makes
and evaluate the production refusal on it as GLM's native-tracked
engine: each served JSON and forced request carries no token constraint
and no logprobs, so it is admitted. A logprobs row threaded the way the
coordinator handler threads it is refused, so the check is not vacuous.
OpenRouter tests every capability on our Super endpoint (tools, all
tool_choice modes, json_object, strict json_schema, reasoning on and off).
Replaying each test shape, derived from the captured OpenRouter tool request,
through the owner's relay path (inbound decode, native controls, response
format preparation, request plan, pinned template, output parser) admits all
of them except a JSON response format combined with tools: the request plan
refused that pair with 400 (unsupportedControl).

Serve it. The plan no longer refuses the pair, and the output validates the
format only for an answer: a turn that calls tools returns its calls, with
any text unchanged, and an answer without calls must be JSON for the format
(422 otherwise). A required or named tool_choice still needs its call.

NemotronSuperOpenRouterCapabilityTests replays all 20 shapes (10 tests,
reasoning enabled and disabled) and validates a compliant response for each,
streamed and complete; the captured request's SHA-256 is pinned to the
platform conformance fixture. The live HTTP test now serves both a call and a
JSON answer for a JSON format with tools, and refuses prose with 422.
GLM aligns the reasoning OpenRouter returns on earlier assistant turns
(`reasoning`, `reasoning_details`) with the decoded messages by index.
For a JSON response_format, MLXOpenAIService first inserts its
instruction turn after the leading system turns, so the counts differed
by one and the capture was dropped: those turns rendered an empty
thinking block in every JSON-mode multi-turn request.

The alignment now skips that inserted turn, at the position the service
inserts it (`OpenAIResponseFormatSupport.preparedRequest`). The
capability tests serve a JSON-mode conversation through the service,
with and without a leading system turn: returned `reasoning` and
`reasoning_details` render byte for byte like `reasoning_content`.
Pin mlx-swift-lm to baca4acf (#340 head plus "capture logprobs on
GLM5-Next native engines"): the GLM page-bank contract now qualifies
logprob capture, and EngineV2.acceptsLogprobRows reports it.

EngineV2Bridge.nativeOutputControlRefusal keeps the typed 400 for a
native engine that does not capture logprobs (MiMo) and for token
constraints on any native engine, and lets GLM logprob rows through to
the engine. On the coordinator relay the existing channel and SSE
splice return them as OpenAI logprobs.content entries.

A GLM logprob row samples through the ordinary sampler and never drafts.
GLM has no request-scoped target-only fallback, so steps that include
it decode target-only, as they do beside a GLM image row; output stays
exact and other rows speculate again once it finishes.

GLM5NextLogprobsTests now asserts served logprobs on the protected
native bridge built from the synthetic managed fixture: one entry per
generated token with the requested alternatives, descending, chosen
token first under greedy decoding, no drafts for the logprob row, and a
later plain request that still speculates.
…Router PR

Brings feat/glm-logprobs (f02327a): GLM serves logprobs in native mode, and the typed 400 now covers only MiMo logprobs and native token constraints. The SDK pin moves 6aef0a5d -> baca4acf (#340), which descends from 6aef0a5d and adds only the native logprobs commit.
The non-throwing submitTokenized wrapper re-yields two typed refusals as
their content-free in-band markers: tokenBudgetExhausted (capacity) and
unsupportedOutputControl (a native engine's refused logprobs row or token
constraint). Both had identical catch bodies; fold them into one
multi-pattern catch. Both throws already finalized their prefix-cache
lookup, and fromSchedulerMessage maps each marker back to the same typed
error, so the 400 invalid_request (client_error) and capacity outcomes are
unchanged.
…mat with tools) into the consolidated Super PR
The merged logprobs support (f02327a) gave
EngineV2Bridge.nativeOutputControlRefusal a capturesLogprobs argument and
made GLM's native engine serve logprob rows. The capability tests still
called the three-argument form, so the provider test products did not
build, and their control asserted that GLM refuses a logprobs row.

The scripted engine now evaluates the check for a given capture
capability. Each served response keeps GLM's decision (captures logprobs)
in nativeRefusals, which every JSON and forced row still asserts is nil,
and adds the decision of a native engine that cannot capture logprobs
(MiMo). The control, now
nativeEngineEvidenceAdmitsGLMLogprobsButRefusesNonCapturingEngines,
asserts GLM admits the logprobs row and the non-capturing engine refuses
it with the output-control prefix, so the evidence stays non-vacuous.
…182 GB

A GLM-5.3-Flash coordinator start read all 182 GB five times: the
startup registration hash, a pre-load WeightHasher pass, the native
loader's SHA-256 of every core file, the tensor reads and a post-load
WeightHasher pass (M5 Ultra: 25 s per hash pass, about 150 s to warm).
Standalone starts did four of them (141 s to listen on the M5).

The managed load already SHA-256-verifies every manifest file against
the catalog-pinned manifest before serving: core files in the native
reader before any header is parsed or payload read, the rest in
verifyAuxiliaryContents before the tokenizer loads, with file identities
rechecked through construction. It now records that result
(GLM5NextManagedLoad.verifiedArtifactSHA256, the manifest aggregate,
which is the value WeightHasher reports for those files) and both
ProviderLoop and StandaloneServer publish it instead of bracketing the
load with two more full passes. Integrity before serving is unchanged;
the dropped post-load pass only re-read disk, never the loaded bytes,
and any modification through the file system changes ctime, which the
load's identity checks refuse.

Coordinator-mode startup registration now reuses the last fully
verified hash of a managed-load model while every hashed file keeps its
device, inode, size and modification and status-change times
(VerifiedWeightHashStore, ~/.darkbloom/verified-weights.json, 0600).
The load verifies again before serving, so a stale or edited record can
misstate the registration claim but cannot serve unverified bytes. Any
changed file is hashed in full and re-recorded.

The load logs its phases (auxiliary verification, core verification,
tensors and construction). scripts/benchmarks/glm_load_timeline.py
turns a provider log into a timeline. The synthetic GLM fixtures gain
the <think>/</think> tokens the serving tokenizer has required since
#1516, so the gated managed and provider-loop suites run again.
Refactor pass for GLM JSON mode, structured outputs and forced
tool_choice. Behavior is unchanged.

- GLM5NextPromptPolicy.withholdsOutput names the requests whose output
  GLM withholds until it validates: a JSON response_format or a
  required/named call. The scheduler's media refusal and its text-path
  channel split and withheld-output recording each spelled that set
  separately; both now read the one predicate, so they cannot drift.
- The JSON-mode returned-reasoning alignment names its index
  (instructionIndex) and says why it is the last leading system turn.
- docs/developer/test.md describes the capability tests' current
  control: GLM admits a logprobs row that the same output-control check
  refuses for a native engine without logprobs capture.
@jonathan308 jonathan308 mentioned this pull request Oct 25, 2026
6 of 10 tasks
jonathan308 added a commit that referenced this pull request Oct 25, 2026
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog
entry from the 27 fragments added since v0.10.1, ordered by theme behind
an upgrade and rollout section: Nemotron 3.5 Super prefix caching
(#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590);
4-bit SSD checkpoints and the SSD prefix cache on every model (#1592
(mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and
GLM-5.3-Flash (#1564); OpenRouter compatibility: GLM-5.3-Flash and
MiMo-V2.6-Flash requests no longer refused (#1585, #1592); Speed: MTP
and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx-swift-lm#357),
#1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift-lm#362),
#1594); Provider diagnostics: refusal reasons and load memory (#1592,
#1603); MLX stack (#1596); Desktop release workflow (#1580). Apply 12
corrections reviewed against the code. #1580 is already in the v0.10.1
tag but merged after the 0.10.1 preparation, so its fragment is rendered
here.

Mark v0.10.1 as published on 2026-10-24. Record in the provider release
runbook the SDK pin check, the enablement order (darkbloom-platform#464
before any catalog logprobs change, the GLM allowlist tuple, then both
models' logprobs after the rollout and Super's tuple after a signed
restart check), the platform evidence and the published history. No tag,
registration, upload, deployment or enablement is performed.
jonathan308 added a commit that referenced this pull request Oct 25, 2026
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog
entry from the 27 fragments added since v0.10.1, ordered by theme behind
an upgrade and rollout section: Nemotron 3.5 Super prefix caching
(#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590);
4-bit SSD checkpoints and the SSD prefix cache on every model (#1592
(mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and
GLM-5.3-Flash (#1564); OpenRouter compatibility: GLM-5.3-Flash and
MiMo-V2.6-Flash requests no longer refused (#1585, #1592); Speed: MTP
and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx-swift-lm#357),
#1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift-lm#362),
#1594); Provider diagnostics: refusal reasons and load memory (#1592,
#1603); MLX stack (#1596); Desktop release workflow (#1580). Apply 14
corrections reviewed against the code. #1580 is already in the v0.10.1
tag but merged after the 0.10.1 preparation, so its fragment is rendered
here.

Mark v0.10.1 as published on 2026-10-24. Record in the provider release
runbook the SDK pin check, the enablement order (darkbloom-platform#464
before any catalog logprobs change, the GLM allowlist tuple, then both
models' logprobs after the rollout and Super's tuple after a signed
restart check), the platform evidence and the published history. No tag,
registration, upload, deployment or enablement is performed.
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog
entry from the 20 fragments added since v0.10.1, ordered by theme behind
an upgrade and rollout section: Nemotron 3.5 Super prefix caching
(#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590);
4-bit SSD checkpoints and the SSD prefix cache on every model (#1592
(mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and
GLM-5.3-Flash (#1564); GLM-5.3-Flash OpenRouter request controls (#1585,
#1592); Speed: MTP and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx-
swift-lm#357), #1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift-
lm#362), #1594); Provider diagnostics (#1592); MLX stack (#1596);
Desktop release workflow (#1580). Apply 12 corrections reviewed against
the code. #1580 is already in the v0.10.1 tag but merged after the
0.10.1 preparation, so its fragment is rendered here.

Mark v0.10.1 as published on 2026-10-24. Record in the provider release
runbook the SDK pin check, the enablement order (darkbloom-platform#464
before any catalog logprobs change, the GLM allowlist tuple, then both
models' logprobs after the rollout and Super's tuple after a signed
restart check), the platform evidence and the published history. No tag,
registration, upload, deployment or enablement is performed.

Co-authored-by: Jonathan Spangler <5055076+jonathan308@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 3c5cb0870563 against base f63554eb75f1.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Batch change context exceeds capacity; scan incomplete

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Human review required: CI did not complete the security review. A maintainer must review the saved findings and remaining scope. A green advisory job is not security clearance; do not manually rerun the paid scan.

Failure diagnostics: CHANGE_CONTEXT_LIMIT

Coverage: 42/218 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Bedrock: 12 request(s), 551360 uncached + 0 cache-read + 0 cache-write input / 9492 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately.
Workload allowance: 41 native request(s), including one shared response repair; 500 emergency ceiling. Selected depth and integration rounds are admitted as their scope becomes known.

…ot diagnostics branch

The tree is this branch's head (82a5de2: #1603 plus the squash of #1600's release preparation) plus exactly #1599's changes. A plain merge from the pre-#1592 merge base would have re-added the 27 changelog fragments that the release preparation folded into CHANGELOG.md, because master's squash adds them; this commit keeps them folded. #1599's own fragment (landing-agent-documents.md) stays pending for the next release.
@jonathan308

Copy link
Copy Markdown
Collaborator Author

This PR now completes provider 0.10.2

@jonathan308 jonathan308 changed the title provider: explain why a model load cannot reclaim memory (Autopilot holds, in-flight work, off-filter serving) Provider 0.10.2: prepare release; explain why a model load cannot reclaim memory Oct 25, 2026
@Gajesh2007
Gajesh2007 merged commit f9d1af3 into master Oct 25, 2026
25 checks passed
jonathan308 added a commit that referenced this pull request Oct 26, 2026
…ation

Merges Layr-Labs/d-inference master f9d1af3 (#1603, "Provider 0.10.2:
prepare release"), 32 commits past the merge base b004e23, into #1407
030fa64. 67 files changed on both sides: 29 conflicted, 38 auto-merged and
reviewed.

Gitlinks keep the cluster values (libs/mlx 79d2ebe8, libs/mlx-swift
59ff16af, libs/mlx-swift-lm 84112479) for the coordinator to re-pin to the
merged native stack and SDK. Master's code, and the follow-up commit, need
the merged SDK (master's 2026-10-22 SDK API changes).

Conflicts:
- GLM prompt and tool policy: master serves reasoning exclusion,
  required/named tool_choice and validated JSON output on every GLM slot,
  and removed reasoningExclusionUnsupported. Took master's
  GLM5NextPromptPolicy, NativeToolStreamRouter (withholdReasoning also
  counts the withheld reasoning) and ToolChoiceEnforcementPolicy. The
  cluster's pair-only gates are superseded and removed:
  admitsReasoningExclusion, glm5PairExcludesReasoning and the pair
  parameters of forcedStrategy and validateNativeControls (auto-merged
  callers in ToolStreamPreparation, ToolConstraintFactory and
  ProviderPromptContractPipeline follow). The pair keeps its single-call
  instruction for automatic choice with parallel_tool_calls false, folded
  into master's ToolChoicePromptPolicy.prepare before the GLM JSON contract
  is attached, so the rewrite cannot drop it.
- Scheduler: master's refusal of withheld output with media comes before
  the cluster's pair media dispatch; the cluster's timed prompt preparation
  takes master's prompt-token cache scope (tokenizeMeasured gains the same
  branch as tokenize), so single-Mac keeps prompt-token reuse.
- Local API: both logprob sources, master's raw-body owner channel and the
  cluster API's plumbing with reasoning-token counts.
- Coordinator path: master's typed nativeControlsRefusal in both places.
- ProviderLoop: cluster member guards first, then master's Autopilot model
  set, downloads and candidate verification (never on a member).
- Package.swift: master's traits: [] on the SDK plus libs/darkbloom-cluster.
- Registration, LaunchAgent, downloader, status, WeightHasher, translation
  markers, CLI subcommands, loop configuration: both sides.
- changelog.d/glm53-native-prerequisites.md: master rendered it into
  v0.10.0 and deleted it; kept only the cluster's unreleased peer-status
  bullet. No other cluster fragment is in master's CHANGELOG.md.
- Docs: both sides, later stamps; the Autopilot page states that a member
  downloads nothing.

GLMPairForcedOutputTests follow the merged contract: exclusion validates
and forced output takes the GLM strategy on every slot. A new case checks
that only the pair adds the single-call instruction and that the JSON
contract survives it.

Tested with the following commit and the merged native stack checked out
(mlx-swift 31cc0ce merge/56, core 95938c4b merge/35, mlx-c 8a50797b + main
build-only, SDK 3feac5c7 merge/308): see the follow-up commit.

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

This branch was successfully deployed

5 active deployments
Preview – d-inference — 3c5cb087 Deployed Oct 25, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 3c5cb087 Deployed Oct 25, 2026 by vercel[bot]
Preview – d-inference-landing — 3c5cb087 Deployed Oct 25, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 3c5cb087 Deployed Oct 25, 2026 by vercel[bot]
Preview – darkbloom-status — 3c5cb087 Deployed Oct 25, 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.

2 participants