Skip to content

feat: multi-model swap — download multiple models, serve one at a time - #225

Merged
Gajesh2007 merged 14 commits into
masterfrom
feat/multi-model-swap
May 27, 2026
Merged

Gajesh2007 merged 14 commits into
masterfrom
feat/multi-model-swap

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented May 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Providers can now select and download multiple models even when their combined size exceeds available RAM. Only one model is warm (loaded in GPU memory) at a time; the coordinator manages demand-driven model swaps via the existing load_model protocol.

Example

A machine with 36 GB RAM can now select both a 12 GB and a 26 GB model. Whichever model is warm is the one being served. When the warm model goes idle and demand arrives for the cold model, the coordinator triggers a swap.


Before / After Flow

Before: Request for cold model (no swap support)

sequenceDiagram
    participant C as Consumer
    participant Co as Coordinator
    participant P as Provider (12GB warm)

    C->>Co: POST /v1/chat/completions (model: 26GB)
    Co->>Co: QuickCapacityCheck
    Note over Co: freeMemoryAdmits: GPU memory<br/>occupied by 12GB model<br/>→ REJECT (no room for 26GB)
    Co-->>C: 429 Too Many Requests
    Note over C: Consumer retries forever<br/>or gives up. 26GB model<br/>is never served.
Loading

After: Request for cold model (demand-driven swap)

sequenceDiagram
    participant C as Consumer
    participant Co as Coordinator
    participant P as Provider (12GB warm, 26GB on disk)

    C->>Co: POST /v1/chat/completions (model: 26GB)
    Co->>Co: QuickCapacityCheck
    Note over Co: availableOnDisk=true<br/>provider idle (pending=0)<br/>26GB + KV + 4GB ≤ 36GB → ADMIT<br/>penalty: +30s (cold)
    Co->>Co: ReserveProviderEx (30s cost penalty)
    Co->>P: inference_request (26GB model)
    P->>P: ensureModelLoaded(26GB)
    P->>P: evict 12GB (LRU, idle)
    P->>P: load 26GB from disk
    P-->>Co: inference_accepted
    P-->>Co: inference_response_chunk (streaming)
    Co-->>C: 200 OK (streaming SSE)
Loading

Before: No warm provider, request queues

sequenceDiagram
    participant C as Consumer
    participant Co as Coordinator
    participant P as Provider (model A warm)

    C->>Co: POST /v1/chat/completions (model: B)
    Co->>Co: No warm provider for B
    Co->>Co: Queue request (120s timeout)
    Note over Co: No proactive action.<br/>Request waits until timeout.
    Co-->>C: 429 queue timeout (after 120s)
Loading

After: No warm provider, proactive swap + fast reject

sequenceDiagram
    participant C as Consumer
    participant Co as Coordinator
    participant P as Provider (model A warm, B on disk)

    C->>Co: POST /v1/chat/completions (model: B)
    Co->>Co: No warm provider for B → queue request
    Co->>Co: Heartbeat arrives
    Co->>Co: TriggerModelSwaps: B queued, no warm provider
    Co->>P: load_model(B)
    P->>P: evict A, load B
    P-->>Co: load_model_status: succeeded
    Co->>Co: MarkModelWarm(P, B)
    Co->>Co: DrainQueuedRequestsForModel(B)
    Co->>P: inference_request (model B)
    P-->>Co: inference_response_chunk
    Co-->>C: 200 OK (streaming SSE)

    Note over Co: If load fails instead:
    Note over Co: RejectUnservableQueuedRequests<br/>→ immediate 429 (not 120s wait)
Loading

Before: TUI model picker

flowchart TD
    A[User selects 12GB model ✓] --> B{Select 26GB model?}
    B -->|12 + 26 = 38 > 32 budget| C[❌ Blocked - won't fit]
    C --> D[User can only serve 1 model]
Loading

After: TUI model picker

flowchart TD
    A[User selects 12GB model ✓] --> B{Select 26GB model?}
    B -->|26 ≤ 32 individually| C[✓ Selected]
    C --> D[Status: one model active at a time - swap on demand]
    D --> E[Both models registered with coordinator]
    E --> F[Coordinator manages warm/cold swaps]
Loading

Before / After Table

Model Selection (TUI Picker)

Before After
Budget enforcement All selected models must fit in memory simultaneously Each model must individually fit; total can exceed RAM
36GB machine, 12GB + 26GB Blocked — 12 + 26 = 38 > 32 budget Allowed — shows "one model active at a time (swap on demand)"
Status line "X GB used · Y GB remaining" "X GB on disk · one model active at a time" or "all models can be served simultaneously"
"Won't fit" warning Based on remaining budget after other selections Based on whether model individually exceeds machine RAM
Pre-selection Largest downloaded model (even if exceeds RAM) Largest downloaded model that fits individually

Coordinator Routing

Before After
Cold provider admission Rejected — freeMemoryAdmits saw GPU memory occupied by warm model Admitted — checks if model individually fits in total RAM when provider is idle
Cold-start penalty 2.5 seconds (unrealistic) 30 seconds (matches real 15–60s swap time)
Idle warm slot penalty "idle" fell through to "unknown" → 30s "idle" treated as "running" → 0ms
Proactive model swap None — cold models only loaded on direct request TriggerModelSwaps sends load_model to idle cold providers when requests queue
Load deduplication N/A 2-min cooldown per (provider, model), one provider per pass, per-provider pending check
Load failure handling N/A Keep cooldown (no retry storm), reject queued requests if no alternative provider
Load success handling Wait up to 5s for next heartbeat MarkModelWarm + DrainQueuedRequestsForModel immediately
Unservable model Requests wait 120s queue timeout RejectUnservableQueuedRequests — immediate 429 if no provider can serve

Provider State Tracking

Before After
WarmModels on empty heartbeat Never cleared (stale entries persist) Always overwritten, including empty list
CurrentModel on nil heartbeat Never cleared (stale model ID) Cleared — prevents attestation hash mismatch
Warm detection for swap planning Only checked status (offline/untrusted) Full routing gates: trust, runtime, privacy, challenge freshness, catalog
BackendCapacity vs WarmModels WarmModels could override crashed slots BackendCapacity authoritative when present; WarmModels fallback for legacy only
Disconnect cleanup pendingModelLoads leaked Entries cleared by provider prefix on disconnect

Model Download Resume

Before After
HTTP 206 handling Deleted partial file, replaced with resumed bytes (corruption) Appends resumed bytes to existing partial via appendDownloadedRange
Content-Range validation None Validates start offset matches partial file size
Missing/malformed Content-Range N/A Discards stale partial, replaces with server response
Test mock No Content-Range header Sends proper Content-Range: bytes start-end/total

Files changed (9)

File Lines Change
provider-swift/.../StartCommand.swift +50/-10 TUI picker budget, status line, warnings, preselect guard
provider-swift/.../ModelCatalog.swift +78/-22 Download resume fix, Content-Range validation, appendDownloadedRange
provider-swift/.../ModelCatalogTests.swift +6/-1 Test mock sends Content-Range header
coordinator/registry/registry.go +380/-7 SendLoadModel, TriggerModelSwaps, MarkModelWarm, RejectUnservableQueuedRequests, ClearPendingModelLoad, providerHasPendingLoad, pendingModelLoads, heartbeat state fixes
coordinator/registry/scheduler.go +38/-5 availableOnDisk, freeMemoryAdmits cold path, slotStatePenalty idle/unknown, DrainQueuedRequestsForModel
coordinator/registry/queue.go +38/-0 QueuedModels, FailQueuedRequestsForModel
coordinator/api/provider.go +15/-0 load_model_status handler: success/failure paths
coordinator/api/billing_handlers.go +2/-2 gofmt (pre-existing)
coordinator/payments/pricing_test.go +4/-4 gofmt (pre-existing)

Testing

  • All 13 Go coordinator test packages pass (0 failures)
  • All 257 Swift provider tests pass across 20 suites
  • E2E integration tests pass
  • E2E benchmarks pass
  • 3 adversarial review rounds + 2 verification rounds completed

Deploy Order

  1. Coordinator first — backward compatible with old providers (they already handle load_model)
  2. Provider second — new TUI picker needs coordinator routing support to be useful

@vercel

vercel Bot commented May 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
d-inference Ready Ready Preview May 27, 2026 3:39am
d-inference-console-ui-dev Ready Ready Preview May 27, 2026 3:39am
d-inference-landing Ready Ready Preview May 27, 2026 3:39am

Request Review

@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 00:58 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.947s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.738s 1.738s 1.738s 1.738s
parse 4 1ms 1ms 1ms 1ms
reserve 4 2ms 2ms 2ms 2ms
route 4 14µs 17µs 17µs 17µs
encrypt 4 439µs 452µs 455µs 455µs
dispatch 4 37µs 37µs 48µs 48µs
coordinator_to_provider 4 1.73s 1.73s 1.731s 1.731s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.28825ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.361ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.72825ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.413ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=438.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=455µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=36.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=48µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.716s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.683s 3.713s 3.716s 3.716s
parse 4 2ms 2ms 2ms 2ms
reserve 4 2ms 2ms 3ms 3ms
route 4 22µs 23µs 25µs 25µs
encrypt 4 666µs 646µs 843µs 843µs
dispatch 4 49µs 45µs 67µs 67µs
coordinator_to_provider 4 2.155s 2.285s 2.286s 2.286s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=2.06125ms (threshold=1ms)
parse:p95<=5ms PASS p95=2.178ms (threshold=5ms)
reserve:mean<=50ms PASS mean=2.24775ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.162ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=665.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=843µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=48.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=67µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 16.245s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 815ms 179ms 3.925s 5.813s
parse 49 0s 0s 1ms 2ms
reserve 49 1ms 1ms 1ms 2ms
route 49 26µs 22µs 67µs 99µs
encrypt 50 478µs 455µs 766µs 835µs
dispatch 50 48µs 33µs 126µs 332µs
coordinator_to_provider 50 761ms 177ms 3.911s 5.807s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=449.326µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.122ms (threshold=5ms)
reserve:mean<=50ms PASS mean=833.02µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.401ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=477.86µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=766µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=47.84µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=126µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 4.323s
Throughput 2.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.547s 2.378s 3.198s 3.198s
parse 12 1ms 1ms 3ms 3ms
reserve 12 1ms 1ms 2ms 2ms
route 12 16µs 13µs 46µs 46µs
encrypt 12 1ms 1ms 1ms 1ms
dispatch 12 54µs 40µs 191µs 191µs
coordinator_to_provider 12 2.536s 2.366s 3.19s 3.19s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.217166ms (threshold=1ms)
parse:p95<=5ms PASS p95=2.867ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.469916ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.125ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=615.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.032ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=53.833µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=191µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.785s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.227s 2.227s 2.229s 2.229s
parse 4 1ms 1ms 2ms 2ms
reserve 4 2ms 2ms 2ms 2ms
route 4 15µs 20µs 23µs 23µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 44µs 35µs 81µs 81µs
coordinator_to_provider 4 2.22s 2.22s 2.222s 2.222s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.3925ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.745ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.86325ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.117ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=789.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.037ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=81µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 10.154s
Throughput 5.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 433ms 29ms 3.03s 3.052s
parse 60 0s 0s 1ms 2ms
reserve 60 1ms 1ms 1ms 4ms
route 60 21µs 19µs 38µs 111µs
encrypt 60 0s 0s 1ms 1ms
dispatch 60 40µs 32µs 137µs 156µs
coordinator_to_provider 60 430ms 27ms 3.025s 3.046s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=395.083µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.465ms (threshold=5ms)
reserve:mean<=50ms PASS mean=789.183µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.426ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=433.433µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=792µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=40.416µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=137µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 3.808s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.324s 2.646s 2.646s 2.646s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 18µs 21µs 25µs 25µs
encrypt 4 513µs 463µs 804µs 804µs
dispatch 4 20µs 16µs 39µs 39µs
coordinator_to_provider 4 2.319s 2.64s 2.641s 2.641s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.01325ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.043ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.49575ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.716ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=513.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=804µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=20µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=39µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.135s
Throughput 4.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 899ms 84ms 3.154s 3.154s
parse 30 1ms 0s 1ms 1ms
reserve 30 1ms 1ms 1ms 1ms
route 30 16µs 14µs 35µs 38µs
encrypt 30 340µs 325µs 412µs 984µs
dispatch 30 56µs 26µs 41µs 932µs
coordinator_to_provider 30 896ms 83ms 3.146s 3.149s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=504.4µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.057ms (threshold=5ms)
reserve:mean<=50ms PASS mean=729.6µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.353ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=339.8µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=412µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=55.966µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=41µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 7.033s
Throughput 4.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 850ms 26ms 2.472s 3.316s
parse 30 1ms 0s 1ms 1ms
reserve 30 1ms 1ms 1ms 2ms
route 30 26µs 23µs 75µs 77µs
encrypt 30 416µs 391µs 686µs 713µs
dispatch 30 39µs 31µs 91µs 138µs
coordinator_to_provider 30 846ms 24ms 2.466s 3.311s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=537.733µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.068ms (threshold=5ms)
reserve:mean<=50ms PASS mean=859.333µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.413ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=416.133µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=686µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=38.633µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=91µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 12
Errors 88
Total Duration 3.897s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.183s 2.194s 2.197s 2.197s
parse 12 5ms 5ms 5ms 5ms
reserve 12 6ms 6ms 7ms 7ms
route 12 29µs 32µs 71µs 71µs
encrypt 12 13ms 13ms 15ms 15ms
dispatch 12 63µs 56µs 151µs 151µs
coordinator_to_provider 12 2.148s 2.159s 2.163s 2.163s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=4.559ms (threshold=1ms)
parse:p95<=5ms FAIL p95=5.165ms (threshold=5ms)
reserve:mean<=50ms PASS mean=6.2675ms (threshold=50ms)
reserve:p95<=200ms PASS p95=6.703ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=13.408583ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=14.603ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=62.916µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=151µs (threshold=50ms)

Providers can now select and download multiple models even when their
combined size exceeds available RAM. Only one model is warm (loaded in
GPU memory) at a time; the coordinator manages demand-driven model
swaps via the existing load_model protocol.

Provider (Swift):
- TUI picker: removed simultaneous memory budget constraint; each model
  only needs to individually fit. Shows 'one model active at a time
  (swap on demand)' when total exceeds RAM.
- Fixed pre-existing download resume bug: range-resumption (HTTP 206)
  now appends to the partial file instead of replacing it.

Coordinator (Go):
- Cold-start routing: freeMemoryAdmits now admits idle providers that
  have the model on disk but not loaded, accounting for LRU eviction.
- Raised cold-start penalty from 2.5s to 30s (realistic for model swap
  times of 15–60s) so warm providers are strongly preferred.
- Proactive model swap: TriggerModelSwaps sends load_model to idle cold
  providers when queued requests have no warm provider. Includes
  deduplication (2-min cooldown per provider+model pair), one-provider-
  per-pass selection, and full routing safety gates (trust, runtime,
  privacy, challenge freshness, catalog).
- SendLoadModel, ClearPendingModelLoad, QueuedModels helpers.
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 01:04 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 5.352s
Throughput 0.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.349s 3.87s 3.87s 3.87s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 11µs 12µs 17µs 17µs
encrypt 4 376µs 394µs 415µs 415µs
dispatch 4 24µs 25µs 35µs 35µs
coordinator_to_provider 4 3.343s 3.864s 3.865s 3.865s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.01275ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.061ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.3ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.742ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=376.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=415µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=24.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=35µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.535s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.531s 3.531s 3.535s 3.535s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 2ms 2ms 2ms
route 4 14µs 18µs 19µs 19µs
encrypt 4 482µs 518µs 545µs 545µs
dispatch 4 44µs 32µs 99µs 99µs
coordinator_to_provider 4 1.947s 1.947s 1.948s 1.948s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.353ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.381ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.492ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.965ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=482.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=545µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=44µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=99µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 15.876s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 757ms 176ms 3.93s 5.882s
parse 49 0s 0s 1ms 2ms
reserve 49 1ms 1ms 1ms 2ms
route 49 28µs 23µs 59µs 81µs
encrypt 50 0s 0s 1ms 1ms
dispatch 50 57µs 34µs 184µs 334µs
coordinator_to_provider 50 704ms 173ms 3.924s 5.876s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=419.02µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.136ms (threshold=5ms)
reserve:mean<=50ms PASS mean=850.897µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.452ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=492.82µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=830µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=57.42µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=184µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 3.874s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.2s 2.033s 2.697s 2.697s
parse 12 3ms 1ms 5ms 5ms
reserve 12 2ms 2ms 4ms 4ms
route 12 21µs 15µs 62µs 62µs
encrypt 12 635µs 663µs 791µs 791µs
dispatch 12 29µs 25µs 47µs 47µs
coordinator_to_provider 12 2.18s 2.016s 2.68s 2.68s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=2.618666ms (threshold=1ms)
parse:p95<=5ms FAIL p95=5.253ms (threshold=5ms)
reserve:mean<=50ms PASS mean=2.358083ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.896ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=635µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=791µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=28.666µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=47µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.591s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.18s 2.18s 2.18s 2.18s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 12µs 12µs 16µs 16µs
encrypt 4 544µs 531µs 747µs 747µs
dispatch 4 19µs 21µs 23µs 23µs
coordinator_to_provider 4 2.174s 2.174s 2.175s 2.175s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.0705ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.181ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.35125ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.501ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=543.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=747µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=18.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=23µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 38
Errors 22
Total Duration 7.114s
Throughput 5.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 38 663ms 107ms 2.306s 2.306s
parse 38 1ms 0s 1ms 2ms
reserve 38 1ms 1ms 2ms 3ms
route 38 20µs 18µs 39µs 61µs
encrypt 38 1ms 0s 1ms 2ms
dispatch 38 49µs 34µs 211µs 222µs
coordinator_to_provider 38 659ms 105ms 2.3s 2.3s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=536.342µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.243ms (threshold=5ms)
reserve:mean<=50ms PASS mean=945.736µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.755ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=527.631µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.082ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=49.342µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=211µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 3.738s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.214s 2.214s 2.214s 2.214s
parse 4 1ms 1ms 1ms 1ms
reserve 4 2ms 2ms 2ms 2ms
route 4 20µs 16µs 38µs 38µs
encrypt 4 452µs 596µs 598µs 598µs
dispatch 4 25µs 27µs 28µs 28µs
coordinator_to_provider 4 2.207s 2.207s 2.207s 2.207s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.11025ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.175ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.86875ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.439ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=451.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=598µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=28µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.005s
Throughput 5.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 850ms 72ms 2.833s 2.833s
parse 30 1ms 0s 3ms 6ms
reserve 30 1ms 1ms 4ms 4ms
route 30 19µs 17µs 30µs 46µs
encrypt 30 1ms 0s 1ms 2ms
dispatch 30 52µs 35µs 141µs 317µs
coordinator_to_provider 30 842ms 70ms 2.815s 2.816s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=945.733µs (threshold=1ms)
parse:p95<=5ms PASS p95=2.955ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.2932ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.627ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=549.4µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.156ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=51.6µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=141µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.835s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 867ms 31ms 3.058s 4.027s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 34µs 28µs 39µs 274µs
encrypt 30 465µs 466µs 728µs 744µs
dispatch 30 36µs 31µs 75µs 122µs
coordinator_to_provider 30 864ms 29ms 3.052s 4.021s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=608.933µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.253ms (threshold=5ms)
reserve:mean<=50ms PASS mean=940.266µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.734ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=465.366µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=728µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=35.6µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=75µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 12
Errors 88
Total Duration 3.996s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.312s 2.292s 2.358s 2.358s
parse 12 4ms 4ms 5ms 5ms
reserve 12 5ms 5ms 8ms 8ms
route 12 13µs 12µs 24µs 24µs
encrypt 12 14ms 16ms 16ms 16ms
dispatch 12 43µs 45µs 70µs 70µs
coordinator_to_provider 12 2.278s 2.256s 2.336s 2.336s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=3.942083ms (threshold=1ms)
parse:p95<=5ms PASS p95=4.955ms (threshold=5ms)
reserve:mean<=50ms PASS mean=5.294ms (threshold=50ms)
reserve:p95<=200ms PASS p95=8.309ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=14.061083ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=16.07ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.666µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=70µs (threshold=50ms)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 007fce7f6b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1319 to +1321
if p.Status == StatusOffline || p.Status == StatusUntrusted {
return false
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Apply routing gates before treating a provider as warm

TriggerModelSwaps skips swap planning whenever hasWarmProviderLocked finds any warm copy, but this helper only excludes offline/untrusted providers and does not apply the same routability checks used elsewhere (runtime verified, challenge freshness, privacy capability, min trust). In a case where the only warm provider has stale attestation (or otherwise fails scheduler gates), queued requests for that model will never trigger load_model on eligible cold providers, so requests can sit in queue until timeout even though a routable provider exists.

Useful? React with 👍 / 👎.

Comment on lines +1329 to +1332
for _, warmModel := range p.WarmModels {
if warmModel == model {
return true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop using stale WarmModels to suppress model swaps

The new warm check falls back to p.WarmModels, but this list is not reliably cleared when a provider has no warm models (heartbeats can omit warm_models when empty), so stale entries can persist after unload. With that stale state, hasWarmProviderLocked returns true and TriggerModelSwaps skips sending load_model, leaving queued requests for that model stuck until timeout despite no provider actually running it.

Useful? React with 👍 / 👎.

if !r.providerServesCatalogModelLocked(p, model) {
return 0, false
}
return p.pendingCount(), true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict proactive model loads to idle providers

The swap planner can pick providers that still have in-flight work because modelLoadCandidatePendingLocked returns pendingCount as eligible regardless of whether it is zero, and bestModelLoadProviderLocked accepts that candidate. In a common single-slot case, sending load_model while another model is actively serving causes the provider to fail the preload (all model slots are active), then the coordinator clears pending and retries on subsequent heartbeats, creating repeated failed swaps and delaying useful warm-up.

Useful? React with 👍 / 👎.

Comment on lines +1095 to +1097
if http.statusCode == 206 {
try Self.appendDownloadedRange(tempFile, to: partial, label: label)
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate Content-Range before appending resumed bytes

On HTTP 206 responses, the downloader always appends the returned temp file to the existing .part without checking that the server actually started at the requested offset. If an origin/proxy returns a mismatched range, this appends duplicate or shifted bytes; for legacy CDN downloads that pass expectedSHA256: nil, that corruption is not detected before promotion to the final model file.

Useful? React with 👍 / 👎.

…idle-only swaps, Content-Range validation

- hasWarmProviderLocked now applies full routing gates (trust, runtime,
  privacy, challenge freshness) so stale-attested providers don't
  suppress model swaps
- Heartbeat always overwrites WarmModels (including empty) to clear
  stale entries after model unload
- bestModelLoadProviderLocked only selects idle providers (pendingCount
  == 0) to avoid failed load_model on busy single-slot providers
- Download resume validates Content-Range start offset before appending;
  falls back to full re-download on mismatch
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 01:23 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 5.391s
Throughput 0.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.379s 3.902s 3.902s 3.902s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 2ms 2ms 2ms
route 4 12µs 16µs 18µs 18µs
encrypt 4 478µs 411µs 833µs 833µs
dispatch 4 40µs 47µs 55µs 55µs
coordinator_to_provider 4 3.372s 3.896s 3.896s 3.896s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.0705ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.116ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.403ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.824ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=478.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=833µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=39.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=55µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.377s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.373s 3.374s 3.377s 3.377s
parse 4 2ms 2ms 2ms 2ms
reserve 4 2ms 3ms 3ms 3ms
route 4 15µs 16µs 19µs 19µs
encrypt 4 558µs 594µs 609µs 609µs
dispatch 4 37µs 42µs 44µs 44µs
coordinator_to_provider 4 1.789s 1.789s 1.79s 1.79s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.65525ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.83ms (threshold=5ms)
reserve:mean<=50ms PASS mean=2.243ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.834ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=558.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=609µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=36.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=44µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 16.644s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 788ms 185ms 3.898s 5.785s
parse 49 0s 0s 1ms 1ms
reserve 49 1ms 1ms 2ms 2ms
route 49 29µs 24µs 55µs 146µs
encrypt 50 0s 0s 1ms 1ms
dispatch 50 45µs 34µs 118µs 171µs
coordinator_to_provider 50 734ms 182ms 3.86s 5.779s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=390.632µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.147ms (threshold=5ms)
reserve:mean<=50ms PASS mean=831.02µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.596ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=482.54µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=750µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=44.92µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=118µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 4.405s
Throughput 2.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.518s 2.311s 3.156s 3.156s
parse 12 1ms 1ms 2ms 2ms
reserve 12 1ms 1ms 2ms 2ms
route 12 14µs 12µs 30µs 30µs
encrypt 12 587µs 551µs 940µs 940µs
dispatch 12 20µs 22µs 28µs 28µs
coordinator_to_provider 12 2.511s 2.305s 3.149s 3.149s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.09025ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.908ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.439583ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.881ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=587µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=940µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=20.416µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=28µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.7s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.967s 1.967s 1.967s 1.967s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 1ms 1ms
route 4 17µs 15µs 34µs 34µs
encrypt 4 439µs 444µs 503µs 503µs
dispatch 4 49µs 68µs 94µs 94µs
coordinator_to_provider 4 1.961s 1.961s 1.962s 1.962s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.079ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.187ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.30525ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.377ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=439.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=503µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=49µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=94µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 10.159s
Throughput 5.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 438ms 31ms 2.319s 3.152s
parse 60 0s 0s 1ms 1ms
reserve 60 1ms 1ms 2ms 2ms
route 60 19µs 19µs 33µs 46µs
encrypt 60 393µs 363µs 617µs 699µs
dispatch 60 36µs 30µs 102µs 128µs
coordinator_to_provider 60 435ms 29ms 2.313s 3.146s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=358.6µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.096ms (threshold=5ms)
reserve:mean<=50ms PASS mean=691.8µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.642ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=392.566µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=617µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=35.866µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=102µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 3.712s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.653s 2.79s 2.79s 2.79s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 11µs 13µs 15µs 15µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 22µs 22µs 23µs 23µs
coordinator_to_provider 4 2.648s 2.785s 2.785s 2.785s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.1385ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.198ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.36825ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.552ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=687µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.071ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=21.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=23µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.364s
Throughput 4.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 798ms 118ms 2.291s 2.292s
parse 30 1ms 0s 3ms 3ms
reserve 30 2ms 1ms 4ms 6ms
route 30 21µs 16µs 49µs 72µs
encrypt 30 1ms 0s 11ms 11ms
dispatch 30 37µs 30µs 82µs 108µs
coordinator_to_provider 30 788ms 116ms 2.272s 2.274s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=883.8µs (threshold=1ms)
parse:p95<=5ms PASS p95=2.961ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.513066ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.022ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=1.138633ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=10.594ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=36.533µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=82µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.536s
Throughput 4.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 821ms 37ms 2.964s 3.085s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 25µs 21µs 54µs 91µs
encrypt 30 0s 0s 1ms 1ms
dispatch 30 57µs 31µs 288µs 292µs
coordinator_to_provider 30 818ms 35ms 2.958s 3.079s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=523.733µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.164ms (threshold=5ms)
reserve:mean<=50ms PASS mean=915.1µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.742ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=466.7µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=904µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=56.766µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=288µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 12
Errors 88
Total Duration 4.016s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.347s 2.221s 3.032s 3.032s
parse 12 3ms 3ms 4ms 4ms
reserve 12 6ms 6ms 8ms 8ms
route 12 13µs 12µs 31µs 31µs
encrypt 12 13ms 15ms 15ms 15ms
dispatch 12 43µs 45µs 79µs 79µs
coordinator_to_provider 12 2.314s 2.185s 2.998s 2.998s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=3.118ms (threshold=1ms)
parse:p95<=5ms PASS p95=3.957ms (threshold=5ms)
reserve:mean<=50ms PASS mean=6.361916ms (threshold=50ms)
reserve:p95<=200ms PASS p95=7.767ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=13.289083ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=15.481ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.916µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=79µs (threshold=50ms)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 33c25dab4a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


slotStatePenaltyRunning = 0.0
slotStatePenaltyUnknown = 2_500.0
slotStatePenaltyUnknown = 30_000.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat idle warm slots as running

When a model is loaded but has no active requests, the Swift provider reports the slot state as idle (BatchScheduler+Telemetry.backendCapacity uses activeRequests > 0 ? "running" : "idle"). Since slotStatePenalty still falls through unknown states to slotStatePenaltyUnknown, raising this value to 30s now charges already-resident idle models the full cold-swap penalty. In a mixed fleet this can make the scheduler prefer an actually cold provider over a warm idle one, causing unnecessary model loads and much worse TTFT.

Useful? React with 👍 / 👎.

Comment on lines +1100 to +1104
if let rangeStart = Self.parseContentRangeStart(contentRange),
rangeStart != expectedStart {
// Range mismatch: discard partial and re-download fully.
try? fm.removeItem(at: partial)
try fm.moveItem(at: tempFile, to: partial)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Discard mismatched 206 ranges instead of promoting them

Fresh evidence: the new mismatch branch detects a Content-Range start that differs from the requested resume offset, but then removes the old .part and promotes the mismatched range body as the new partial, which is immediately moved to the final destination below. If an origin/proxy returns a shifted 206 response and expectedSHA256 is nil (the legacy download path), this can install a truncated or shifted model file instead of retrying a full download.

Useful? React with 👍 / 👎.

Comment thread coordinator/registry/registry.go Outdated
Comment on lines +1359 to +1360
if _, pending := r.pendingModelLoads[modelLoadKey(id, model)]; pending {
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Block providers with any pending model load

When multiple models are queued for the same idle machine, this only suppresses a duplicate (provider, same model) load; on the next heartbeat, while the first load_model is still pending and no inference is in pendingReqs, the same provider can be selected for a different model. The Swift provider serializes those loads, so the second preload can immediately evict or supersede the first before queued requests for the first model are drained, producing repeated swap oscillation or queue timeouts on single-provider/low-memory setups.

Useful? React with 👍 / 👎.

Comment on lines +1108 to +1110
} else {
// No Content-Range header: cannot verify, append optimistically.
try Self.appendDownloadedRange(tempFile, to: partial, label: label)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject unverifiable 206 resume responses

Fresh evidence: although the code now detects some mismatched Content-Range starts, it still appends the resumed bytes when a 206 response omits Content-Range or has a malformed value that parseContentRangeStart returns nil for. In that proxy/origin failure mode the coordinator cannot prove the returned bytes start at existingBytes, and for downloads without expectedSHA256 the corrupted .part is promoted to the final model file.

Useful? React with 👍 / 👎.

// AND passes the same routing safety gates used by the scheduler. A provider
// with stale attestation or failed privacy checks should not suppress swap
// planning. Caller must hold p.mu. Caller must hold r.mu (read or write).
func (r *Registry) providerHasWarmModelLocked(p *Provider, model string, now time.Time) bool {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the catalog gate before suppressing swaps

Fresh evidence: the warm-provider helper now applies the trust/runtime/privacy/freshness gates, but it still never calls providerServesCatalogModelLocked. If a provider has the requested ID warm but is no longer catalog-routable for that ID (for example a weight-hash mismatch after a catalog update), it can make TriggerModelSwaps skip loading the model on an eligible cold provider, while the normal scheduler will refuse to route to the warm provider.

Useful? React with 👍 / 👎.

…trictness, load oscillation, catalog gate

- slotStatePenalty: handle 'idle' state as running (0ms) — provider
  reports 'idle' for warm-but-no-active-requests models
- Content-Range: discard partial on missing/unparseable header instead
  of appending optimistically; test mock now sends Content-Range
- bestModelLoadProviderLocked: skip providers with ANY pending
  load_model (providerHasPendingLoad) to prevent swap oscillation
- providerHasWarmModelLocked: add catalog gate so retired/hash-changed
  models don't suppress swap planning
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 02:10 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 5.229s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.241s 3.75s 3.751s 3.751s
parse 4 2ms 2ms 2ms 2ms
reserve 4 2ms 2ms 2ms 2ms
route 4 23µs 21µs 35µs 35µs
encrypt 4 650µs 718µs 745µs 745µs
dispatch 4 51µs 49µs 77µs 77µs
coordinator_to_provider 4 3.231s 3.74s 3.741s 3.741s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.5245ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.708ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.789ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.122ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=650.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=745µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=50.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=77µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.48s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.463s 3.479s 3.48s 3.48s
parse 4 2ms 3ms 3ms 3ms
reserve 4 3ms 4ms 4ms 4ms
route 4 31µs 31µs 56µs 56µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 131µs 57µs 395µs 395µs
coordinator_to_provider 4 2.065s 2.188s 2.19s 2.19s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=2.27375ms (threshold=1ms)
parse:p95<=5ms PASS p95=2.998ms (threshold=5ms)
reserve:mean<=50ms PASS mean=2.87575ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.04ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=833µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.378ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=131µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=395µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 15.092s
Throughput 3.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 835ms 170ms 4.107s 6.031s
parse 48 0s 0s 1ms 3ms
reserve 48 1ms 1ms 2ms 7ms
route 48 27µs 24µs 57µs 102µs
encrypt 50 1ms 0s 1ms 2ms
dispatch 50 46µs 38µs 102µs 136µs
coordinator_to_provider 50 731ms 167ms 4.048s 6.025s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=451.875µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.074ms (threshold=5ms)
reserve:mean<=50ms PASS mean=959.812µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.908ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=550.98µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.026ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=46.38µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=102µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 4.207s
Throughput 2.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.367s 2.203s 2.956s 2.956s
parse 12 1ms 1ms 1ms 1ms
reserve 12 1ms 1ms 2ms 2ms
route 12 14µs 12µs 27µs 27µs
encrypt 12 503µs 449µs 772µs 772µs
dispatch 12 17µs 16µs 26µs 26µs
coordinator_to_provider 12 2.358s 2.197s 2.948s 2.948s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=918.083µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.308ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.265583ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.643ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=503.166µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=772µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=17µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=26µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.749s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.213s 2.213s 2.215s 2.215s
parse 4 1ms 1ms 2ms 2ms
reserve 4 2ms 2ms 2ms 2ms
route 4 12µs 13µs 18µs 18µs
encrypt 4 624µs 759µs 852µs 852µs
dispatch 4 36µs 17µs 106µs 106µs
coordinator_to_provider 4 2.207s 2.207s 2.209s 2.209s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.177ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.548ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.71325ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.994ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=624µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=852µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=36.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=106µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 9.706s
Throughput 6.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 502ms 86ms 3.15s 3.151s
parse 60 0s 0s 1ms 2ms
reserve 60 1ms 1ms 2ms 2ms
route 60 20µs 17µs 46µs 74µs
encrypt 60 383µs 337µs 716µs 760µs
dispatch 60 32µs 29µs 51µs 146µs
coordinator_to_provider 60 499ms 84ms 3.14s 3.143s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=392.65µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.387ms (threshold=5ms)
reserve:mean<=50ms PASS mean=686.566µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.573ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=383.266µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=716µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=32.416µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=51µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 3.435s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.032s 2.032s 2.032s 2.032s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 20µs 26µs 27µs 27µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 64µs 77µs 86µs 86µs
coordinator_to_provider 4 2.026s 2.026s 2.027s 2.027s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=973.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.046ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.27825ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.801ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=778µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.084ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=64µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=86µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.195s
Throughput 4.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 745ms 24ms 2.185s 2.185s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 4ms
route 30 17µs 17µs 33µs 33µs
encrypt 30 0s 0s 1ms 1ms
dispatch 30 44µs 27µs 127µs 180µs
coordinator_to_provider 30 741ms 21ms 2.179s 2.18s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=565.9µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.455ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.059166ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.003ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=458.833µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=719µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.666µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=127µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.798s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 825ms 159ms 2.403s 2.403s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 22µs 22µs 39µs 42µs
encrypt 30 448µs 453µs 763µs 867µs
dispatch 30 42µs 32µs 76µs 208µs
coordinator_to_provider 30 820ms 157ms 2.397s 2.398s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=641.9µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.436ms (threshold=5ms)
reserve:mean<=50ms PASS mean=974.733µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.744ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=447.933µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=763µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.166µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=76µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 16
Errors 84
Total Duration 5.097s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 16 2.841s 2.454s 4.241s 4.241s
parse 16 4ms 4ms 4ms 4ms
reserve 16 5ms 5ms 7ms 7ms
route 16 1.025s 0s 4.104s 4.104s
queue_wait 4 4.1s 4.099s 4.104s 4.104s
encrypt 16 12ms 16ms 16ms 16ms
dispatch 16 95µs 44µs 371µs 371µs
coordinator_to_provider 16 1.786s 2.333s 2.426s 2.426s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=3.672ms (threshold=1ms)
parse:p95<=5ms PASS p95=4.44ms (threshold=5ms)
reserve:mean<=50ms PASS mean=5.105562ms (threshold=50ms)
reserve:p95<=200ms PASS p95=6.703ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=11.522437ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=16.377ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=95µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=371µs (threshold=50ms)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 354cd7148a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coordinator/registry/registry.go Outdated
Comment on lines +1424 to +1429
key := modelLoadKey(action.providerID, action.modelID)
if _, pending := r.pendingModelLoads[key]; pending {
continue
}
r.pendingModelLoads[key] = now
reserved = append(reserved, action)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reserve model loads per provider

When two provider heartbeat goroutines call TriggerModelSwaps concurrently while different models are queued, both can plan against an empty pendingModelLoads map under the read lock, and this reservation step only rejects the exact (provider, model) key. Fresh evidence beyond the earlier heartbeat-ordering concern is that the write-side reservation still allows the second concurrent plan to reserve the same provider for a different model, so a single idle machine can receive overlapping load_model commands for A and B before either pending entry is visible to planning; the Swift provider serializes/evicts these loads, which can undo the first warm-up and leave queued requests timing out on low-capacity setups.

Useful? React with 👍 / 👎.

Comment thread coordinator/api/provider.go Outdated
Comment on lines +318 to +320
if statusMsg.Status == protocol.LoadModelStatusSucceeded ||
statusMsg.Status == protocol.LoadModelStatusFailed {
s.registry.ClearPendingModelLoad(providerID, statusMsg.ModelID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Drain queued requests when preloads succeed

When a demand-driven load_model finishes close to the queue timeout, this handler only clears the pending-load marker and then waits for a future heartbeat to report the model as warm before queued requests are drained. In the inspected provider loop, load_model_status: succeeded is sent immediately after ensureModelLoaded, so a request can still time out during the heartbeat gap even though the model was loaded in time; drain or otherwise wake the queue on terminal success for statusMsg.ModelID.

Useful? React with 👍 / 👎.

Comment on lines +1287 to +1292
for _, model := range queuedModels {
if r.hasWarmProviderLocked(model, now) {
continue
}

providerID := r.bestModelLoadProviderLocked(model, now, selectedProviders)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Plan swaps with request serial constraints

When a queued request has AllowedProviderSerials, this model-only planning can select and warm any provider for the model, but the queue drain later calls ReserveProviderEx with the original request and will still reject providers outside the allowed serial set. If the wrong provider becomes warm first, hasWarmProviderLocked suppresses further swaps for that model, so a serial-pinned request can time out even though an allowed cold provider could have loaded the model.

Useful? React with 👍 / 👎.

- reservePendingModelLoads: check providerHasPendingLoad (not just
  per-key) to prevent concurrent heartbeat goroutines from reserving
  the same idle provider for different models
- load_model_status handler: drain queued requests immediately on
  success instead of waiting for next heartbeat (up to 5s)
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 03:03 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.977s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.751s 1.751s 1.751s 1.751s
parse 4 3ms 4ms 4ms 4ms
reserve 4 3ms 3ms 4ms 4ms
route 4 32µs 23µs 66µs 66µs
encrypt 4 551µs 594µs 598µs 598µs
dispatch 4 37µs 42µs 56µs 56µs
coordinator_to_provider 4 1.733s 1.733s 1.734s 1.734s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=3.47075ms (threshold=1ms)
parse:p95<=5ms PASS p95=4.039ms (threshold=5ms)
reserve:mean<=50ms PASS mean=2.8355ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.69ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=551µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=598µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=36.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=56µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.968s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.934s 3.966s 3.968s 3.968s
parse 4 930µs 959µs 983µs 983µs
reserve 4 1ms 1ms 2ms 2ms
route 4 10µs 10µs 12µs 12µs
encrypt 4 435µs 446µs 710µs 710µs
dispatch 4 23µs 26µs 29µs 29µs
coordinator_to_provider 4 2.289s 2.425s 2.426s 2.426s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=930µs (threshold=1ms)
parse:p95<=5ms PASS p95=983µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.21475ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.636ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=434.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=710µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=23.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=29µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 17.727s
Throughput 2.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 877ms 189ms 5.61s 5.631s
parse 49 0s 0s 1ms 1ms
reserve 49 1ms 1ms 2ms 2ms
route 49 28µs 23µs 58µs 99µs
encrypt 50 1ms 0s 1ms 1ms
dispatch 50 49µs 37µs 149µs 180µs
coordinator_to_provider 50 823ms 186ms 5.604s 5.624s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=424.04µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.119ms (threshold=5ms)
reserve:mean<=50ms PASS mean=894.877µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.516ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=545.88µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=921µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=48.78µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=149µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 4.448s
Throughput 2.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.595s 2.394s 3.223s 3.223s
parse 12 1ms 1ms 1ms 1ms
reserve 12 2ms 2ms 3ms 3ms
route 12 15µs 15µs 33µs 33µs
encrypt 12 1ms 1ms 1ms 1ms
dispatch 12 26µs 25µs 43µs 43µs
coordinator_to_provider 12 2.585s 2.385s 3.217s 3.217s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=887.583µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.231ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.775833ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.366ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=692.166µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.304ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=26.166µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=43µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 5
Errors 35
Total Duration 4.802s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 5 2.622s 2.274s 4.014s 4.014s
parse 5 1ms 1ms 2ms 2ms
reserve 5 1ms 1ms 2ms 2ms
route 5 800ms 0s 4.001s 4.001s
queue_wait 1 4.002s 4.002s 4.002s 4.002s
encrypt 5 502µs 492µs 597µs 597µs
dispatch 5 31µs 24µs 67µs 67µs
coordinator_to_provider 5 1.816s 2.268s 2.268s 2.268s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.2868ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.602ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.4502ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.733ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=502.4µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=597µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=30.8µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=67µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 10.221s
Throughput 5.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 455ms 45ms 3.068s 3.068s
parse 60 0s 0s 1ms 2ms
reserve 60 1ms 1ms 1ms 1ms
route 60 23µs 19µs 54µs 118µs
encrypt 60 408µs 382µs 669µs 881µs
dispatch 60 33µs 28µs 86µs 104µs
coordinator_to_provider 60 452ms 43ms 3.06s 3.063s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=374.216µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.197ms (threshold=5ms)
reserve:mean<=50ms PASS mean=737.116µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.431ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=407.85µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=669µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=33.216µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=86µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.047s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.767s 2.949s 2.95s 2.95s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 18µs 18µs 24µs 24µs
encrypt 4 766µs 702µs 989µs 989µs
dispatch 4 91µs 125µs 173µs 173µs
coordinator_to_provider 4 2.761s 2.943s 2.944s 2.944s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.18725ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.331ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.4735ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.955ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=766.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=989µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=90.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=173µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.459s
Throughput 4.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 958ms 79ms 3.317s 3.32s
parse 30 1ms 0s 2ms 2ms
reserve 30 1ms 1ms 3ms 3ms
route 30 18µs 16µs 43µs 44µs
encrypt 30 436µs 374µs 702µs 819µs
dispatch 30 36µs 29µs 58µs 123µs
coordinator_to_provider 30 950ms 78ms 3.297s 3.3s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=708.733µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.916ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.146433ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.612ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=436.066µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=702µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=35.666µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=58µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.796s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 825ms 43ms 2.438s 2.438s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 3ms 3ms
route 30 35µs 22µs 82µs 285µs
encrypt 30 492µs 425µs 881µs 899µs
dispatch 30 48µs 30µs 159µs 170µs
coordinator_to_provider 30 821ms 40ms 2.432s 2.432s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=652.066µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.469ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.132033ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.71ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=491.733µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=881µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=47.866µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=159µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 14
Errors 86
Total Duration 4.652s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 14 2.626s 2.199s 3.973s 3.973s
parse 14 4ms 4ms 4ms 4ms
reserve 14 6ms 6ms 7ms 7ms
route 14 546ms 0s 3.825s 3.825s
queue_wait 2 3.823s 3.825s 3.825s 3.825s
encrypt 14 11ms 12ms 13ms 13ms
dispatch 14 43µs 35µs 76µs 76µs
coordinator_to_provider 14 2.049s 2.167s 3.015s 3.015s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=3.897ms (threshold=1ms)
parse:p95<=5ms PASS p95=4.436ms (threshold=5ms)
reserve:mean<=50ms PASS mean=5.643785ms (threshold=50ms)
reserve:p95<=200ms PASS p95=6.514ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=10.898857ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=13.499ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.928µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=76µs (threshold=50ms)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd7f43d780

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1509 to +1513
if !found {
p.BackendCapacity.Slots = append(p.BackendCapacity.Slots, protocol.BackendSlotCapacity{
Model: modelID,
State: "idle",
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear evicted slots when marking the new model warm

When a load_model_status:succeeded arrives after a preload that evicted the previous idle model, this only appends a synthetic slot for the new model and leaves the old BackendCapacity.Slots entries in place until the next heartbeat. In that pre-heartbeat window the scheduler and hasWarmProviderLocked still treat the evicted model as warm, so requests for the old model can be routed/swap-suppressed based on stale capacity state instead of warming a real provider for that model.

Useful? React with 👍 / 👎.

Comment on lines +1543 to +1545
candidates, capacityRejections := r.QuickCapacityCheck(modelID, 500, defaultRequestedMaxTokens)
if candidates > 0 || capacityRejections > 0 {
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore failed preload providers when deciding to fail the queue

When the only provider reports load_model_status:failed for a model (for example because its local weights are corrupt), this check still calls QuickCapacityCheck, which only sees that the same provider advertises the model and has theoretical capacity. Because the failed path deliberately keeps the pending-load entry as a cooldown, the queue is not rejected and no other provider can be selected, so consumers wait for the 120s timeout and the coordinator repeats the failed preload after the TTL instead of failing fast when there is no usable alternative.

Useful? React with 👍 / 👎.

When a swap evicts model A and loads model B, stale 'running'/'idle'
slots for A remained in BackendCapacity until the next heartbeat,
causing the scheduler to treat A as still warm. Now drops all warm
slots except the newly loaded model.
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 03:18 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.931s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.737s 1.737s 1.737s 1.737s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 2ms 2ms 2ms
route 4 20µs 19µs 43µs 43µs
encrypt 4 415µs 422µs 454µs 454µs
dispatch 4 33µs 34µs 34µs 34µs
coordinator_to_provider 4 1.729s 1.73s 1.73s 1.73s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.19875ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.267ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.426ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.725ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=415µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=454µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=32.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=34µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.219s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.215s 3.216s 3.219s 3.219s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 13µs 13µs 17µs 17µs
encrypt 4 432µs 441µs 443µs 443µs
dispatch 4 28µs 32µs 48µs 48µs
coordinator_to_provider 4 1.681s 1.681s 1.682s 1.682s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.049ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.08ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.374ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.663ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=432.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=443µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=28µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=48µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 15.684s
Throughput 3.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 852ms 176ms 5.684s 5.705s
parse 48 396µs 288µs 953µs 986µs
reserve 48 1ms 1ms 2ms 2ms
route 48 24µs 23µs 51µs 66µs
encrypt 50 516µs 486µs 827µs 888µs
dispatch 50 43µs 35µs 90µs 143µs
coordinator_to_provider 50 749ms 174ms 5.678s 5.699s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=396.02µs (threshold=1ms)
parse:p95<=5ms PASS p95=953µs (threshold=5ms)
reserve:mean<=50ms PASS mean=819.791µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.618ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=516.44µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=827µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.22µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=90µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 4.274s
Throughput 2.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.491s 2.234s 3.048s 3.048s
parse 12 1ms 1ms 1ms 1ms
reserve 12 2ms 2ms 3ms 3ms
route 12 16µs 15µs 41µs 41µs
encrypt 12 1ms 1ms 1ms 1ms
dispatch 12 23µs 21µs 42µs 42µs
coordinator_to_provider 12 2.482s 2.226s 3.04s 3.04s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=957.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.31ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.79875ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.734ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=642.333µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.386ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=23µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=42µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.189s
Throughput 1.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.946s 1.946s 1.946s 1.946s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 11µs 13µs 13µs 13µs
encrypt 4 491µs 552µs 567µs 567µs
dispatch 4 17µs 19µs 19µs 19µs
coordinator_to_provider 4 1.941s 1.941s 1.941s 1.941s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=918µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.001ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.3145ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.607ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=491µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=567µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=17µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=19µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 9.671s
Throughput 6.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 463ms 23ms 2.43s 3.177s
parse 60 0s 0s 1ms 2ms
reserve 60 1ms 1ms 2ms 2ms
route 60 21µs 17µs 59µs 66µs
encrypt 60 0s 0s 1ms 1ms
dispatch 60 32µs 27µs 77µs 129µs
coordinator_to_provider 60 460ms 21ms 2.423s 3.171s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=343.983µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.174ms (threshold=5ms)
reserve:mean<=50ms PASS mean=683.75µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.598ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=382.033µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=678µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=32.483µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=77µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 3.53s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.471s 2.638s 2.639s 2.639s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 1ms 1ms
route 4 12µs 17µs 17µs 17µs
encrypt 4 392µs 388µs 467µs 467µs
dispatch 4 29µs 29µs 38µs 38µs
coordinator_to_provider 4 2.465s 2.633s 2.633s 2.633s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.0225ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.046ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.309ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.465ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=391.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=467µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=28.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=38µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 5.441s
Throughput 5.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 727ms 71ms 2.661s 2.661s
parse 30 1ms 0s 2ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 14µs 13µs 25µs 29µs
encrypt 30 368µs 332µs 650µs 676µs
dispatch 30 34µs 28µs 68µs 155µs
coordinator_to_provider 30 723ms 69ms 2.654s 2.655s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=552.833µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.514ms (threshold=5ms)
reserve:mean<=50ms PASS mean=779.3µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.522ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=368.266µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=650µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=33.7µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=68µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.631s
Throughput 4.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 833ms 89ms 2.344s 3.06s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 26µs 23µs 45µs 76µs
encrypt 30 1ms 0s 1ms 2ms
dispatch 30 39µs 32µs 84µs 133µs
coordinator_to_provider 30 829ms 87ms 2.338s 3.053s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=600.6µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.48ms (threshold=5ms)
reserve:mean<=50ms PASS mean=932.833µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.93ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=519.166µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.019ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=39.233µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=84µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 12
Errors 88
Total Duration 4.253s
Throughput 2.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.306s 2.3s 2.33s 2.33s
parse 12 3ms 3ms 4ms 4ms
reserve 12 6ms 6ms 7ms 7ms
route 12 16µs 16µs 41µs 41µs
encrypt 12 10ms 11ms 15ms 15ms
dispatch 12 46µs 39µs 105µs 105µs
coordinator_to_provider 12 2.28s 2.277s 2.311s 2.311s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=2.900916ms (threshold=1ms)
parse:p95<=5ms PASS p95=3.864ms (threshold=5ms)
reserve:mean<=50ms PASS mean=6.063916ms (threshold=50ms)
reserve:p95<=200ms PASS p95=7.071ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=9.799583ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=14.777ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=45.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=105µs (threshold=50ms)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da353a853c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coordinator/registry/registry.go Outdated
Comment on lines +1511 to +1512
if slot.State == "running" || slot.State == "idle" {
continue // evicted — drop stale warm slot

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve warm slots when no eviction occurred

When a preload succeeds while the provider still has spare model slots, ensureModelLoaded does not evict existing models (it only evicts once modelSlots.count >= maxModelSlots), but this synthetic capacity update drops every other running/idle slot anyway. Until the next heartbeat, BackendCapacity is authoritative, so still-loaded models disappear from scheduler/warm-provider checks and can be treated as cold, causing unnecessary swaps or routing away from a provider that is already warm.

Useful? React with 👍 / 👎.

Provider may have multiple model slots loaded simultaneously
(maxModelSlots=3). Only add/update the new model's slot; leave
existing slots untouched. Next heartbeat provides authoritative state.
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 03:30 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.98s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.769s 1.769s 1.769s 1.769s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 15µs 10µs 37µs 37µs
encrypt 4 411µs 485µs 504µs 504µs
dispatch 4 34µs 32µs 46µs 46µs
coordinator_to_provider 4 1.763s 1.763s 1.764s 1.764s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.00975ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.085ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.2735ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.767ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=410.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=504µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=34µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=46µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.337s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.334s 3.334s 3.337s 3.337s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 1ms 1ms
route 4 8µs 7µs 13µs 13µs
encrypt 4 339µs 341µs 388µs 388µs
dispatch 4 22µs 23µs 30µs 30µs
coordinator_to_provider 4 1.789s 1.79s 1.79s 1.79s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=973.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.061ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.15925ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.486ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=339.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=388µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=22.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=30µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 17.402s
Throughput 2.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 813ms 184ms 3.867s 5.723s
parse 49 0s 0s 1ms 3ms
reserve 49 1ms 1ms 2ms 2ms
route 49 31µs 25µs 77µs 129µs
encrypt 50 1ms 0s 1ms 2ms
dispatch 50 47µs 38µs 106µs 129µs
coordinator_to_provider 50 759ms 181ms 3.852s 5.61s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=467.551µs (threshold=1ms)
parse:p95<=5ms PASS p95=988µs (threshold=5ms)
reserve:mean<=50ms PASS mean=910.428µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.593ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=502.52µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=907µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=46.66µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=106µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 3.774s
Throughput 3.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.163s 2.163s 2.185s 2.185s
parse 12 1ms 1ms 1ms 1ms
reserve 12 1ms 1ms 2ms 2ms
route 12 18µs 16µs 48µs 48µs
encrypt 12 0s 0s 1ms 1ms
dispatch 12 29µs 23µs 68µs 68µs
coordinator_to_provider 12 2.154s 2.156s 2.178s 2.178s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=952.166µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.402ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.14925ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.503ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=496µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.159ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=28.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=68µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.134s
Throughput 1.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.928s 1.928s 1.928s 1.928s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 10µs 9µs 20µs 20µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 16µs 18µs 20µs 20µs
coordinator_to_provider 4 1.922s 1.922s 1.922s 1.922s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.0285ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.056ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.41875ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.653ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=751µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.096ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=16.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=20µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 34
Errors 26
Total Duration 7.521s
Throughput 4.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 34 861ms 98ms 3.467s 3.486s
parse 34 1ms 0s 2ms 2ms
reserve 34 1ms 1ms 3ms 3ms
route 34 20µs 18µs 39µs 41µs
encrypt 34 1ms 0s 1ms 1ms
dispatch 34 56µs 30µs 99µs 809µs
coordinator_to_provider 34 857ms 96ms 3.46s 3.479s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=544.176µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.612ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.027823ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.65ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=525.147µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.219ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=56.352µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=99µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 3.944s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.741s 2.902s 2.903s 2.903s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 11µs 16µs 16µs 16µs
encrypt 4 438µs 426µs 586µs 586µs
dispatch 4 86µs 113µs 171µs 171µs
coordinator_to_provider 4 2.736s 2.897s 2.897s 2.897s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.09025ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.179ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.39775ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.513ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=437.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=586µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=85.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=171µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 5.974s
Throughput 5.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 806ms 75ms 2.865s 2.865s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 19µs 19µs 33µs 39µs
encrypt 30 0s 0s 1ms 1ms
dispatch 30 47µs 34µs 155µs 259µs
coordinator_to_provider 30 803ms 74ms 2.858s 2.859s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=525.9µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.487ms (threshold=5ms)
reserve:mean<=50ms PASS mean=805.633µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.504ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=467.033µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.035ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=47.3µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=155µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.668s
Throughput 4.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 758ms 88ms 2.224s 2.224s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 27µs 23µs 65µs 86µs
encrypt 30 458µs 417µs 699µs 830µs
dispatch 30 51µs 32µs 228µs 258µs
coordinator_to_provider 30 754ms 85ms 2.214s 2.218s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=610.366µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.433ms (threshold=5ms)
reserve:mean<=50ms PASS mean=905.366µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.646ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=457.933µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=699µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=51.466µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=228µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 12
Errors 88
Total Duration 4.339s
Throughput 2.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.716s 3.095s 3.148s 3.148s
parse 12 5ms 6ms 6ms 6ms
reserve 12 6ms 6ms 10ms 10ms
route 12 19µs 15µs 58µs 58µs
encrypt 12 14ms 15ms 16ms 16ms
dispatch 12 96µs 69µs 481µs 481µs
coordinator_to_provider 12 2.679s 3.058s 3.108s 3.108s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=5.40725ms (threshold=1ms)
parse:p95<=5ms FAIL p95=6.284ms (threshold=5ms)
reserve:mean<=50ms PASS mean=6.483166ms (threshold=50ms)
reserve:p95<=200ms PASS p95=10.222ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=14.4355ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=15.745ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=96.333µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=481µs (threshold=50ms)

Documents the overlapping state views (BackendCapacity vs WarmModels
vs CurrentModel vs pendingModelLoads), their precedence rules, and a
5-point checklist for mutating provider state. Learned from 10 fix
iterations on the multi-model swap feature.
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 03:34 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.938s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.727s 1.727s 1.727s 1.727s
parse 4 933µs 940µs 972µs 972µs
reserve 4 1ms 1ms 2ms 2ms
route 4 14µs 9µs 34µs 34µs
encrypt 4 330µs 368µs 373µs 373µs
dispatch 4 42µs 40µs 79µs 79µs
coordinator_to_provider 4 1.722s 1.722s 1.722s 1.722s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=933.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=972µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.154ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.528ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=329.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=373µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=42µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=79µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.289s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.285s 3.285s 3.289s 3.289s
parse 4 1ms 1ms 1ms 1ms
reserve 4 2ms 2ms 2ms 2ms
route 4 65µs 29µs 205µs 205µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 42µs 34µs 85µs 85µs
coordinator_to_provider 4 1.738s 1.738s 1.738s 1.738s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.29575ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.331ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.68175ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.249ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=869.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.185ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=42µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=85µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 16.348s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 719ms 183ms 3.671s 5.534s
parse 49 0s 0s 1ms 1ms
reserve 49 1ms 1ms 2ms 2ms
route 49 32µs 24µs 99µs 136µs
encrypt 50 1ms 0s 1ms 1ms
dispatch 50 50µs 34µs 144µs 217µs
coordinator_to_provider 50 665ms 180ms 3.666s 5.526s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=409.224µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.108ms (threshold=5ms)
reserve:mean<=50ms PASS mean=882.918µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.696ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=506.22µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=778µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=50.28µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=144µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 4.474s
Throughput 2.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.576s 2.359s 3.233s 3.233s
parse 12 1ms 1ms 2ms 2ms
reserve 12 2ms 2ms 2ms 2ms
route 12 10µs 9µs 21µs 21µs
encrypt 12 1ms 1ms 1ms 1ms
dispatch 12 95µs 35µs 423µs 423µs
coordinator_to_provider 12 2.567s 2.353s 3.226s 3.226s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=913.083µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.693ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.525916ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.267ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=808.083µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.362ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=94.916µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=423µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.736s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.05s 2.05s 2.05s 2.05s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 12µs 15µs 19µs 19µs
encrypt 4 398µs 359µs 569µs 569µs
dispatch 4 23µs 26µs 31µs 31µs
coordinator_to_provider 4 2.045s 2.045s 2.045s 2.045s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.0205ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.264ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.26025ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.518ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=398µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=569µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=22.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=31µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 10.491s
Throughput 5.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 465ms 41ms 2.331s 3.288s
parse 60 0s 0s 1ms 2ms
reserve 60 1ms 1ms 1ms 2ms
route 60 26µs 22µs 56µs 78µs
encrypt 60 416µs 361µs 724µs 798µs
dispatch 60 33µs 32µs 72µs 88µs
coordinator_to_provider 60 462ms 38ms 2.325s 3.281s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=324.7µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.073ms (threshold=5ms)
reserve:mean<=50ms PASS mean=751µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.445ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=416.383µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=724µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=33µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=72µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 3.485s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.185s 2.185s 2.185s 2.185s
parse 4 2ms 2ms 3ms 3ms
reserve 4 3ms 3ms 3ms 3ms
route 4 27µs 30µs 43µs 43µs
encrypt 4 682µs 705µs 733µs 733µs
dispatch 4 40µs 37µs 52µs 52µs
coordinator_to_provider 4 2.172s 2.172s 2.173s 2.173s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=2.341ms (threshold=1ms)
parse:p95<=5ms PASS p95=2.756ms (threshold=5ms)
reserve:mean<=50ms PASS mean=2.51525ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.829ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=682.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=733µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=39.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=52µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.174s
Throughput 4.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 754ms 98ms 2.163s 2.163s
parse 30 0s 0s 1ms 1ms
reserve 30 1ms 1ms 2ms 4ms
route 30 21µs 19µs 47µs 64µs
encrypt 30 405µs 347µs 659µs 877µs
dispatch 30 45µs 31µs 123µs 125µs
coordinator_to_provider 30 750ms 97ms 2.157s 2.158s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=463.866µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.117ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.007ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.034ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=404.666µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=659µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=44.8µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=123µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.732s
Throughput 4.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 784ms 72ms 2.266s 2.266s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 1ms 2ms
route 30 27µs 23µs 70µs 82µs
encrypt 30 0s 0s 1ms 1ms
dispatch 30 43µs 30µs 83µs 378µs
coordinator_to_provider 30 780ms 70ms 2.259s 2.26s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=523.333µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.245ms (threshold=5ms)
reserve:mean<=50ms PASS mean=932.833µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.471ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=493.8µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.106ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.266µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=83µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 13
Errors 87
Total Duration 4.677s
Throughput 2.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 13 2.533s 2.22s 4.028s 4.028s
parse 13 4ms 4ms 5ms 5ms
reserve 13 7ms 7ms 8ms 8ms
route 13 306ms 0s 3.972s 3.972s
queue_wait 1 3.972s 3.972s 3.972s 3.972s
encrypt 13 16ms 17ms 19ms 19ms
dispatch 13 46µs 49µs 67µs 67µs
coordinator_to_provider 13 2.189s 2.18s 2.947s 2.947s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=4.120153ms (threshold=1ms)
parse:p95<=5ms PASS p95=4.664ms (threshold=5ms)
reserve:mean<=50ms PASS mean=7.236ms (threshold=50ms)
reserve:p95<=200ms PASS p95=7.614ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=16.020923ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=18.908ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=45.769µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=67µs (threshold=50ms)

@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-27 03:40 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.941s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.743s 1.743s 1.743s 1.743s
parse 4 2ms 2ms 2ms 2ms
reserve 4 2ms 2ms 2ms 2ms
route 4 25µs 18µs 57µs 57µs
encrypt 4 567µs 596µs 691µs 691µs
dispatch 4 39µs 43µs 64µs 64µs
coordinator_to_provider 4 1.733s 1.734s 1.734s 1.734s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.56175ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.721ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.8655ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.48ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=567.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=691µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=38.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=64µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 4
Errors 16
Total Duration 3.278s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.275s 3.276s 3.278s 3.278s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 2ms 2ms 2ms
route 4 13µs 14µs 19µs 19µs
encrypt 4 436µs 464µs 476µs 476µs
dispatch 4 44µs 37µs 96µs 96µs
coordinator_to_provider 4 1.728s 1.728s 1.729s 1.729s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.1055ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.15ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.4365ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.855ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=436.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=476µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=96µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 15.539s
Throughput 3.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 823ms 180ms 5.703s 5.73s
parse 49 0s 0s 1ms 1ms
reserve 49 1ms 1ms 2ms 2ms
route 49 33µs 26µs 79µs 102µs
encrypt 50 1ms 0s 1ms 1ms
dispatch 50 48µs 36µs 125µs 136µs
coordinator_to_provider 50 769ms 176ms 5.694s 5.724s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=436.265µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.184ms (threshold=5ms)
reserve:mean<=50ms PASS mean=922.714µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.881ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=540.4µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=784µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=48.18µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=125µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 12
Errors 48
Total Duration 3.671s
Throughput 3.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.139s 1.989s 2.627s 2.627s
parse 12 2ms 2ms 3ms 3ms
reserve 12 2ms 2ms 3ms 3ms
route 12 48µs 16µs 371µs 371µs
encrypt 12 1ms 1ms 2ms 2ms
dispatch 12 41µs 30µs 146µs 146µs
coordinator_to_provider 12 2.125s 1.972s 2.617s 2.617s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.804833ms (threshold=1ms)
parse:p95<=5ms PASS p95=2.908ms (threshold=5ms)
reserve:mean<=50ms PASS mean=2.052583ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.117ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=757.833µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.615ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=41.333µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=146µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 4
Errors 36
Total Duration 3.512s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.214s 2.214s 2.214s 2.214s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 2ms 2ms
route 4 9µs 8µs 15µs 15µs
encrypt 4 443µs 428µs 602µs 602µs
dispatch 4 18µs 18µs 23µs 23µs
coordinator_to_provider 4 2.209s 2.208s 2.209s 2.209s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.16225ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.356ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.2595ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.558ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=442.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=602µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=17.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=23µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 10.359s
Throughput 5.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 445ms 39ms 2.259s 3.028s
parse 60 0s 0s 2ms 2ms
reserve 60 1ms 1ms 2ms 3ms
route 60 24µs 20µs 61µs 160µs
encrypt 60 0s 0s 1ms 2ms
dispatch 60 40µs 30µs 112µs 130µs
coordinator_to_provider 60 441ms 37ms 2.251s 3.02s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=452.416µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.584ms (threshold=5ms)
reserve:mean<=50ms PASS mean=811.566µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.855ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=432.3µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=720µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=40.066µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=112µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 4
Errors 26
Total Duration 4.06s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.664s 2.851s 2.851s 2.851s
parse 4 1ms 1ms 1ms 1ms
reserve 4 1ms 1ms 1ms 1ms
route 4 13µs 13µs 16µs 16µs
encrypt 4 643µs 596µs 970µs 970µs
dispatch 4 31µs 39µs 43µs 43µs
coordinator_to_provider 4 2.659s 2.846s 2.846s 2.846s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=1.01475ms (threshold=1ms)
parse:p95<=5ms PASS p95=1.107ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.1955ms (threshold=50ms)
reserve:p95<=200ms PASS p95=1.399ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=642.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=970µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=31.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=43µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.139s
Throughput 4.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 826ms 85ms 2.991s 3.137s
parse 30 1ms 0s 1ms 2ms
reserve 30 1ms 1ms 2ms 2ms
route 30 20µs 19µs 37µs 61µs
encrypt 30 0s 0s 1ms 1ms
dispatch 30 34µs 29µs 75µs 86µs
coordinator_to_provider 30 822ms 83ms 2.985s 3.13s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=524.7µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.335ms (threshold=5ms)
reserve:mean<=50ms PASS mean=875.333µs (threshold=50ms)
reserve:p95<=200ms PASS p95=1.571ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=434.233µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=680µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=34.266µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=75µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 6.608s
Throughput 4.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 799ms 28ms 2.388s 2.388s
parse 30 1ms 0s 2ms 2ms
reserve 30 1ms 1ms 3ms 3ms
route 30 32µs 23µs 55µs 220µs
encrypt 30 1ms 1ms 1ms 1ms
dispatch 30 0s 0s 0s 1ms
coordinator_to_provider 30 793ms 25ms 2.375s 2.378s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=836.833µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.982ms (threshold=5ms)
reserve:mean<=50ms PASS mean=1.338466ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.668ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=597.6µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.201ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=71.666µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=132µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 12
Errors 88
Total Duration 4.601s
Throughput 2.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.731s 2.449s 3.448s 3.448s
parse 12 5ms 5ms 6ms 6ms
reserve 12 6ms 6ms 7ms 7ms
route 12 15µs 13µs 31µs 31µs
encrypt 12 17ms 17ms 17ms 17ms
dispatch 12 65µs 68µs 96µs 96µs
coordinator_to_provider 12 2.688s 2.404s 3.405s 3.405s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms FAIL mean=5.162583ms (threshold=1ms)
parse:p95<=5ms FAIL p95=5.566ms (threshold=5ms)
reserve:mean<=50ms PASS mean=6.10875ms (threshold=50ms)
reserve:p95<=200ms PASS p95=7.06ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=16.626416ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=17.391ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=65.083µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=96µs (threshold=50ms)

@Gajesh2007
Gajesh2007 merged commit 48d4926 into master May 27, 2026
18 checks passed
@Gajesh2007
Gajesh2007 deleted the feat/multi-model-swap branch May 27, 2026 03:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3955b8404

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
}
snap.modelLoaded = snap.slotState == "running"
snap.availableOnDisk = !snap.modelLoaded

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat idle slots as loaded before cold admission

When a Swift provider reports the requested model in an idle slot, this new availableOnDisk flag still becomes true because modelLoaded only recognizes running. In the no-token-budget/backward-compatible path, freeMemoryAdmits then takes the cold-swap branch for an already-loaded idle model and ignores gpuMemoryActiveGB; with multiple idle models filling memory, a request can be routed even when there is not enough free memory for its KV cache, leading to provider-side OOM/failure. Mark idle as loaded here (as slotStatePenalty now does) so loaded models use the normal free-memory check.

Useful? React with 👍 / 👎.

// alongside active models.
if snap.availableOnDisk && !snap.modelLoaded && snap.totalPending == 0 {
const osReserveGB = 4.0
return snap.modelSizeGB+kvCacheGB+osReserveGB <= snap.totalMemoryGB

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the provider's load headroom for cold routes

For an idle provider that only has the model on disk, this new admission path accepts the route when catalog disk size plus KV plus 4 GB fits in total RAM, but the Swift provider's actual ensureModelLoaded gate requires modelInfo.estimatedMemoryGb * 3.0 headroom before loading. In the common case where a large model satisfies this coordinator check but fails the provider's stricter load gate, direct cold requests are routed to a provider that immediately errors instead of staying queued/trying another capable machine; the cold-route check needs to mirror the provider load headroom (or otherwise exclude models the provider will reject).

Useful? React with 👍 / 👎.

Comment on lines +324 to +328
case protocol.LoadModelStatusFailed:
// Keep the pending entry (TTL cooldown suppresses retry storms).
// If no other provider can serve this model, reject queued
// requests immediately rather than making them wait 120s.
s.registry.RejectUnservableQueuedRequests(statusMsg.ModelID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor preload cooldown during direct routing

When a preload fails, this branch intentionally leaves the pending-load entry in place as a cooldown, but that state is only consulted by TriggerModelSwaps; ReserveProviderEx/QuickCapacityCheck still see the same idle provider as routable. A new direct request for the same cold model during the TTL can therefore be sent right back to the provider that just failed to load it, producing an immediate provider-side 500 instead of suppressing that provider until the cooldown expires or another provider is chosen.

Useful? React with 👍 / 👎.

hankbobtheresearchoor pushed a commit to hankbobtheresearchoor/d-inference that referenced this pull request May 28, 2026
Layr-Labs#225)

* feat: multi-model swap — download multiple models, serve one at a time

Providers can now select and download multiple models even when their
combined size exceeds available RAM. Only one model is warm (loaded in
GPU memory) at a time; the coordinator manages demand-driven model
swaps via the existing load_model protocol.

Provider (Swift):
- TUI picker: removed simultaneous memory budget constraint; each model
  only needs to individually fit. Shows 'one model active at a time
  (swap on demand)' when total exceeds RAM.
- Fixed pre-existing download resume bug: range-resumption (HTTP 206)
  now appends to the partial file instead of replacing it.

Coordinator (Go):
- Cold-start routing: freeMemoryAdmits now admits idle providers that
  have the model on disk but not loaded, accounting for LRU eviction.
- Raised cold-start penalty from 2.5s to 30s (realistic for model swap
  times of 15–60s) so warm providers are strongly preferred.
- Proactive model swap: TriggerModelSwaps sends load_model to idle cold
  providers when queued requests have no warm provider. Includes
  deduplication (2-min cooldown per provider+model pair), one-provider-
  per-pass selection, and full routing safety gates (trust, runtime,
  privacy, challenge freshness, catalog).
- SendLoadModel, ClearPendingModelLoad, QueuedModels helpers.

* chore: gofmt billing_handlers.go and pricing_test.go

* fix: address review — routing gates on warm check, stale WarmModels, idle-only swaps, Content-Range validation

- hasWarmProviderLocked now applies full routing gates (trust, runtime,
  privacy, challenge freshness) so stale-attested providers don't
  suppress model swaps
- Heartbeat always overwrites WarmModels (including empty) to clear
  stale entries after model unload
- bestModelLoadProviderLocked only selects idle providers (pendingCount
  == 0) to avoid failed load_model on busy single-slot providers
- Download resume validates Content-Range start offset before appending;
  falls back to full re-download on mismatch

* fix: address second review round — idle slot penalty, Content-Range strictness, load oscillation, catalog gate

- slotStatePenalty: handle 'idle' state as running (0ms) — provider
  reports 'idle' for warm-but-no-active-requests models
- Content-Range: discard partial on missing/unparseable header instead
  of appending optimistically; test mock now sends Content-Range
- bestModelLoadProviderLocked: skip providers with ANY pending
  load_model (providerHasPendingLoad) to prevent swap oscillation
- providerHasWarmModelLocked: add catalog gate so retired/hash-changed
  models don't suppress swap planning

* fix: per-provider reservation race + drain queue on load success

- reservePendingModelLoads: check providerHasPendingLoad (not just
  per-key) to prevent concurrent heartbeat goroutines from reserving
  the same idle provider for different models
- load_model_status handler: drain queued requests immediately on
  success instead of waiting for next heartbeat (up to 5s)

* fix: adversarial review — BackendCapacity authority, load failure backoff, disconnect cleanup, TUI preselect

- providerHasWarmModelLocked: BackendCapacity is authoritative when
  present; only 'running'/'idle' slots count as warm. Prevents crashed
  slots from suppressing needed model swaps via stale WarmModels.
- load_model_status: only clear pendingModelLoads on success. Failures
  retain the 2-min cooldown to prevent retry storms against providers
  that consistently fail (deleted files, OOM).
- Disconnect: clear pendingModelLoads entries for the disconnected
  provider to prevent stale entries from blocking future swaps.
- TUI preselect: check canFitIndividually before preselecting a
  downloaded model.

* feat: reject queued requests immediately when model is unservable

When load_model fails and no other provider can serve the model,
queued requests are now rejected immediately with a fast error
instead of waiting 120 seconds for the queue timeout.

- FailQueuedRequestsForModel: sends nil to all ResponseChs, causing
  waiters to receive ErrQueueTimeout
- RejectUnservableQueuedRequests: checks QuickCapacityCheck after a
  load failure; if no eligible provider exists, flushes the queue
- Wired into load_model_status handler alongside the existing
  success/drain path

* fix: clear stale CurrentModel on nil heartbeat, mark provider warm before queue drain

- Heartbeat: clear CurrentModel when active_model is nil/omitted,
  preventing attestation challenges from comparing against unloaded
  models
- load_model_status:succeeded: call MarkModelWarm before draining so
  the scheduler sees the provider as warm immediately, not after the
  next heartbeat (up to 5s delay)

* fix: RejectUnservableQueuedRequests must check capacityRejections

Only reject queued requests when NO provider serves the model at all.
If providers exist but are temporarily at capacity, requests should
wait — those providers may finish current work and become available.

* fix: MarkModelWarm injects synthetic BackendCapacity slot

The scheduler uses BackendCapacity.Slots (not WarmModels) for Swift
providers. When load_model_status:succeeded arrives before the next
heartbeat, the model had no slot so the scheduler still saw it as
cold/unknown. Now injects an 'idle' slot so DrainQueuedRequestsForModel
immediately routes to the just-warmed provider.

* fix: MarkModelWarm clears stale evicted slots from BackendCapacity

When a swap evicts model A and loads model B, stale 'running'/'idle'
slots for A remained in BackendCapacity until the next heartbeat,
causing the scheduler to treat A as still warm. Now drops all warm
slots except the newly loaded model.

* fix: MarkModelWarm preserves existing warm slots

Provider may have multiple model slots loaded simultaneously
(maxModelSlots=3). Only add/update the new model's slot; leave
existing slots untouched. Next heartbeat provides authoritative state.

* docs: add coordinator state model and mutation checklist to AGENTS.md

Documents the overlapping state views (BackendCapacity vs WarmModels
vs CurrentModel vs pendingModelLoads), their precedence rules, and a
5-point checklist for mutating provider state. Learned from 10 fix
iterations on the multi-model swap feature.

* docs: fix WarmModels reader list — include legacy ScoreProvider and /v1/me/providers
ethenotethan added a commit that referenced this pull request May 28, 2026
* refactor: extract per-package config structs from main.go

Each package now owns its Config struct and ReadConfig() function
with env var constants scoped to the package that consumes them:

- coordinator/config: AppConfig composition + shared helpers
- coordinator/store: database URL / memory store selection
- coordinator/billing: Stripe, mnemonic, referral, mock mode
- coordinator/auth: Privy app ID, verification key, app secret
- coordinator/ratelimit: consumer + financial rate limits
- coordinator/registry: min trust level
- coordinator/mdm: MDM URL + API key
- coordinator/api: ServerConfig (port, URLs, CORS, min version)

main.go goes from ~40 inline os.Getenv() calls to a single
config.ReadAppConfig() call, with all env reads scoped to the
package that owns each config domain.

Pattern adapted from: https://github.com/Layr-Labs/eigenda-proxy

* fix: move Config structs into config.go, add Check methods

- billing.Config moved from billing.go to config.go
- auth.Config moved from privy.go to config.go
- Added Check() to billing, auth, registry, mdm, datadog Configs
- Fixed config/app_config.go to use correct function names
- Removed duplicate Config from ratelimit/ratelimit.go

* refactor: inject config structs through constructors

- store.NewPostgres(ctx, cfg store.Config) — replaces connString param
- store.NewMemory(cfg store.Config) — replaces adminKey param
- mdm.NewClient(cfg mdm.Config, logger) — replaces baseURL/apiKey params
- api.NewServer(reg, st, cfg api.ServerConfig, logger) — injects cfg fields

Added AdminKey to store.Config and ServerConfig (AdminKey/AdminEmails/ReleaseKey).
Updated all 117 NewMemory call sites, 2 NewPostgres callers, 1 mdm.NewClient,
1 api.NewServer in main.go, and ~20 api.NewServer test callers via testServer helper.

All tests pass (go test -race ./...).

* fix: update e2e testbed for new constructor signatures

- store/config.go: pass AdminKey in ReadConfig
- e2e/testbed/coordinator.go: use store.Config for NewMemory/NewPostgres
- e2e/testbed/suite.go: pass api.ServerConfig to NewServer

* fix: use shared env.EnvPrefix in ratelimit config

Create coordinator/env/ package with shared EnvPrefix constant
so that ratelimit/config.go can reference it without creating
an import cycle (config->ratelimit would conflict with
ratelimit->config).

config/app_config.go now defines EnvPrefix = env.EnvPrefix
as a package-level alias. ratelimit/config.go imports env
and uses env.EnvPrefix+"_RATE_LIMIT_RPS" etc.

* fix: wire env prefix + deduplicate NewServer wiring

Addresses review feedback on PR #187:

1. All per-package configs now use env.EnvPrefix instead of hardcoded
   "EIGENINFERENCE" strings. Previously only ratelimit/ used it; now
   store/, billing/, auth/, mdm/, registry/, and api/server_config do
   too.  No import cycles — all packages import coordinator/env.

2. NewServer now applies same trimming as the Set* methods:
   - strings.TrimRight for baseURL, r2CDNURL, r2SitePackagesCDNURL
   - strings.TrimSpace for minProviderVersion
   - strings.ToLower(strings.TrimSpace) for admin emails
   This fixes an inconsistency where NewServer left URLs untrimmed
   but the Set* calls in main.go would trim them later.

3. Removed redundant Set* calls from main.go.  NewServer already
   sets all ServerConfig fields, so the conditional SetConsoleURL /
   SetCORSOrigin / SetBaseURL / SetMinProviderVersion / SetR2CDNURL /
   SetR2SitePackagesCDNURL / SetReleaseKey / SetAdminKey blocks
   were duplicate work.

* chore: add TODO for admin email storage antipattern (PR feedback)

* ratelimit: reuse env helpers instead of local duplicates

Move EnvFloat/EnvInt/EnvOr/FirstNonEmpty from coordinator/config to
coordinator/env so they're accessible without import cycles.
coordinator/config now forwards to env for backward compatibility.
ratelimit/config.go now calls env.EnvFloat/env.EnvInt directly
instead of defining its own duplicate helpers.

Fixes: config→app_config→api→ratelimit import cycle that prevented
ratelimit from importing coordinator/config directly.

* fix: reuse env.EnvOr/env.FirstNonEmpty instead of local helpers

* registry: validate MinTrustLevel is a recognized value in Check()

* fix(billing): add MockMode+StripeSecretKey mutual exclusion to Check()

* fix: guard threat-model-review for fork PRs where ANTHROPIC_API_KEY unavailable

Two-part fix:
1. Workflow: add `if: github.event.pull_request.head.repo.full_name == github.repository`
   to skip the entire job for fork PRs (secrets not shared with forks).
2. Script: handle missing ANTHROPIC_API_KEY env var gracefully by returning a
   skip message instead of crashing.

* Revert guard block from threat-model-review.py per review feedback

* revert: remove out-of-scope workflow guard from config refactor PR

* feat(coordinator): use registry max_output_length for default max_tokens bound

The coordinator was hardcoding defaultMaxOutputTokens=8192 for all models
when the consumer didn't specify max_tokens. Now it looks up the model's
max_output_length from the registry (set at registration) and uses that
as the bound. Falls back to 8192 for models not in the registry.

GPT-OSS 20B and Gemma 4 both support 32K output, so consumers that omit
max_tokens now get up to 32K instead of being capped at 8K.

The registry lookup piggybacks on the existing GetModelRegistryRecord
call used for reasoning_parser injection -- no additional DB query.

* fix(provider-swift): exclude sliding attention layers from per-token KV cost

Sliding-attention layers have a fixed KV cache bounded by the window
size (e.g. 128 tokens for GPT-OSS 20B). Their memory does not grow with
sequence length, so counting them in kvBytesPerToken overestimates the
per-token cost and underestimates the token budget by up to 2x.

GPT-OSS 20B: 12 full + 12 sliding layers. Before: 48 KB/token, budget
~2.1M tokens on 128GB. After: 24 KB/token, budget ~4.2M tokens.

Gemma 4 has a similar hybrid layout and benefits equally.

* fix: update test files for store.Config and ServerConfig signatures

* rebrand: research preview -> public alpha (#220)

Rename all instances of 'Research Preview' and 'research project' to
'Public Alpha' across UI, landing page, legal terms, and README.

- console-ui: sidebar label, footer disclaimer, login page, provider
  setup, LLM system prompt
- landing: banner tag (now 'Low-cost private inference on idle Macs'),
  marketing copy (3 sections), terms.html (6 clauses)
- docs: terms-of-service.md (6 matching clauses)
- README: top-level callout

No legal meaning changed -- the existing ToS already listed 'alpha' as
a valid label. CSS class names (.research-tag) left unchanged.

* feat: add Vercel Web Analytics to console-ui and landing page (#221)

* feat: add Vercel Web Analytics to console-ui and landing page

Install @vercel/analytics alongside existing Google Analytics on both
surfaces. Vercel Analytics is cookieless and collects only anonymized
page-view data, so no consent banner is required.

console-ui (Next.js):
  - Added @vercel/analytics dependency
  - Added <Analytics /> component to root layout (imported from
    @vercel/analytics/next for automatic route tracking)

landing (plain HTML):
  - Added va queue shim + deferred script tag pointing at
    /_vercel/insights/script.js

Google Analytics remains untouched -- both systems run in parallel.
Vercel Analytics tracks by default; GA continues to be consent-gated.

Note: Web Analytics must also be enabled in the Vercel project dashboard
for data to start flowing.

* feat: mirror custom events to Vercel Analytics

Add Vercel track() call inside the existing trackEvent() function so
all 45 custom event call sites automatically send to both GA and Vercel
Analytics with zero call-site changes.

Vercel track() fires unconditionally (cookieless, always-on). GA
continues to be consent-gated. Vercel track() limits: string values
only and max 5 key-value pairs per event, so we convert and cap.

* feat: add landing page funnel tracking with Vercel Analytics

Add scroll-based section visibility and CTA click tracking to
landing/index.html using Vercel Analytics va() events.

Section funnel (IntersectionObserver, fires once per section at 30%
visibility threshold):
  hero -> what-you-get -> why-it-costs-less -> privacy-problem ->
  privacy-architecture -> developer-experience -> pricing -> earn ->
  footer

CTA click tracking:
  - Hero buttons (Start building, Estimate earnings, Read the Paper)
  - Card buttons (Open Console, Start Earning)
  - Paper download links (eigen-block CTAs)
  - Nav anchor clicks (Why, Privacy, API, Pricing, Earn)
  - Footer link clicks
  - Install tab toggle (CLI vs Mac App)

All events use the va() queue shim already present in <head>. The
existing scroll-reveal animation is preserved and runs alongside.

* improve stats model catalog display (#222)

* Improve stats model catalog display

* Enable analytics by default

co-authored with codex

* feat: streamline provider onboarding to one post-install command (#223)

* Improve stats model catalog display

* feat: streamline provider onboarding to one post-install command

Reduce the provider onboarding flow from 5+ manual steps to a single
command after the curl installer.

install.sh:
- Remove [5/5] model catalog step (redundant with start's picker)
- Make MDM enrollment non-blocking (no more read -p wait)
- Replace 5-line 'next steps' with: source ~/.zshrc && darkbloom start
- Renumber steps from [1/5]...[5/5] to [1/4]...[4/4]

LoginCommand.swift:
- Fix stale 'darkbloom serve' -> 'darkbloom start' in success message

StartCommand.swift:
- Add preflight doctor checks (SIP, debugger, min RAM) before model
  picker so problems surface before downloading GBs of weights
- Add inline login prompt ('Link account? [Y/n]') before model picker
  so users don't need a separate darkbloom login step
- Both are skipped in non-interactive/foreground/--model modes

* fix: default 'darkbloom models' to catalog instead of local list

A new user running 'darkbloom models' with nothing downloaded saw
'No local MLX models found.' -- unhelpful. Now it shows the full
coordinator catalog with download status markers (✓ for downloaded),
so they can immediately see what's available.

'darkbloom models list' still works for the local-only view.

* feat: show supported vs local-only models in 'darkbloom models'

Split the catalog view into two sections:

  Supported models
    ✓ Qwen 3.5  [qwen3.5-4b]  ~2.5 GB
      Llama 4   [llama-4-8b]  ~4.8 GB

  Local only (not in current catalog)
    old-model-v1  3.2 GB

    These models are no longer served by the network.
    Remove with: darkbloom models remove <id>

Users immediately see what's active vs what's just taking up disk
space from old downloads. Nudges cleanup without being aggressive.

* feat(console-ui): public models catalog proxy and earn page resilience (#224)

Models API route:
- Unauthenticated requests now proxy to /v1/models/catalog + /v1/models/capacity
  instead of the auth-gated /v1/models, so the earn page and other public
  surfaces can display the full model catalog without an API key.
- toModelEntry() normalizes catalog fields (size_gb, min_ram_gb, architecture,
  capacity stats) into the standard model shape the UI expects.

Client (api.ts):
- fetchModels() handles three response shapes: data.data (OpenAI list),
  data.models (catalog), or a raw array.

Earn page:
- Models without explicit pricing fall back to a default output price
  instead of being filtered out entirely.

Tests:
- Add catalog response unwrapping test for fetchModels.
- Update earn page tests to mock fetchModels/fetchPricing from @/lib/api.

* feat: multi-model swap — download multiple models, serve one at a time (#225)

* feat: multi-model swap — download multiple models, serve one at a time

Providers can now select and download multiple models even when their
combined size exceeds available RAM. Only one model is warm (loaded in
GPU memory) at a time; the coordinator manages demand-driven model
swaps via the existing load_model protocol.

Provider (Swift):
- TUI picker: removed simultaneous memory budget constraint; each model
  only needs to individually fit. Shows 'one model active at a time
  (swap on demand)' when total exceeds RAM.
- Fixed pre-existing download resume bug: range-resumption (HTTP 206)
  now appends to the partial file instead of replacing it.

Coordinator (Go):
- Cold-start routing: freeMemoryAdmits now admits idle providers that
  have the model on disk but not loaded, accounting for LRU eviction.
- Raised cold-start penalty from 2.5s to 30s (realistic for model swap
  times of 15–60s) so warm providers are strongly preferred.
- Proactive model swap: TriggerModelSwaps sends load_model to idle cold
  providers when queued requests have no warm provider. Includes
  deduplication (2-min cooldown per provider+model pair), one-provider-
  per-pass selection, and full routing safety gates (trust, runtime,
  privacy, challenge freshness, catalog).
- SendLoadModel, ClearPendingModelLoad, QueuedModels helpers.

* chore: gofmt billing_handlers.go and pricing_test.go

* fix: address review — routing gates on warm check, stale WarmModels, idle-only swaps, Content-Range validation

- hasWarmProviderLocked now applies full routing gates (trust, runtime,
  privacy, challenge freshness) so stale-attested providers don't
  suppress model swaps
- Heartbeat always overwrites WarmModels (including empty) to clear
  stale entries after model unload
- bestModelLoadProviderLocked only selects idle providers (pendingCount
  == 0) to avoid failed load_model on busy single-slot providers
- Download resume validates Content-Range start offset before appending;
  falls back to full re-download on mismatch

* fix: address second review round — idle slot penalty, Content-Range strictness, load oscillation, catalog gate

- slotStatePenalty: handle 'idle' state as running (0ms) — provider
  reports 'idle' for warm-but-no-active-requests models
- Content-Range: discard partial on missing/unparseable header instead
  of appending optimistically; test mock now sends Content-Range
- bestModelLoadProviderLocked: skip providers with ANY pending
  load_model (providerHasPendingLoad) to prevent swap oscillation
- providerHasWarmModelLocked: add catalog gate so retired/hash-changed
  models don't suppress swap planning

* fix: per-provider reservation race + drain queue on load success

- reservePendingModelLoads: check providerHasPendingLoad (not just
  per-key) to prevent concurrent heartbeat goroutines from reserving
  the same idle provider for different models
- load_model_status handler: drain queued requests immediately on
  success instead of waiting for next heartbeat (up to 5s)

* fix: adversarial review — BackendCapacity authority, load failure backoff, disconnect cleanup, TUI preselect

- providerHasWarmModelLocked: BackendCapacity is authoritative when
  present; only 'running'/'idle' slots count as warm. Prevents crashed
  slots from suppressing needed model swaps via stale WarmModels.
- load_model_status: only clear pendingModelLoads on success. Failures
  retain the 2-min cooldown to prevent retry storms against providers
  that consistently fail (deleted files, OOM).
- Disconnect: clear pendingModelLoads entries for the disconnected
  provider to prevent stale entries from blocking future swaps.
- TUI preselect: check canFitIndividually before preselecting a
  downloaded model.

* feat: reject queued requests immediately when model is unservable

When load_model fails and no other provider can serve the model,
queued requests are now rejected immediately with a fast error
instead of waiting 120 seconds for the queue timeout.

- FailQueuedRequestsForModel: sends nil to all ResponseChs, causing
  waiters to receive ErrQueueTimeout
- RejectUnservableQueuedRequests: checks QuickCapacityCheck after a
  load failure; if no eligible provider exists, flushes the queue
- Wired into load_model_status handler alongside the existing
  success/drain path

* fix: clear stale CurrentModel on nil heartbeat, mark provider warm before queue drain

- Heartbeat: clear CurrentModel when active_model is nil/omitted,
  preventing attestation challenges from comparing against unloaded
  models
- load_model_status:succeeded: call MarkModelWarm before draining so
  the scheduler sees the provider as warm immediately, not after the
  next heartbeat (up to 5s delay)

* fix: RejectUnservableQueuedRequests must check capacityRejections

Only reject queued requests when NO provider serves the model at all.
If providers exist but are temporarily at capacity, requests should
wait — those providers may finish current work and become available.

* fix: MarkModelWarm injects synthetic BackendCapacity slot

The scheduler uses BackendCapacity.Slots (not WarmModels) for Swift
providers. When load_model_status:succeeded arrives before the next
heartbeat, the model had no slot so the scheduler still saw it as
cold/unknown. Now injects an 'idle' slot so DrainQueuedRequestsForModel
immediately routes to the just-warmed provider.

* fix: MarkModelWarm clears stale evicted slots from BackendCapacity

When a swap evicts model A and loads model B, stale 'running'/'idle'
slots for A remained in BackendCapacity until the next heartbeat,
causing the scheduler to treat A as still warm. Now drops all warm
slots except the newly loaded model.

* fix: MarkModelWarm preserves existing warm slots

Provider may have multiple model slots loaded simultaneously
(maxModelSlots=3). Only add/update the new model's slot; leave
existing slots untouched. Next heartbeat provides authoritative state.

* docs: add coordinator state model and mutation checklist to AGENTS.md

Documents the overlapping state views (BackendCapacity vs WarmModels
vs CurrentModel vs pendingModelLoads), their precedence rules, and a
5-point checklist for mutating provider state. Learned from 10 fix
iterations on the multi-model swap feature.

* docs: fix WarmModels reader list — include legacy ScoreProvider and /v1/me/providers

* ci: require approval before running e2e benchmarks (#227)

* chore: remove dead coordinator code (#211)

Remove unused functions, methods, constants, and a duplicate directory:

- coordinator/internal/e2e/e2e/: accidental byte-identical copy of parent
  directory, never imported by any code

- api/provider.go: SendInferenceRequest() -- consumer path writes
  directly to provider.Conn, this was a leftover from a refactor

- registry/queue.go: WaitForProvider() -- superseded by
  WaitForProviderContext(), the only method actually called

- registry/queue.go: TryAssign() -- stale queue method from older
  design, never called from production code

- registry/queue.go: CleanStale() -- stale queue method, never called
  (inline cleanStaleLocked is still used by Enqueue)

- registry/registry.go: BackendInprocessMLX const -- dead enum value,
  the in-process MLX path was removed. String literal kept where needed
  for backward compat with old providers.

- registry/registry.go: ForceTrustProvider() -- bypasses attestation
  with no legitimate production use. Tests updated to use
  testMakeTextRoutable().

- registry/registry.go: ProviderCountByChip() -- analytics method
  never wired to any endpoint

- registry/registry.go: ModelProviderCounts() -- analytics method
  never wired to any endpoint

Tests updated: removed 3 tests for deleted methods, migrated 2 tests
from ForceTrustProvider to testMakeTextRoutable, replaced WaitForProvider
calls with WaitForProviderContext.

All tests pass. go vet clean.

* [codex] Add stats leaderboard tab (#226)

* Add stats leaderboard tab

* Add earn now CTA to stats leaderboard

* fix(coordinator): resolve DB connection starvation, deprecate Python providers (#228)

Production outage root cause: Postgres connection pool (20 max) exhausted by
concurrent stats scans, heartbeat upserts, and billing settlement. When
SyncRuntimeManifest happened to overlap with pool exhaustion, ListReleases
timed out, the manifest was nuked, and revalidateConnectedProvidersAgainstRuntimePolicy
set RuntimeVerified=false for ALL providers — instantly derouting the fleet.

Critical fixes:
- Increase pool MaxConns from 20 to 80, MinConns from 5 to 10
- SyncRuntimeManifest: return early on ListReleases nil (DB timeout) instead
  of nuking a working manifest
- revalidateConnectedProvidersAgainstRuntimePolicy: only deroute on intentional
  manifest withdrawal, not transient DB failures
- Add 5s timeout to telemetry batch INSERT (was unbounded)

Python/legacy provider deprecation:
- privateTextBackendSupported only accepts mlx-swift
- verifyRuntimeHashesForBackend immediately rejects non-Swift backends
- providerSupportsPrivateTextLocked: remove dead Python caps branch
- Remove dead code: r2SitePackagesCDNURL, verifyRuntimeHashes(),
  EIGENINFERENCE_KNOWN_PYTHON_HASHES, EIGENINFERENCE_KNOWN_RUNTIME_HASHES
- All test fixtures updated from inprocess-mlx to mlx-swift

DB performance optimizations:
- CreditProviderAccount: 6 sequential round-trips → single CTE
- Usage recording made async (saferun.Go)
- Provider credit + platform fee run concurrently (WaitGroup)
- Auth middleware: 3 DB queries → 1 (ValidateKeyFull) + LRU cache (60s TTL)
- PersistProviderThrottled: heartbeat writes rate-limited to 1x/30s per provider
- Add indexes: idx_usage_created, idx_usage_consumer, idx_usage_provider
- Add earnings_summary materialized table: eliminates full-table SUM scans on
  /v1/provider/account-earnings (PK lookup instead)
- Backfill migration populates earnings_summary from existing data
- Add detailed mismatch logging (component+hash, not just count)

All migrations are idempotent (CREATE IF NOT EXISTS / ON CONFLICT DO NOTHING).
No manual SQL required — indexes and tables auto-create on restart.

All tests pass. go vet clean.

* fix(coordinator): unblock WebSocket read loop from billing settlement

Root cause of challenge timeouts: handleComplete runs billing DB calls
(GetModelPrice, Credit, Charge) synchronously on the WebSocket read loop.
Under DB pressure (cross-cloud RDS latency), these block for 5+ seconds,
preventing the read loop from receiving attestation challenge responses.
The 30s challenge timeout expires, RecordChallengeFailure clears
LastChallengeVerified, and the provider becomes unroutable.

Fixes:
- Move handleComplete to a saferun.Go goroutine so billing settlement
  never blocks the read loop
- RecordChallengeFailure: only clear LastChallengeVerified on security
  failures (SIP disabled, signature mismatch, etc.), NOT on transient
  timeouts. Transient timeouts only deroute at MaxFailedChallenges (3).
- Move MaxFailedChallenges constant to registry package (was hardcoded)

All tests pass. go vet clean.

* refactor(coordinator): replace MaxMind with ip-api.com for provider geolocation

Remove the geoip2-golang dependency and MaxMind .mmdb file requirement.
Provider geolocation now uses ip-api.com (free, no API key, 45 req/min).
Called once per provider WebSocket connection so rate limit is never hit.

The resolver always initializes now — no env vars needed for basic geo.
EIGENINFERENCE_TRUST_GEO_HEADERS=1 still works as a fast-path when
behind Cloudflare/Vercel. EIGENINFERENCE_GEOIP_DB is removed.

* style: gofmt provider.go, postgres.go

* perf(coordinator): stop writing telemetry to Postgres — Datadog is sole sink

Removes the synchronous InsertTelemetryEvents call from the telemetry
handler. With 60 providers sending batches every 10s, this was 6 INSERTs
per second, each writing up to 50 rows into a table with 5 indexes.
That alone consumed ~30-40% of the DB connection pool.

Datadog already receives all telemetry asynchronously via the Logs API.
The Postgres copy was documented as best-effort secondary storage and
adds no value that Datadog doesn't already provide.

The telemetry_events table and its schema are left intact (no migration
needed). New events simply stop being written.

* fix(provider-swift): migrate SE key to AfterFirstUnlock for background signing

The SE key was created with kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
which blocks signing when the screen is locked. This caused all attestation
challenges to fail with OSStatus -25308 (errSecInteractionNotAllowed) on
provider machines with locked screens, making them unroutable.

Changes:
- New keys use kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly — accessible
  after first unlock even when screen subsequently locks
- loadOrCreate performs a test sign on existing keys; if it gets -25308,
  deletes the old key and recreates with the new policy
- Migration is automatic on provider restart — no manual intervention

Providers need to update to this version and restart. The old key is
deleted and a new one is created, which means the provider will
re-attest with a new public key on next coordinator connection.

* chore: bump provider version to 0.5.11

* fix: add missing r2SitePackagesCDNURL field and setter from PR branch

* fix: DB perf optimizations, error classification, and provider diagnostics (#232)

* fix: DB perf optimizations, error classification, and provider diagnostics

Coordinator DB performance:
- Add usage_totals counter table (O(1) vs full-table scan)
- Add partial index on usage.request_location IS NOT NULL
- Replace UsageRecordsSince + ListProviderRecords with SQL JOIN
- Add 60s cache to /v1/models/catalog endpoint
- Fix N+1 query in ListActiveModelRegistryWithError (batch file load)
- Add 20s cache to /v1/provider/account-earnings
- Merge GetBalance + GetWithdrawableBalance into single query

Billing error classification:
- Add ErrInsufficientBalance sentinel to store package
- Debit() distinguishes pgx.ErrNoRows from DB timeouts
- Consumer handler returns 503 (not 402) for DB errors
- Provider handler logs warn vs error for balance vs DB failures

Provider diagnostics:
- darkbloom logs now streams macOS unified logging by default
- darkbloom logs --last 1h shows historical unified logs
- darkbloom logs --file falls back to provider.log
- New darkbloom report command uploads 24h unified logs
- New POST /v1/provider/log-report endpoint (API key auth)
- New GET /v1/admin/log-reports admin endpoints
- New provider_log_reports DB table

Closes #230

* fix: address Codex review findings

- Accept provider tokens (eigeninference-pt-...) in requireAuth so
  darkbloom report works with device-login tokens
- Include limit param in earnings cache key to prevent stale responses
- Invalidate catalog cache in SyncModelCatalog after admin changes
- Fix log show to use --info flag instead of --level info (macOS log(1))

* fix: restore in-memory telemetry buffer, no-op Postgres telemetry writes

The telemetry Postgres removal (e0a63cc) removed both the Postgres
INSERT and the in-memory buffer write. The in-memory buffer is free
(no DB, bounded at 10K entries) and is needed by the admin metrics
endpoint and test assertions.

- Restore InsertTelemetryEvents call in the handler (writes to
  in-memory MemoryStore buffer only)
- Make PostgresStore.InsertTelemetryEvents a no-op (was still doing
  the expensive batch INSERT that the removal intended to eliminate)
- All 9 telemetry tests now pass (were failing on master)

* fix: remove telemetry Postgres writes, fix tests to assert on Datadog path

Telemetry is forwarded to Datadog only — no store writes. The previous
fix incorrectly re-added InsertTelemetryEvents to the HTTP handler.

- Remove InsertTelemetryEvents call from ingestion handler
- Make PostgresStore.InsertTelemetryEvents a no-op (was still doing
  the expensive batch INSERT the removal intended to eliminate)
- Update 3 tests to assert on HTTP response counts and metrics
  counters instead of TelemetryEventsSnapshot (which is empty since
  the handler no longer writes to the store)
- Recover middleware test unchanged (uses Emitter path, not HTTP handler)

All 12 packages pass with zero failures.

* style: gofmt server.go, stats.go, memory.go

* feat: trust_status message, auto-report, and MDM re-verification (#233)

Coordinator → Provider trust status notification:
- Add TypeTrustStatus protocol message (Go + Swift)
- Send trust_status after SE attestation (self_signed), MDM upgrade
  (hardware), ACME upgrade (hardware), and MarkUntrusted
- Provider receives trust level and status over WebSocket

Provider auto-report on degraded trust:
- When provider learns it is self_signed or untrusted, schedules a
  one-time auto-report of 24h unified logs after 10 minutes
- Report is uploaded to POST /v1/provider/log-report
- Cancelled if trust is upgraded before the 10-min window
- Once-per-session flag prevents spamming

MDM re-verification for self_signed providers:
- Challenge loop now re-attempts MDM verification after a successful
  challenge if the provider is still at self_signed trust
- Providers that install MDM enrollment after registration will get
  upgraded to hardware trust on the next challenge cycle (5 minutes)
  instead of being stuck at self_signed forever

* chore: bump provider version to 0.5.12

* fix: MDM channel saturation, timeout-marks-untrusted, and model load memory gate

MDM channel architecture (coordinator/mdm/mdm.go):
- Replace shared buffered channels (size 16) with per-UDID waiter maps
- Eliminates channel saturation: late/unsolicited webhooks no longer
  fill the buffer and block all future MDM verifications
- Eliminates CPU busy-spin: no more read-put-back loops when waiting
  for a specific UDID while other UDIDs are in the buffer
- Same fix applied to attestation (MDA) response path

MDM timeout handling (coordinator/api/provider.go):
- SecurityInfo timeout no longer marks provider untrusted
- Timeout is APN latency, not evidence of compromise
- Provider stays at self_signed trust, MDM re-check retries on next
  challenge cycle (every 5 minutes)

Model load memory gate (coordinator/registry/registry.go):
- TriggerModelSwaps now checks provider memory before sending load_model
- Uses catalog SizeGB * 2.5 as the coordinator-side memory threshold
- Prevents sending load_model to machines that will always reject
  (e.g., 32GB Mac for gpt-oss-20b needing 40.5GB)
- Stops the infinite retry loop of failed load_model commands

* fix: APN reliability for MDM — network assertions, 90s timeout, late-arrival path

Provider (Swift):
- Add NetworkPowerAssertion: IOKit assertions for NetworkClientActive
  and BackgroundTask, acquired for the entire provider session
- Keeps the macOS network stack alive during sleep so APN pushes
  (courier.push.apple.com:5223) can be delivered for MDM commands
- No root required — uses IOPMAssertionCreateWithName API

Coordinator:
- Increase SecurityInfo timeout from 30s to 90s to cover Power Nap
  cycles (every ~15 minutes on AC power)
- Add OnLateSecurityInfoCallback: when a SecurityInfo webhook arrives
  after the 90s timeout, retroactively upgrade the self_signed provider
  to hardware trust instead of silently dropping the response
- Wire up the callback in main.go alongside the existing SetOnMDA
  callback, using the same ForEachProvider + serial match pattern

* chore: bump provider version to 0.5.13

* chore: remove telemetry_events Postgres table and writes (#234)

* chore: remove telemetry_events Postgres table and writes

The telemetry_events table + 5 indexes was the single largest source of
DB write pressure (60 providers × batch/10s × 50 rows × 5 indexes consumed
~30-40% of the connection pool). The /v1/telemetry/events ingestion handler
already skips Postgres entirely — Datadog is the sole durable sink. No read
endpoints consumed this table.

- Remove CREATE TABLE telemetry_events + 5 CREATE INDEX from migration
- Delete telemetry_postgres.go, telemetry_memory.go, telemetry_test.go
- Remove InsertTelemetryEvents from Store interface
- Remove store field/param from telemetry.Emitter
- Remove telemetryEvents ring buffer from MemoryStore
- Update all callers (main.go, server.go, tests)

* ci: trigger re-run

---------

Co-authored-by: ethenotethan <42627790+ethenotethan@users.noreply.github.com>
Co-authored-by: Gajesh Naik <26431906+Gajesh2007@users.noreply.github.com>

This branch was successfully deployed

3 active deployments
Preview – d-inference — d3955b84 Deployed May 27, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — d3955b84 Deployed May 27, 2026 by vercel[bot]
Preview – d-inference-landing — d3955b84 Deployed May 27, 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