Skip to content

feat(provider-swift): migrate BatchScheduler from BatchGenerator to BatchedEngine - #207

Merged
Gajesh2007 merged 1 commit into
masterfrom
feat/batched-engine-migration
May 25, 2026
Merged

Gajesh2007 merged 1 commit into
masterfrom
feat/batched-engine-migration

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented May 24, 2026 •

Copy link
Copy Markdown
Member

Depends on: Layr-Labs/mlx-swift-lm#27 (adds the `Scheduler.setMaxNumSeqs` API this PR consumes). This PR's submodule pointer currently references that PR's feature-branch tip; before merge the pointer should be advanced to the merged `main` commit.

Summary

Swaps `BatchScheduler` internals from the low-level `MLXLMCommon.BatchGenerator` to the new `MLXLMCommon.BatchedEngine` orchestrator. Public surface of `BatchScheduler` is preserved — `ProviderLoop`, `StandaloneServer`, `OpenAIFormatter`, and `LocalTokenizerLoader` are untouched.

What BatchedEngine gives us

Compared to `BatchGenerator` (caller-driven `while gen.hasWork { gen.next() }` loop inside a `container.perform` actor hop):

  • Engine-owned step loop on a single `DispatchQueue` — no worker task, no actor hop per step
  • Auto-preemption with re-queue when KV budget exceeded
  • Chunked cold prefill interleaved with decode (`prefillStepSize=512`, `maxNumBatchedTokens=8192`) — running decode is never starved by incoming prompts
  • Per-request stop-sequence state machine (EOS + `stopTokenIds` + tokenized `stop` strings)
  • Per-request `RequestOutputCollector` with non-blocking `get` + producer-merge on backpressure
  • `SamplingParams` support: temperature, topP, topK, minP, seed, repetitionPenalty, presencePenalty, frequencyPenalty
  • Auto `Memory.clearCache()` after 8 idle steps (M4 IOKit panic mitigation)
  • First-class cancellation — `abortRequest` emits terminal `RequestOutput` immediately; scheduler frees the slot on the next step

Migration design decisions

Decision Value Rationale
Prefix cache OFF (`prefixCacheConfig: nil`, `prefixCache: nil`) Cross-tenant data persistence risk per TB-007. Inline comment in code. Flipping requires a fresh threat-model review.
MTP OFF (`mtpEnabled: false`) No prod model is `MTPCapable` today.
KV budget Ours only (`maxKVCacheTokens: 0` = unlimited at engine) Our byte-level `kvBudget` + `BatchQueuePlanner` are the sole gates. Single source of truth. Engine never preempts.
Adaptive cap Propagates to engine via new `Scheduler.setMaxNumSeqs(_:)` Companion upstream PR #27. `AdaptiveBatchCapPolicy` shrinks/grows both the admission layer and the engine cap.
Tokenization Pre-tokenize at `submit` (existing `tk.inner.applyChatTemplate`); pass `[Int]` to engine Avoids double tokenization. Preserves synchronous `.error("Failed to tokenize: …")` contract instead of engine's silent `role:content` fallback.
Error strings Distinct: `request timed out waiting for capacity` vs `request cancelled` Operator observability — distinguishes pending-queue timeout from client-initiated cancel.

Kept from previous BatchScheduler (not in BatchedEngine)

  • KV-bytes-per-token estimation from `config.json` (GQA, hybrid, KV sharing, recurrent layers)
  • `tokenBudgetMax` derived from `ProcessInfo.physicalMemory` − `MLX.GPU.activeMemory` − reserves
  • `GlobalKVCacheBudget` (process-wide byte reservation across loaded models)
  • `BatchQueuePlanner` admission + 120s pending-queue timeout
  • `AdaptiveBatchCapPolicy` + TPS EWMA
  • `GPUEnforcement.requireMetal()`
  • `capacity()` / `backendCapacity()` heartbeat shape
  • Public `AsyncStream` contract (`.chunk`/`.info`/`.error`)

Race-safety audit (done)

Pre-implementation audit confirmed only ONE production code path drove the model forward outside `BatchScheduler` — the deleted `stepEngine` itself. After migration, `git grep "container.perform"` in `provider-swift/Sources/` returns three sites: `BatchScheduler.loadModel` snapshot pass (metadata-only, runs before `engine.start()`), the engine construction inside `loadModel` (runs once), and `ModelBenchmark` (separate container, doesn't start engine). No concurrent model access after engine start.

Verification

```
$ swift build (provider-swift)
PASS (only pre-existing MLX.GPU.* deprecation warnings)

$ swift test (provider-swift, full non-live suite)
234/234 pass (213 Swift Testing + 21 XCTest, 19 suites)
2 live tests auto-skipped (env-gated)
```

Live MLX tests recommended before merge

cd provider-swift
DARKBLOOM_LIVE_MLX_TESTS=1 swift test --filter ContinuousBatchingLiveTests
DARKBLOOM_LIVE_MLX_TESTS=1 swift test --filter BatchSchedulerEngineIntegrationTests
DARKBLOOM_LIVE_MLX_TESTS=1 swift test --filter PerformanceLiveTests

# Optional, Gemma 4 chat-template + tool-call regression check
DARKBLOOM_LIVE_MLX_TESTS=1 DARKBLOOM_LIVE_MLX_GEMMA=1 swift test --filter PerformanceLiveTests

`PerformanceLiveTests` is a smoke gate (`#expect(tps > 0)`); the header comment notes baseline TPS numbers must be re-measured against `BatchedEngine` before being used as regression thresholds.

Net LOC

File Net
`Sources/ProviderCore/Inference/BatchScheduler.swift` −56 (+372 / −428)
`Tests/ProviderCoreTests/ContinuousBatchingLiveTests.swift` +93
`Tests/ProviderCoreTests/PerformanceLiveTests.swift` +44
`Tests/ProviderCoreTests/BatchSchedulerEngineIntegrationTests.swift` +201 (new)
`Sources/ProviderCore/ProviderLoop.swift`, `Server/StandaloneServer.swift` unchanged

Submodule bump

`libs/mlx-swift-lm`: `d164323f` → `90811a35` (feature-branch tip of Layr-Labs/mlx-swift-lm#27 — `feat(scheduler): add runtime setMaxNumSeqs(_:)`). Once that upstream PR merges, the pointer here will be advanced to the merged `main` commit.

Acknowledged trade-offs (deferred, not blockers)

  1. No mock-engine test harness. Non-live coverage of bridge logic is via constructed `RequestOutput` structs. Live tests cover the real path. Acceptable for v1; mock harness flagged as v2 work.
  2. Adaptive cap signal is per-finish, not per-step. Noisier than the old per-step measurement. Cap propagation to engine via `setMaxNumSeqs` mitigates; oscillation behavior should be monitored in prod.
  3. `decodeBurstSteps=32` is gone. Engine runs one step per loop iteration; `engineQueue` is a single serial queue. `PerformanceLiveTests` will reveal any steady-state TPS regression.
  4. Multi-token EOS not supported at the EOS path. All shipped models (Llama 3, Qwen 3.x, Gemma 3/4) use single-token EOS. Future multi-token EOS models route through `SamplingParams.stop`.

Audit / review trail

  • ProviderLoop concurrent-access audit: ✓ (3 `container.perform` sites, all safe)
  • Security review (TB-007): ✓ (prefix cache symbols absent from `darkbloom` binary; no new disk writes / logs of decoded text; no new IPC / sockets)
  • API surface review: ✓ (`BatchScheduler` public surface bit-identical)
  • Reviewer verdict before this PR: APPROVE_WITH_FIXES → all 3 should-fix items applied (distinct timeout error string, drop init clamp from upstream Scheduler, drop redundant `getMaxNumSeqs()` upstream accessor)

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

@vercel

vercel Bot commented May 24, 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 25, 2026 1:08am
d-inference-console-ui-dev Ready Ready Preview May 25, 2026 1:08am
d-inference-landing Ready Ready Preview May 25, 2026 1:08am

Request Review

@github-actions

github-actions Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-24 21:11 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.974s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.75s 1.75s 1.751s 1.751s
parse 4 23µs 33µs 34µs 34µs
reserve 4 3ms 3ms 4ms 4ms
route 4 17µs 15µs 31µs 31µs
encrypt 4 351µs 375µs 384µs 384µs
dispatch 4 26µs 27µs 32µs 32µs
coordinator_to_provider 4 1.744s 1.744s 1.745s 1.745s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=22.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=34µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.7835ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.202ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=351µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=384µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=25.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=32µ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.294s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.29s 3.29s 3.294s 3.294s
parse 4 15µs 18µs 22µs 22µs
reserve 4 3ms 3ms 5ms 5ms
route 4 14µs 15µs 20µs 20µs
encrypt 4 366µs 372µs 425µs 425µs
dispatch 4 34µs 32µs 56µs 56µs
coordinator_to_provider 4 1.742s 1.742s 1.743s 1.743s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=15µs (threshold=1ms)
parse:p95<=5ms PASS p95=22µs (threshold=5ms)
reserve:mean<=50ms PASS mean=3.035ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.53ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=365.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=425µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=34µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=56µ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 44
Errors 6
Total Duration 13.308s
Throughput 3.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 44 652ms 4ms 3.539s 3.549s
parse 43 32µs 19µs 51µs 306µs
reserve 43 2ms 1ms 3ms 4ms
route 43 30µs 22µs 66µs 195µs
encrypt 44 1ms 0s 1ms 1ms
dispatch 44 42µs 32µs 87µs 159µs
coordinator_to_provider 44 591ms 1ms 3.514s 3.541s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=31.72µs (threshold=1ms)
parse:p95<=5ms PASS p95=51µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.550186ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.005ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=506.704µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=875µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.318µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=87µ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.178s
Throughput 2.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.132s 2.139s 2.178s 2.178s
parse 12 18µs 16µs 46µs 46µs
reserve 12 3ms 3ms 5ms 5ms
route 12 14µs 13µs 32µs 32µs
encrypt 12 633µs 662µs 971µs 971µs
dispatch 12 23µs 19µs 54µs 54µs
coordinator_to_provider 12 2.124s 2.131s 2.171s 2.171s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=18µs (threshold=1ms)
parse:p95<=5ms PASS p95=46µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.932666ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.679ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=632.833µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=971µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=22.583µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=54µ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.37s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.019s 2.019s 2.019s 2.019s
parse 4 18µs 23µs 23µs 23µs
reserve 4 2ms 3ms 3ms 3ms
route 4 11µs 13µs 14µs 14µs
encrypt 4 554µs 539µs 693µs 693µs
dispatch 4 25µs 23µs 38µs 38µs
coordinator_to_provider 4 2.013s 2.013s 2.014s 2.014s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=18µs (threshold=1ms)
parse:p95<=5ms PASS p95=23µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.46175ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.674ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=554µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=693µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=24.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=38µ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 31
Errors 29
Total Duration 7.378s
Throughput 4.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 31 736ms 7ms 2.306s 2.306s
parse 31 21µs 19µs 37µs 48µs
reserve 31 2ms 2ms 6ms 7ms
route 31 25µs 22µs 44µs 75µs
encrypt 31 1ms 0s 2ms 2ms
dispatch 31 42µs 33µs 92µs 188µs
coordinator_to_provider 31 731ms 4ms 2.299s 2.3s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=20.645µs (threshold=1ms)
parse:p95<=5ms PASS p95=37µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.32058ms (threshold=50ms)
reserve:p95<=200ms PASS p95=5.566ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=549.129µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.607ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.419µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=92µ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.577s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.984s 1.984s 1.984s 1.984s
parse 4 13µs 12µs 21µs 21µs
reserve 4 2ms 2ms 2ms 2ms
route 4 14µs 16µs 17µs 17µs
encrypt 4 551µs 601µs 613µs 613µs
dispatch 4 31µs 23µs 66µs 66µs
coordinator_to_provider 4 1.979s 1.979s 1.979s 1.979s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=12.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=21µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.1855ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.344ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=550.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=613µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=31.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=66µ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.064s
Throughput 4.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 728ms 8ms 2.206s 2.206s
parse 30 22µs 17µs 47µs 113µs
reserve 30 2ms 2ms 5ms 7ms
route 30 23µs 19µs 49µs 54µs
encrypt 30 1ms 1ms 1ms 1ms
dispatch 30 67µs 31µs 391µs 533µs
coordinator_to_provider 30 719ms 5ms 2.186s 2.187s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=22.133µs (threshold=1ms)
parse:p95<=5ms PASS p95=47µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.373766ms (threshold=50ms)
reserve:p95<=200ms PASS p95=5.115ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=570.033µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.017ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=66.6µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=391µ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.863s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 759ms 8ms 2.303s 2.303s
parse 30 20µs 17µs 38µs 64µs
reserve 30 2ms 2ms 4ms 6ms
route 30 31µs 23µs 92µs 141µs
encrypt 30 1ms 1ms 1ms 2ms
dispatch 30 50µs 27µs 199µs 240µs
coordinator_to_provider 30 753ms 2ms 2.293s 2.296s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=20.1µs (threshold=1ms)
parse:p95<=5ms PASS p95=38µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.423666ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.873ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=607.166µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.17ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=49.533µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=199µ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.901s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.188s 2.173s 2.221s 2.221s
parse 12 95µs 103µs 141µs 141µs
reserve 12 9ms 9ms 10ms 10ms
route 12 36µs 38µs 83µs 83µs
encrypt 12 19ms 19ms 20ms 20ms
dispatch 12 86µs 54µs 267µs 267µs
coordinator_to_provider 12 2.149s 2.135s 2.182s 2.182s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=94.583µs (threshold=1ms)
parse:p95<=5ms PASS p95=141µs (threshold=5ms)
reserve:mean<=50ms PASS mean=8.937333ms (threshold=50ms)
reserve:p95<=200ms PASS p95=9.724ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=19.168583ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=19.891ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=86.083µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=267µ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: 83065eedb7

ℹ️ 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 832 to 835
let timedOut = activeBridges.filter { _, bridge in
bridge.firstTokenAt == nil
&& now - bridge.submittedAt >= pendingTimeout
}

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 Restrict timeout aborts to truly queued requests

expirePlannerTimeouts currently aborts every request that has no first token after pendingTimeout, but firstTokenAt == nil also covers admitted requests that are still prefilling a large prompt. In that case a valid in-progress generation is cancelled and mislabeled as "request timed out waiting for capacity" even when it was already running. This is a regression from the previous behavior, which timed out only the explicit pending queue; the timeout predicate should be tied to actual queue/waiting state, not first-token timing alone.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in this commit — expirePlannerTimeouts now gates on bridge.admittedAt == nil (not firstTokenAt == nil). A long-prefill request has admittedAt set (from the first RequestOutput) but firstTokenAt nil; the new predicate correctly leaves it alone. See recordAdmission for the wiring.

Comment on lines +592 to +595
// Stream closed without a terminal output (engine teardown).
await scheduler.dropBridge(requestId: id)
continuation.finish()
}

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 Emit an error when teardown closes a live request stream

When the engine stream ends without a terminal output, this branch drops bridge state and finishes the stream without yielding .error. ProviderLoop treats plain stream completion as success and emits a normal completion payload, so model unload/shutdown can silently turn aborted in-flight requests into successful responses with partial/empty output. Teardown-initiated closure should surface an explicit error event before finishing.

Useful? React with 👍 / 👎.

Comment on lines +860 to +865
let queuedTokens = snap.pendingRequests.reduce(0) {
$0 + $1.promptTokenCount + $1.maxOutputTokens
}
cancelledUIDs.removeAll()
pendingSummaryCache = PendingSummary(
queuedRequests: snap.pendingRequests.count,
queuedTokens: queuedTokens

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 counting admitted requests as pending budget

refreshPendingSummaryCache derives queuedRequests/queuedTokens from planner.snapshot().pendingRequests, but this integration never advances planner entries out of pending (requests are removed only via planner.cancel on finish). That makes running requests appear both active (activeBridges) and queued, double-counting budget and waiters in heartbeats. The coordinator’s routing gate sums activeTokenBudgetUsed + queuedTokenBudget when deciding admission, so this inflation can falsely reject routable work and underutilize healthy providers.

Useful? React with 👍 / 👎.

Comment on lines +309 to +313
maxNumSeqs: maxConcurrentRequests,
maxNumBatchedTokens: 8192,
prefillStepSize: 512,
streamInterval: 1,
maxKVCacheTokens: 0 // unlimited — our kvBudget gates by bytes

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 adaptive cap when starting the engine

The engine is initialized with maxNumSeqs: maxConcurrentRequests (hard cap), while dynamicMaxConcurrentRequests is reset to min(4, maxConcurrentRequests) afterwards and only pushed to the engine later when a performance update changes the cap. This means the intended conservative startup cap is never enforced, so fresh loads can immediately admit up to the hard cap and regress latency/memory behavior before adaptive control even engages.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in this commit — engine.setMaxNumSeqs(dynamicMaxConcurrentRequests) is called immediately after engine.start() so the conservative startup cap (min(4, maxConcurrentRequests)) is in effect before any submit lands.

Comment on lines +541 to +544
if !output.newText.isEmpty {
if !sawFirstToken {
await scheduler.recordFirstToken(requestId: id, at: .now)
sawFirstToken = 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 Track first-token progress from tokens, not emitted text

First-token progress is recorded only when output.newText is non-empty, but the engine can emit token IDs that decode to an empty text chunk (e.g., intermediate/special pieces) before visible text appears. In that case the request is actively decoding yet firstTokenAt stays nil, so the timeout watchdog can incorrectly abort it as "waiting for capacity" after pendingTimeout. The previous implementation marked first-token progress per generated token, so this is a regression in timeout classification.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-24 21: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.853s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.671s 1.671s 1.671s 1.671s
parse 4 45µs 48µs 76µs 76µs
reserve 4 6ms 6ms 8ms 8ms
route 4 36µs 28µs 83µs 83µs
encrypt 4 640µs 662µs 664µs 664µs
dispatch 4 49µs 47µs 65µs 65µs
coordinator_to_provider 4 1.653s 1.654s 1.656s 1.656s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=45.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=76µs (threshold=5ms)
reserve:mean<=50ms PASS mean=5.90175ms (threshold=50ms)
reserve:p95<=200ms PASS p95=8.289ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=639.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=664µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=49µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=65µ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.237s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.232s 3.232s 3.236s 3.236s
parse 4 40µs 39µs 71µs 71µs
reserve 4 8ms 10ms 12ms 12ms
route 4 49µs 44µs 89µs 89µs
encrypt 4 732µs 842µs 924µs 924µs
dispatch 4 75µs 79µs 109µs 109µs
coordinator_to_provider 4 1.678s 1.679s 1.682s 1.682s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=39.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=71µs (threshold=5ms)
reserve:mean<=50ms PASS mean=8.49425ms (threshold=50ms)
reserve:p95<=200ms PASS p95=11.694ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=732µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=924µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=109µ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 43
Errors 7
Total Duration 12.986s
Throughput 3.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 43 677ms 4ms 3.65s 3.652s
parse 41 26µs 19µs 44µs 164µs
reserve 41 2ms 1ms 3ms 4ms
route 41 29µs 22µs 47µs 190µs
encrypt 43 1ms 0s 1ms 1ms
dispatch 43 43µs 32µs 89µs 126µs
coordinator_to_provider 43 556ms 1ms 3.582s 3.644s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=25.512µs (threshold=1ms)
parse:p95<=5ms PASS p95=44µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.596146ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.432ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=522.767µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=954µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.209µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=89µ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.747s
Throughput 3.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.117s 2.124s 2.149s 2.149s
parse 12 13µs 12µs 25µs 25µs
reserve 12 2ms 2ms 4ms 4ms
route 12 17µs 15µs 44µs 44µs
encrypt 12 470µs 440µs 684µs 684µs
dispatch 12 33µs 22µs 131µs 131µs
coordinator_to_provider 12 2.109s 2.116s 2.142s 2.142s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=13.416µs (threshold=1ms)
parse:p95<=5ms PASS p95=25µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.425333ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.907ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=470.416µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=684µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=32.666µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=131µ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.563s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.103s 2.103s 2.103s 2.103s
parse 4 17µs 19µs 21µs 21µs
reserve 4 2ms 2ms 2ms 2ms
route 4 17µs 23µs 30µs 30µs
encrypt 4 464µs 524µs 529µs 529µs
dispatch 4 23µs 25µs 28µs 28µs
coordinator_to_provider 4 2.096s 2.097s 2.097s 2.097s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=17µs (threshold=1ms)
parse:p95<=5ms PASS p95=21µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.37ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.475ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=464µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=529µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=22.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=28µ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.137s
Throughput 5.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 38 617ms 5ms 2.359s 2.359s
parse 38 24µs 17µs 60µs 159µs
reserve 38 2ms 1ms 3ms 3ms
route 38 19µs 17µs 39µs 46µs
encrypt 38 454µs 429µs 725µs 955µs
dispatch 38 35µs 29µs 76µs 76µs
coordinator_to_provider 38 613ms 1ms 2.352s 2.353s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=24.131µs (threshold=1ms)
parse:p95<=5ms PASS p95=60µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.571105ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.982ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=454µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=725µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=35.289µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=76µ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.662s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.089s 2.089s 2.089s 2.089s
parse 4 19µs 18µs 33µs 33µs
reserve 4 3ms 3ms 3ms 3ms
route 4 18µs 21µs 29µs 29µs
encrypt 4 632µs 649µs 723µs 723µs
dispatch 4 18µs 18µs 26µs 26µs
coordinator_to_provider 4 2.083s 2.083s 2.083s 2.083s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=18.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=33µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.68125ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.862ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=632.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=723µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=17.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=26µ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.99s
Throughput 5.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 760ms 5ms 2.288s 2.288s
parse 30 18µs 16µs 53µs 54µs
reserve 30 2ms 1ms 3ms 3ms
route 30 17µs 16µs 34µs 38µs
encrypt 30 427µs 392µs 728µs 742µs
dispatch 30 29µs 28µs 50µs 132µs
coordinator_to_provider 30 756ms 3ms 2.282s 2.283s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=18.4µs (threshold=1ms)
parse:p95<=5ms PASS p95=53µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.578866ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.062ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=427.433µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=728µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=29.233µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=50µ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.912s
Throughput 4.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 753ms 6ms 2.281s 2.281s
parse 30 21µs 18µs 30µs 86µs
reserve 30 2ms 2ms 4ms 4ms
route 30 36µs 24µs 62µs 387µs
encrypt 30 576µs 552µs 934µs 984µs
dispatch 30 52µs 31µs 170µs 260µs
coordinator_to_provider 30 748ms 2ms 2.272s 2.274s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=20.566µs (threshold=1ms)
parse:p95<=5ms PASS p95=30µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.086133ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.516ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=575.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=934µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=51.833µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=170µ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.949s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.273s 2.289s 2.292s 2.292s
parse 12 142µs 109µs 395µs 395µs
reserve 12 7ms 7ms 8ms 8ms
route 12 18µs 10µs 51µs 51µs
encrypt 12 21ms 20ms 22ms 22ms
dispatch 12 44µs 40µs 96µs 96µs
coordinator_to_provider 12 2.232s 2.248s 2.252s 2.252s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=141.833µs (threshold=1ms)
parse:p95<=5ms PASS p95=395µs (threshold=5ms)
reserve:mean<=50ms PASS mean=7.20825ms (threshold=50ms)
reserve:p95<=200ms PASS p95=7.517ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=20.845833ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=22.111ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=96µ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: 05d1569b7e

ℹ️ 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 +503 to +507
let engineBatchedTPS: [(Int, Double)] = await withTaskGroup(
of: (Int, Double).self
) { group in
for batchSize in [2, 4] {
group.addTask {

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 Run BatchedEngine benchmark cases sequentially

runDecodeTPSBracket now launches the B=2 and B=4 engine benchmarks in parallel, but both calls share the same ModelContainer and each constructs a BatchedEngine from that container’s ctx.model. That means two engines can drive the same model concurrently, which invalidates the TPS comparison and can trigger nondeterministic runtime failures when live perf tests run. This benchmark path should execute those batch-size cases one at a time (or use isolated model/container instances).

Useful? React with 👍 / 👎.

)
}
await engine.start()
defer { Task.detached { await engine.stop() } }

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 Await engine stop before leaving performance helper

runBatchedEngineSingle stops the engine via Task.detached in defer, so the function returns before shutdown completes. Subsequent benchmark stages can start while prior engines are still draining, which skews timings and can inflate memory pressure in live runs. Because this function is used repeatedly in the same test, engine shutdown should be awaited synchronously before returning.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-24 22:01 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.831s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.692s 1.692s 1.692s 1.692s
parse 4 99µs 122µs 199µs 199µs
reserve 4 8ms 9ms 10ms 10ms
route 4 49µs 26µs 125µs 125µs
encrypt 4 809µs 770µs 986µs 986µs
dispatch 4 57µs 61µs 73µs 73µs
coordinator_to_provider 4 1.677s 1.678s 1.68s 1.68s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=99.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=199µs (threshold=5ms)
reserve:mean<=50ms PASS mean=7.52975ms (threshold=50ms)
reserve:p95<=200ms PASS p95=10.444ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=808.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=986µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=56.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=73µ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.193s
Throughput 1.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.189s 3.189s 3.193s 3.193s
parse 4 69µs 104µs 111µs 111µs
reserve 4 7ms 9ms 11ms 11ms
route 4 43µs 53µs 56µs 56µs
encrypt 4 798µs 785µs 924µs 924µs
dispatch 4 63µs 69µs 89µs 89µs
coordinator_to_provider 4 1.662s 1.663s 1.665s 1.665s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=69.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=111µs (threshold=5ms)
reserve:mean<=50ms PASS mean=7.363ms (threshold=50ms)
reserve:p95<=200ms PASS p95=10.794ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=797.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=924µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=62.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=89µ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 47
Errors 3
Total Duration 14.997s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 47 662ms 5ms 3.806s 3.844s
parse 46 22µs 20µs 43µs 72µs
reserve 46 2ms 2ms 2ms 4ms
route 46 26µs 24µs 42µs 102µs
encrypt 47 1ms 0s 1ms 1ms
dispatch 47 53µs 37µs 127µs 184µs
coordinator_to_provider 47 605ms 1ms 3.799s 3.837s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=21.717µs (threshold=1ms)
parse:p95<=5ms PASS p95=43µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.599021ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.478ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=545.765µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=882µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=52.68µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=127µ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.989s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.144s 2.131s 2.182s 2.182s
parse 12 15µs 13µs 30µs 30µs
reserve 12 3ms 3ms 4ms 4ms
route 12 18µs 14µs 48µs 48µs
encrypt 12 1ms 1ms 1ms 1ms
dispatch 12 20µs 19µs 29µs 29µs
coordinator_to_provider 12 2.135s 2.123s 2.175s 2.175s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=15.083µs (threshold=1ms)
parse:p95<=5ms PASS p95=30µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.9675ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.675ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=608.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.115ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=19.916µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=29µ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.362s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.122s 2.122s 2.122s 2.122s
parse 4 17µs 19µs 26µs 26µs
reserve 4 3ms 3ms 3ms 3ms
route 4 16µs 12µs 31µs 31µs
encrypt 4 421µs 468µs 472µs 472µs
dispatch 4 22µs 22µs 35µs 35µs
coordinator_to_provider 4 2.115s 2.115s 2.116s 2.116s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=17.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=26µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.56775ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.751ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=421.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=472µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=21.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=35µ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 6.865s
Throughput 5.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 34 644ms 8ms 2.192s 2.192s
parse 34 19µs 16µs 41µs 44µs
reserve 34 2ms 1ms 3ms 3ms
route 34 46µs 18µs 292µs 635µs
encrypt 34 1ms 0s 1ms 2ms
dispatch 34 50µs 32µs 191µs 328µs
coordinator_to_provider 34 639ms 4ms 2.185s 2.185s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=18.852µs (threshold=1ms)
parse:p95<=5ms PASS p95=41µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.647647ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.037ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=519.088µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.372ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=50.147µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=191µ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.706s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.208s 2.208s 2.208s 2.208s
parse 4 15µs 17µs 21µs 21µs
reserve 4 2ms 3ms 3ms 3ms
route 4 13µs 15µs 23µs 23µs
encrypt 4 452µs 415µs 650µs 650µs
dispatch 4 18µs 19µs 20µs 20µs
coordinator_to_provider 4 2.202s 2.203s 2.203s 2.203s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=15.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=21µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.2535ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.951ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=452.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=650µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=17.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=20µ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.624s
Throughput 5.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 766ms 6ms 2.295s 2.295s
parse 30 18µs 15µs 31µs 63µs
reserve 30 2ms 2ms 3ms 3ms
route 30 24µs 16µs 116µs 189µs
encrypt 30 0s 0s 1ms 1ms
dispatch 30 44µs 26µs 108µs 349µs
coordinator_to_provider 30 762ms 3ms 2.289s 2.29s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=17.666µs (threshold=1ms)
parse:p95<=5ms PASS p95=31µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.554433ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.641ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=471.666µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=962µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=44.266µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=108µ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.804s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 770ms 6ms 2.346s 2.346s
parse 30 25µs 19µs 59µs 146µs
reserve 30 2ms 2ms 3ms 3ms
route 30 26µs 22µs 62µs 63µs
encrypt 30 545µs 536µs 762µs 792µs
dispatch 30 43µs 31µs 98µs 229µs
coordinator_to_provider 30 765ms 2ms 2.337s 2.34s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=24.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=59µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.857566ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=545µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=762µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=98µ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.014s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.307s 2.318s 2.332s 2.332s
parse 12 190µs 117µs 569µs 569µs
reserve 12 8ms 8ms 9ms 9ms
route 12 22µs 18µs 44µs 44µs
encrypt 12 18ms 18ms 19ms 19ms
dispatch 12 57µs 56µs 98µs 98µs
coordinator_to_provider 12 2.27s 2.282s 2.296s 2.296s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=189.916µs (threshold=1ms)
parse:p95<=5ms PASS p95=569µs (threshold=5ms)
reserve:mean<=50ms PASS mean=8.404166ms (threshold=50ms)
reserve:p95<=200ms PASS p95=9.453ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=17.891166ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=19.033ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=57.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=98µ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: a39cf7571d

ℹ️ 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".

)
}
await engine.start()
defer { Task.detached { await engine.stop() } }

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 Await engine shutdown in live batching helper

The helper returns immediately after scheduling engine.stop() on a detached task, so the next live test/helper invocation can start another engine while the previous one is still draining. In this suite we repeatedly create engines against the same loaded model/container, so overlapping teardown can skew token/TPS measurements and cause nondeterministic live-test failures under load. Make teardown synchronous (await engine.stop()) before returning from the helper.

Useful? React with 👍 / 👎.

memoryBudgetBytes: 8 * 1024 * 1024 * 1024
)
let scheduler = loaded.scheduler
defer { Task { await scheduler.unloadModel() } }

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 Await scheduler unload before leaving live test

This defer launches unloadModel() asynchronously and does not wait for completion, so the test can finish while teardown is still in progress. Because the suite has multiple live tests that each load large models, the next test may begin with the previous model still unloading, leading to transient memory pressure and flaky failures that are unrelated to assertion logic. Teardown should be awaited before the test exits.

Useful? React with 👍 / 👎.

memoryBudgetBytes: 8 * 1024 * 1024 * 1024
)
let scheduler = loaded.scheduler
defer { Task { await scheduler.unloadModel() } }

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 Await scheduler unload in cancel-path live test

The second live test uses the same fire-and-forget unload pattern, so model teardown can continue after the test completes. In practice this creates overlap with subsequent live tests in the serialized suite, causing intermittent memory pressure and timing noise that can hide real regressions. Use an awaited teardown path so the test does not return until unload finishes.

Useful? React with 👍 / 👎.

}
}
await engine.start()
defer { Task.detached { await engine.stop() } }

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 Await engine stop in eviction/admission live test

This test also detaches engine.stop() in defer, which means cleanup races with later test work and can leave prior engine shutdown running in the background. Because the test drives multiple requests and then immediately exits, overlapping teardown can introduce nondeterministic failures and inflated resource use in subsequent live cases. Teardown should synchronously await engine.stop().

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-24 23:33 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.99s
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 45µs 39µs 80µs 80µs
reserve 4 6ms 7ms 10ms 10ms
route 4 39µs 54µs 71µs 71µs
encrypt 4 706µs 854µs 903µs 903µs
dispatch 4 45µs 41µs 65µs 65µs
coordinator_to_provider 4 1.723s 1.723s 1.727s 1.727s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=44.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=80µs (threshold=5ms)
reserve:mean<=50ms PASS mean=6.233ms (threshold=50ms)
reserve:p95<=200ms PASS p95=10.259ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=705.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=903µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=44.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=65µ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.241s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.237s 3.238s 3.241s 3.241s
parse 4 86µs 56µs 217µs 217µs
reserve 4 6ms 7ms 7ms 7ms
route 4 24µs 34µs 37µs 37µs
encrypt 4 559µs 579µs 585µs 585µs
dispatch 4 46µs 36µs 91µs 91µs
coordinator_to_provider 4 1.664s 1.665s 1.667s 1.667s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=85.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=217µs (threshold=5ms)
reserve:mean<=50ms PASS mean=6.1ms (threshold=50ms)
reserve:p95<=200ms PASS p95=7.35ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=559.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=585µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=46µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=91µ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.106s
Throughput 2.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 594ms 4ms 3.611s 3.639s
parse 50 25µs 21µs 44µs 91µs
reserve 50 2ms 1ms 3ms 3ms
route 50 0s 0s 0s 2ms
encrypt 50 1ms 0s 1ms 2ms
dispatch 50 41µs 35µs 82µs 173µs
coordinator_to_provider 50 590ms 1ms 3.601s 3.634s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=24.8µs (threshold=1ms)
parse:p95<=5ms PASS p95=44µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.63442ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.847ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=519.3µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=736µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=41.06µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=82µ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.114s
Throughput 2.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.196s 2.185s 2.228s 2.228s
parse 12 14µs 13µs 21µs 21µs
reserve 12 2ms 2ms 3ms 3ms
route 12 12µs 10µs 25µs 25µs
encrypt 12 489µs 475µs 743µs 743µs
dispatch 12 29µs 26µs 74µs 74µs
coordinator_to_provider 12 2.188s 2.179s 2.222s 2.222s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=13.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=21µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.470583ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.731ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=489.083µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=743µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=28.583µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=74µ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.025s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 5 2.227s 1.948s 3.345s 3.345s
parse 5 13µs 17µs 18µs 18µs
reserve 5 2ms 2ms 2ms 2ms
route 5 667ms 0s 3.334s 3.334s
queue_wait 1 3.334s 3.334s 3.334s 3.334s
encrypt 5 365µs 375µs 420µs 420µs
dispatch 5 25µs 26µs 30µs 30µs
coordinator_to_provider 5 1.555s 1.942s 1.943s 1.943s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=13µs (threshold=1ms)
parse:p95<=5ms PASS p95=18µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.0196ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.131ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=364.6µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=420µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=24.6µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=30µ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 39
Errors 21
Total Duration 7.319s
Throughput 5.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 39 571ms 4ms 2.236s 2.236s
parse 39 21µs 17µs 46µs 65µs
reserve 39 1ms 1ms 3ms 3ms
route 39 17µs 16µs 35µs 36µs
encrypt 39 0s 0s 1ms 2ms
dispatch 39 41µs 26µs 60µs 538µs
coordinator_to_provider 39 568ms 1ms 2.23s 2.231s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=20.948µs (threshold=1ms)
parse:p95<=5ms PASS p95=46µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.447743ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.526ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=475.564µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.389ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=41.307µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=60µ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.695s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.159s 2.159s 2.159s 2.159s
parse 4 13µs 12µs 22µs 22µs
reserve 4 2ms 2ms 3ms 3ms
route 4 12µs 13µs 17µs 17µs
encrypt 4 549µs 575µs 631µs 631µs
dispatch 4 20µs 21µs 22µs 22µs
coordinator_to_provider 4 2.153s 2.153s 2.154s 2.154s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=13µs (threshold=1ms)
parse:p95<=5ms PASS p95=22µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.203ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.516ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=548.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=631µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=19.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=22µ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.688s
Throughput 5.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 674ms 8ms 2.03s 2.03s
parse 30 16µs 15µs 34µs 43µs
reserve 30 2ms 1ms 4ms 5ms
route 30 17µs 14µs 42µs 46µs
encrypt 30 382µs 346µs 583µs 836µs
dispatch 30 39µs 26µs 136µs 156µs
coordinator_to_provider 30 670ms 6ms 2.024s 2.025s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=16.166µs (threshold=1ms)
parse:p95<=5ms PASS p95=34µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.770866ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.792ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=382.033µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=583µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=39.033µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=136µ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.795s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 785ms 6ms 2.36s 2.36s
parse 30 25µs 20µs 43µs 131µs
reserve 30 2ms 2ms 3ms 3ms
route 30 27µs 23µs 53µs 97µs
encrypt 30 1ms 1ms 1ms 2ms
dispatch 30 51µs 32µs 138µs 257µs
coordinator_to_provider 30 780ms 2ms 2.354s 2.354s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=24.933µs (threshold=1ms)
parse:p95<=5ms PASS p95=43µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.107066ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.119ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=569.633µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=881µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=51.066µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=138µ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.919s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.225s 2.221s 2.237s 2.237s
parse 12 91µs 86µs 150µs 150µs
reserve 12 8ms 8ms 9ms 9ms
route 12 44µs 11µs 207µs 207µs
encrypt 12 13ms 15ms 16ms 16ms
dispatch 12 56µs 41µs 105µs 105µs
coordinator_to_provider 12 2.197s 2.196s 2.213s 2.213s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=90.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=150µs (threshold=5ms)
reserve:mean<=50ms PASS mean=7.824916ms (threshold=50ms)
reserve:p95<=200ms PASS p95=8.701ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=12.532916ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=16.005ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=56µ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: ddd538e24f

ℹ️ 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".

prompt: promptTokens as AnyHashable,
samplingParams: sp
)
_ = await engine.core.addRequest(req)

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 Reintroduce aggregate token-budget gating before addRequest

After the migration, requests are forwarded directly to engine.core.addRequest here, but the planner path no longer enforces a cumulative currentTokenBudgetUsed + requestBudget check before admission. planner.admit(...) only validates per-request limits/queue size (see BatchQueuePlanner.admit), so multiple large requests can be accepted simultaneously as long as each one is individually below tokenBudgetMax, which bypasses the previous pending→admit budget gate and can overcommit KV memory under burst traffic.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed — cumulative budget gate at BatchScheduler.swift:316 (activeUsed + requestBudget > tokenBudgetMax). Also at line 296 for per-request cap. See BatchSchedulerBudgetTests for coverage.

let elapsed = Self.seconds(between: startedAt, and: .now)
guard epoch == generationEpoch, generator === gen else {
return false
recordBatchPerformance(observedBatchSize: max(1, activeBridges.count + 1), tps: tps)

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 Measure adaptive cap from running rows, not bridge count

This uses activeBridges.count + 1 as the observed batch size, but activeBridges includes requests still waiting in the engine queue (not yet admitted/running). Under backlog (e.g., engine cap 2 with many queued requests), the adaptive policy records inflated batch sizes and synthetic aggregate TPS, which can drive incorrect cap adjustments and degrade scheduling stability.

Useful? React with 👍 / 👎.

var maxTokensPotential: Int64 = 0
for entry in active.values {
for entry in activeBridges.values {
activeTokens += Int64(entry.promptTokens + entry.completionTokens)

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 Update bridge completion counters before reporting active tokens

backendCapacity() reports activeTokens from entry.promptTokens + entry.completionTokens, but completionTokens in BridgeState is only assigned in recordFinish (after the bridge is removed), so in-flight decode progress is never reflected in heartbeats. This under-reports live token load and skews coordinator-side backlog/health accounting while requests are running.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-24 23:59 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.011s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.832s 1.832s 1.832s 1.832s
parse 4 31µs 32µs 66µs 66µs
reserve 4 3ms 4ms 4ms 4ms
route 4 14µs 13µs 28µs 28µs
encrypt 4 351µs 373µs 381µs 381µs
dispatch 4 21µs 22µs 24µs 24µs
coordinator_to_provider 4 1.825s 1.826s 1.827s 1.827s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=31.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=66µs (threshold=5ms)
reserve:mean<=50ms PASS mean=3.0555ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.324ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=350.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=381µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=20.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=24µ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.342s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.34s 3.341s 3.342s 3.342s
parse 4 15µs 14µs 20µs 20µs
reserve 4 3ms 4ms 4ms 4ms
route 4 8µs 8µs 13µs 13µs
encrypt 4 386µs 398µs 400µs 400µs
dispatch 4 27µs 23µs 44µs 44µs
coordinator_to_provider 4 1.744s 1.744s 1.745s 1.745s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=15µs (threshold=1ms)
parse:p95<=5ms PASS p95=20µs (threshold=5ms)
reserve:mean<=50ms PASS mean=3.05425ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.338ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=385.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=400µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=26.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 15.634s
Throughput 3.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 561ms 4ms 3.457s 3.458s
parse 49 28µs 20µs 77µs 127µs
reserve 49 2ms 1ms 4ms 5ms
route 49 28µs 26µs 51µs 88µs
encrypt 50 514µs 515µs 733µs 797µs
dispatch 50 38µs 33µs 69µs 125µs
coordinator_to_provider 50 507ms 1ms 3.445s 3.448s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=27.53µs (threshold=1ms)
parse:p95<=5ms PASS p95=77µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.792428ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.555ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=514.28µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=733µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=37.52µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=69µ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.832s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.143s 2.149s 2.153s 2.153s
parse 12 17µs 16µs 38µs 38µs
reserve 12 3ms 3ms 4ms 4ms
route 12 12µs 12µs 19µs 19µs
encrypt 12 1ms 1ms 2ms 2ms
dispatch 12 23µs 21µs 56µs 56µs
coordinator_to_provider 12 2.133s 2.141s 2.145s 2.145s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=16.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=38µs (threshold=5ms)
reserve:mean<=50ms PASS mean=3.168083ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.336ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=884.333µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.686ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=23.333µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=56µ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.922s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.362s 2.362s 2.362s 2.362s
parse 4 25µs 32µs 33µs 33µs
reserve 4 2ms 2ms 3ms 3ms
route 4 23µs 19µs 42µs 42µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 32µs 31µs 54µs 54µs
coordinator_to_provider 4 2.356s 2.356s 2.356s 2.356s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=25.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=33µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.36ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.597ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=870.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.215ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=31.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=54µ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.018s
Throughput 6.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 388ms 4ms 2.349s 2.35s
parse 60 18µs 16µs 42µs 49µs
reserve 60 1ms 1ms 3ms 3ms
route 60 28µs 17µs 99µs 284µs
encrypt 60 0s 0s 1ms 1ms
dispatch 60 31µs 26µs 76µs 126µs
coordinator_to_provider 60 385ms 1ms 2.341s 2.343s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=17.883µs (threshold=1ms)
parse:p95<=5ms PASS p95=42µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.37965ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.578ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=439.383µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=787µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=31.083µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=76µ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.626s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.149s 2.149s 2.149s 2.149s
parse 4 31µs 25µs 60µs 60µs
reserve 4 2ms 2ms 2ms 2ms
route 4 11µs 12µs 16µs 16µs
encrypt 4 444µs 431µs 545µs 545µs
dispatch 4 31µs 22µs 66µs 66µs
coordinator_to_provider 4 2.143s 2.144s 2.144s 2.144s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=31µs (threshold=1ms)
parse:p95<=5ms PASS p95=60µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.9445ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.15ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=443.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=545µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=30.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=66µ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.838s
Throughput 5.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 704ms 10ms 2.115s 2.115s
parse 30 19µs 16µs 48µs 62µs
reserve 30 2ms 2ms 5ms 6ms
route 30 14µs 15µs 27µs 35µs
encrypt 30 1ms 0s 2ms 3ms
dispatch 30 29µs 20µs 75µs 121µs
coordinator_to_provider 30 698ms 7ms 2.107s 2.107s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=19.4µs (threshold=1ms)
parse:p95<=5ms PASS p95=48µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.4647ms (threshold=50ms)
reserve:p95<=200ms PASS p95=5.494ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=625.666µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.723ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=28.933µ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.849s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 813ms 8ms 2.446s 2.446s
parse 30 19µs 19µs 38µs 40µs
reserve 30 2ms 2ms 3ms 4ms
route 30 26µs 20µs 68µs 98µs
encrypt 30 1ms 1ms 1ms 2ms
dispatch 30 51µs 26µs 153µs 424µs
coordinator_to_provider 30 808ms 3ms 2.439s 2.441s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=19.033µs (threshold=1ms)
parse:p95<=5ms PASS p95=38µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.8627ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.032ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=600µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.342ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=50.7µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=153µ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.949s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.242s 2.237s 2.278s 2.278s
parse 12 112µs 87µs 413µs 413µs
reserve 12 9ms 9ms 9ms 9ms
route 12 23µs 25µs 29µs 29µs
encrypt 12 18ms 18ms 19ms 19ms
dispatch 12 50µs 51µs 119µs 119µs
coordinator_to_provider 12 2.205s 2.2s 2.241s 2.241s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=111.833µs (threshold=1ms)
parse:p95<=5ms PASS p95=413µs (threshold=5ms)
reserve:mean<=50ms PASS mean=8.606666ms (threshold=50ms)
reserve:p95<=200ms PASS p95=9.161ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=18.402083ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=19.189ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=50µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=119µs (threshold=50ms)

@github-actions

github-actions Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-25 00:43 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.898s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.699s 1.699s 1.699s 1.699s
parse 4 42µs 41µs 71µs 71µs
reserve 4 9ms 11ms 13ms 13ms
route 4 47µs 34µs 96µs 96µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 58µs 58µs 90µs 90µs
coordinator_to_provider 4 1.679s 1.681s 1.684s 1.684s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=41.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=71µs (threshold=5ms)
reserve:mean<=50ms PASS mean=8.78825ms (threshold=50ms)
reserve:p95<=200ms PASS p95=12.806ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=883.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.031ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=57.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=90µ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.233s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.229s 3.23s 3.233s 3.233s
parse 4 37µs 45µs 74µs 74µs
reserve 4 5ms 6ms 7ms 7ms
route 4 19µs 16µs 34µs 34µs
encrypt 4 543µs 571µs 579µs 579µs
dispatch 4 34µs 36µs 44µs 44µs
coordinator_to_provider 4 1.669s 1.67s 1.671s 1.671s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=37.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=74µs (threshold=5ms)
reserve:mean<=50ms PASS mean=5.0435ms (threshold=50ms)
reserve:p95<=200ms PASS p95=6.81ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=542.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=579µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=33.75µ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 15.213s
Throughput 3.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 575ms 5ms 3.552s 3.574s
parse 48 27µs 22µs 62µs 91µs
reserve 48 2ms 1ms 3ms 3ms
route 48 31µs 23µs 95µs 122µs
encrypt 50 1ms 0s 1ms 14ms
dispatch 50 39µs 34µs 74µs 141µs
coordinator_to_provider 50 470ms 1ms 3.534s 3.568s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=27.333µs (threshold=1ms)
parse:p95<=5ms PASS p95=62µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.624145ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.109ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=833.1µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.139ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=39.18µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=74µ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.689s
Throughput 3.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.058s 2.053s 2.077s 2.077s
parse 12 16µs 14µs 25µs 25µs
reserve 12 2ms 2ms 3ms 3ms
route 12 13µs 14µs 23µs 23µs
encrypt 12 441µs 390µs 834µs 834µs
dispatch 12 32µs 23µs 84µs 84µs
coordinator_to_provider 12 2.05s 2.047s 2.071s 2.071s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=15.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=25µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.484583ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.408ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=440.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=834µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=31.833µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=84µ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.483s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.023s 2.023s 2.023s 2.023s
parse 4 12µs 13µs 16µs 16µs
reserve 4 2ms 2ms 2ms 2ms
route 4 16µs 19µs 21µs 21µs
encrypt 4 486µs 507µs 599µs 599µs
dispatch 4 37µs 31µs 85µs 85µs
coordinator_to_provider 4 2.017s 2.017s 2.017s 2.017s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=12µs (threshold=1ms)
parse:p95<=5ms PASS p95=16µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.165ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.305ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=485.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=599µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=37.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=85µ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 35
Errors 25
Total Duration 7.998s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 35 723ms 9ms 2.523s 2.523s
parse 34 19µs 17µs 31µs 44µs
reserve 34 2ms 2ms 4ms 8ms
route 34 20µs 18µs 49µs 55µs
encrypt 35 1ms 0s 1ms 2ms
dispatch 35 0s 0s 0s 1ms
coordinator_to_provider 35 646ms 3ms 2.516s 2.517s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=18.558µs (threshold=1ms)
parse:p95<=5ms PASS p95=31µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.128941ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.126ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=569.6µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.215ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=80.685µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=224µ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 5
Errors 25
Total Duration 4.414s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 5 2.311s 1.993s 3.583s 3.583s
parse 5 24µs 23µs 30µs 30µs
reserve 5 3ms 3ms 3ms 3ms
route 5 713ms 0s 3.566s 3.566s
queue_wait 1 3.566s 3.566s 3.566s 3.566s
encrypt 5 452µs 447µs 575µs 575µs
dispatch 5 22µs 21µs 26µs 26µs
coordinator_to_provider 5 1.591s 1.986s 1.987s 1.987s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=23.8µs (threshold=1ms)
parse:p95<=5ms PASS p95=30µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.715ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.136ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=452.4µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=575µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=22µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=26µ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.925s
Throughput 5.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 731ms 6ms 2.229s 2.229s
parse 30 20µs 15µs 44µs 84µs
reserve 30 2ms 2ms 3ms 4ms
route 30 21µs 15µs 80µs 83µs
encrypt 30 458µs 444µs 862µs 961µs
dispatch 30 30µs 22µs 72µs 74µs
coordinator_to_provider 30 727ms 4ms 2.224s 2.224s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=19.866µs (threshold=1ms)
parse:p95<=5ms PASS p95=44µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.763733ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.762ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=457.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=862µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=30.133µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=72µ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.82s
Throughput 4.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 823ms 5ms 2.499s 2.499s
parse 30 25µs 20µs 50µs 83µs
reserve 30 2ms 2ms 3ms 4ms
route 30 40µs 23µs 114µs 394µs
encrypt 30 1ms 1ms 1ms 1ms
dispatch 30 61µs 31µs 122µs 864µs
coordinator_to_provider 30 818ms 1ms 2.492s 2.492s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=24.666µs (threshold=1ms)
parse:p95<=5ms PASS p95=50µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.814966ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.932ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=549.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=850µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=60.9µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=122µ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.44s
Throughput 2.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 13 2.115s 1.988s 3.652s 3.652s
parse 13 131µs 93µs 323µs 323µs
reserve 13 8ms 8ms 10ms 10ms
route 13 278ms 0s 3.616s 3.616s
queue_wait 1 3.617s 3.617s 3.617s 3.617s
encrypt 13 15ms 17ms 19ms 19ms
dispatch 13 66µs 48µs 198µs 198µs
coordinator_to_provider 13 1.803s 1.95s 1.97s 1.97s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=131.23µs (threshold=1ms)
parse:p95<=5ms PASS p95=323µs (threshold=5ms)
reserve:mean<=50ms PASS mean=8.378923ms (threshold=50ms)
reserve:p95<=200ms PASS p95=9.585ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=14.615846ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=18.515ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=65.692µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=198µs (threshold=50ms)

@github-actions

github-actions Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-25 00:49 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.973s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.765s 1.765s 1.765s 1.765s
parse 4 22µs 22µs 35µs 35µs
reserve 4 3ms 4ms 5ms 5ms
route 4 15µs 13µs 30µs 30µs
encrypt 4 384µs 396µs 459µs 459µs
dispatch 4 26µs 26µs 36µs 36µs
coordinator_to_provider 4 1.757s 1.758s 1.759s 1.759s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=21.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=35µs (threshold=5ms)
reserve:mean<=50ms PASS mean=3.424ms (threshold=50ms)
reserve:p95<=200ms PASS p95=5.031ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=384µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=459µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=26.25µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=36µ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.308s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.304s 3.305s 3.308s 3.308s
parse 4 37µs 42µs 48µs 48µs
reserve 4 6ms 7ms 8ms 8ms
route 4 23µs 23µs 32µs 32µs
encrypt 4 773µs 889µs 917µs 917µs
dispatch 4 52µs 59µs 65µs 65µs
coordinator_to_provider 4 1.744s 1.745s 1.747s 1.747s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=37µs (threshold=1ms)
parse:p95<=5ms PASS p95=48µs (threshold=5ms)
reserve:mean<=50ms PASS mean=5.74ms (threshold=50ms)
reserve:p95<=200ms PASS p95=8.1ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=773.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=917µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=51.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=65µ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.859s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 618ms 5ms 3.735s 3.847s
parse 48 28µs 21µs 76µs 141µs
reserve 48 2ms 2ms 3ms 4ms
route 48 32µs 25µs 57µs 225µs
encrypt 50 1ms 1ms 1ms 1ms
dispatch 50 51µs 39µs 139µs 370µs
coordinator_to_provider 50 514ms 1ms 3.727s 3.841s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=27.729µs (threshold=1ms)
parse:p95<=5ms PASS p95=76µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.72425ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.099ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=541.7µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.032ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=50.66µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=139µ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.052s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.296s 2.299s 2.302s 2.302s
parse 12 13µs 13µs 25µs 25µs
reserve 12 3ms 3ms 4ms 4ms
route 12 53µs 16µs 233µs 233µs
encrypt 12 1ms 0s 1ms 1ms
dispatch 12 26µs 20µs 68µs 68µs
coordinator_to_provider 12 2.288s 2.29s 2.295s 2.295s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=13.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=25µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.642ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.796ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=584µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.18ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=26.166µ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.95s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.286s 2.287s 2.287s 2.287s
parse 4 63µs 64µs 74µs 74µs
reserve 4 7ms 7ms 7ms 7ms
route 4 32µs 45µs 47µs 47µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 47µs 47µs 87µs 87µs
coordinator_to_provider 4 2.268s 2.268s 2.268s 2.268s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=63.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=74µs (threshold=5ms)
reserve:mean<=50ms PASS mean=6.57275ms (threshold=50ms)
reserve:p95<=200ms PASS p95=6.965ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=889.25µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.207ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=47µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=87µ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.545s
Throughput 4.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 34 652ms 8ms 2.214s 2.214s
parse 34 21µs 18µs 33µs 97µs
reserve 34 2ms 2ms 3ms 4ms
route 34 5ms 0s 0s 160ms
queue_wait 1 161ms 161ms 161ms 161ms
encrypt 34 1ms 0s 1ms 4ms
dispatch 34 39µs 31µs 140µs 144µs
coordinator_to_provider 34 643ms 4ms 2.207s 2.208s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=21.205µs (threshold=1ms)
parse:p95<=5ms PASS p95=33µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.809411ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.379ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=583.47µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.082ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=38.794µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=140µ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.562s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.077s 2.077s 2.077s 2.077s
parse 4 16µs 18µs 20µs 20µs
reserve 4 2ms 2ms 2ms 2ms
route 4 11µs 12µs 15µs 15µs
encrypt 4 422µs 443µs 455µs 455µs
dispatch 4 29µs 30µs 43µs 43µs
coordinator_to_provider 4 2.071s 2.071s 2.071s 2.071s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=15.5µs (threshold=1ms)
parse:p95<=5ms PASS p95=20µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.16825ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.482ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=421.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=455µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=28.75µ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.314s
Throughput 4.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 767ms 5ms 2.307s 2.308s
parse 30 17µs 15µs 31µs 49µs
reserve 30 2ms 1ms 3ms 4ms
route 30 19µs 15µs 43µs 48µs
encrypt 30 413µs 352µs 733µs 805µs
dispatch 30 32µs 26µs 78µs 164µs
coordinator_to_provider 30 763ms 3ms 2.301s 2.301s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=17.033µs (threshold=1ms)
parse:p95<=5ms PASS p95=31µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.6714ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.118ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=413.233µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=733µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=32.333µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=78µ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.365s
Throughput 4.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 739ms 6ms 2.241s 2.242s
parse 30 20µs 17µs 36µs 53µs
reserve 30 2ms 2ms 3ms 3ms
route 30 34µs 25µs 149µs 157µs
encrypt 30 497µs 501µs 742µs 927µs
dispatch 30 35µs 33µs 70µs 71µs
coordinator_to_provider 30 734ms 2ms 2.234s 2.237s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=20.366µs (threshold=1ms)
parse:p95<=5ms PASS p95=36µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.766333ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.834ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=497.133µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=742µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=34.9µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=70µ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.96s
Throughput 3.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.213s 2.204s 2.233s 2.233s
parse 12 77µs 78µs 104µs 104µs
reserve 12 9ms 8ms 10ms 10ms
route 12 10µs 10µs 16µs 16µs
encrypt 12 19ms 20ms 20ms 20ms
dispatch 12 37µs 37µs 55µs 55µs
coordinator_to_provider 12 2.174s 2.165s 2.193s 2.193s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=76.916µs (threshold=1ms)
parse:p95<=5ms PASS p95=104µs (threshold=5ms)
reserve:mean<=50ms PASS mean=8.514083ms (threshold=50ms)
reserve:p95<=200ms PASS p95=10.444ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=19.070666ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=20.446ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=36.833µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=55µs (threshold=50ms)

@Gajesh2007
Gajesh2007 force-pushed the feat/batched-engine-migration branch from 77989fa to cc8c973 Compare May 25, 2026 00:47

@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: cc8c973836

ℹ️ 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 +136 to +143
let engine = await Self.makeBatchedEngine(
container: container,
modelId: modelId,
maxConcurrentRequests: maxConcurrentRequests,
eosTokenIds: snapshot.eosTokenIds
)
self.engine = engine
await engine.start()

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 Revalidate generation epoch after awaited engine startup

loadModel checks loadEpoch only before the later await points, but then awaits makeBatchedEngine and engine.start without re-checking whether another loadModel/unloadModel has already advanced generationEpoch. If a second lifecycle call interleaves during those awaits, this stale invocation can still write self.engine, planner state, and watchdog state afterward, resurrecting an engine that should have been superseded and leaving model state inconsistent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed — epoch revalidated at BatchScheduler.swift:148-153 (after makeBatchedEngine) and again at lines 155-159 (after engine.start). Stale invocations now call engine.stop() and bail.

if output.finished || output.error != nil {
sawTerminal = true
// "abort"/non-nil error → .error; "stop"/"length"/nil → .info.
let isAbort = output.finishReason == "abort" || output.error != nil

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 Surface terminal engine errors instead of cancellation

This branch classifies every terminal output with a non-nil error as cancellation and emits only "request cancelled". When the engine terminates a request due to an internal/runtime failure (i.e., finishReason is not "abort" but error is populated), callers lose the real failure reason and telemetry misattributes server-side faults as cancels, which makes diagnosis and retry behavior incorrect.

Useful? React with 👍 / 👎.

@@ -183,8 +158,7 @@ struct PerformanceLiveTests {
let scheduler = loaded.scheduler
defer { Task { await scheduler.unloadModel() } }

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 Await scheduler unload before leaving perf scenarios

The teardown here launches unloadModel() in a detached task, so the scenario can return before model shutdown is complete. In this live performance suite, subsequent cases may begin while previous unload is still draining, which introduces avoidable memory pressure and timing noise that can skew throughput/TTFT measurements.

Useful? React with 👍 / 👎.

…atchedEngine

Replaces the BatchGenerator-driven inference loop with the new
BatchedEngine orchestrator from mlx-swift-lm. Public surface of
BatchScheduler is preserved (ProviderLoop and StandaloneServer
unchanged); only internals swap.

What BatchedEngine gives us (vs BatchGenerator):
  - Engine-owned step loop on its own DispatchQueue (no worker task)
  - Auto-preemption with re-queue when KV budget exceeded
  - Chunked cold prefill interleaved with decode (prefillStepSize=512,
    maxNumBatchedTokens=8192) so running decode is not starved
  - Per-request stop-sequence state machine (EOS + stopTokenIds +
    tokenized stop strings)
  - Per-request RequestOutputCollector with non-blocking get + producer
    merge on backpressure
  - SamplingParams support: temperature, topP, topK, minP, seed,
    repetitionPenalty, presencePenalty, frequencyPenalty
  - Auto Memory.clearCache() after 8 idle steps (M4 IOKit panic
    mitigation)
  - First-class cancellation (abortRequest emits terminal RequestOutput
    immediately, scheduler frees slot on next step)

Migration design decisions:
  - Prefix cache OFF (prefixCacheConfig: nil, prefixCache: nil) with
    inline TB-007 security comment. Cross-tenant data persistence risk;
    flipping requires a fresh threat-model review.
  - MTP OFF (mtpEnabled: false).
  - KV budget: ours only. SchedulerConfig.maxKVCacheTokens = 0
    (unlimited). Engine never preempts; our byte-level kvBudget +
    BatchQueuePlanner are the sole gates. Single source of truth.
  - Adaptive cap (AdaptiveBatchCapPolicy) propagates to engine via the
    Scheduler.setMaxNumSeqs(_:) API (companion upstream PR #27, now
    merged on mlx-swift-lm main).
  - Pre-tokenize at submit time via existing tk.inner.applyChatTemplate
    and pass [Int] to engine via Request(prompt: tokens as AnyHashable).
    Avoids double tokenization and avoids the engine's silent
    role:content fallback on chat-template error.
  - Distinct error strings: pending-queue 120s timeout emits
    .error('request timed out waiting for capacity'); client cancel
    emits .error('request cancelled'). Preserves operator
    observability.

Kept from previous BatchScheduler (not in BatchedEngine):
  - KV-bytes-per-token estimation from config.json (GQA, hybrid, KV
    sharing, recurrent layers)
  - tokenBudgetMax derived from ProcessInfo.physicalMemory +
    MLX.GPU.activeMemory
  - GlobalKVCacheBudget (process-wide byte reservation across loaded
    models)
  - BatchQueuePlanner admission + 120s pending-queue timeout
  - AdaptiveBatchCapPolicy + TPS EWMA
  - GPUEnforcement.requireMetal()
  - capacity()/backendCapacity() heartbeat shape
  - Public AsyncStream<GenerationEvent> contract

Submodule bump:
  - libs/mlx-swift-lm: d164323f -> 096e792 (upstream main, includes
    BOTH PR #26 'Add OpenAI-compatible inference server' (MLXLMServer)
    AND PR #27 'feat(scheduler): add runtime setMaxNumSeqs(_:)').
  - Provider-swift now references the merged mainline commit, not a
    feature-branch tip. MLXLMServer is linked transitively but not yet
    consumed by provider-swift code (planned for a separate follow-up
    PR replacing StandaloneServer with MLXOpenAIService).

Package.swift bump:
  - hummingbird exact 2.22.0 -> exact 2.23.0 to satisfy mlx-swift-lm's
    new MLXLMServer target which declares from: 2.23.0. hummingbird-
    websocket 2.6.0 remains compatible (verified by swift package
    resolve).

Tests:
  - ContinuousBatchingLiveTests rewritten to drive BatchedEngine
    directly (still bypassing BatchScheduler). Sequence-equivalence
    invariants for eviction/admission preserved.
  - PerformanceLiveTests bracket repointed to BatchedEngine; header
    note added re: baseline numbers needing re-measurement.
  - BatchSchedulerEngineIntegrationTests (new, +201 LOC): 4 non-live
    GenerationEvent mapping tests + 2 live (env-gated) integration
    tests covering submit -> chunk -> info -> finish and cancel ->
    error -> finish.
  - RowSamplersTests and BatchKVCacheTests kept verbatim.

Verification:
  swift build  (provider-swift): clean (only pre-existing MLX.GPU.*
                                  deprecation warnings)
  swift test   (provider-swift, non-live): 213/213 pass (Swift Testing
                                  + XCTest, 19 suites); 2 live tests
                                  auto-skipped without
                                  DARKBLOOM_LIVE_MLX_TESTS=1.

Live MLX tests still recommended on prod model before merge:
  cd provider-swift
  DARKBLOOM_LIVE_MLX_TESTS=1 swift test --filter ContinuousBatchingLiveTests
  DARKBLOOM_LIVE_MLX_TESTS=1 swift test --filter BatchSchedulerEngineIntegrationTests
  DARKBLOOM_LIVE_MLX_TESTS=1 swift test --filter PerformanceLiveTests

Net LOC delta:
  BatchScheduler.swift: -56 net (-428 / +372)
  ContinuousBatchingLiveTests.swift: +93 net
  PerformanceLiveTests.swift: +44 net
  BatchSchedulerEngineIntegrationTests.swift: +201 (new)
  ProviderLoop.swift, StandaloneServer.swift: untouched
@github-actions

github-actions Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-25 01:09 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.954s
Throughput 0.8 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 1.74s 1.74s 1.74s 1.74s
parse 4 44µs 61µs 70µs 70µs
reserve 4 5ms 6ms 7ms 7ms
route 4 22µs 21µs 42µs 42µs
encrypt 4 537µs 569µs 589µs 589µs
dispatch 4 40µs 48µs 49µs 49µs
coordinator_to_provider 4 1.729s 1.73s 1.731s 1.731s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=44.25µs (threshold=1ms)
parse:p95<=5ms PASS p95=70µs (threshold=5ms)
reserve:mean<=50ms PASS mean=4.67775ms (threshold=50ms)
reserve:p95<=200ms PASS p95=6.595ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=536.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=589µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=39.75µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=49µ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.329s
Throughput 1.2 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 3.324s 3.325s 3.329s 3.329s
parse 4 26µs 28µs 32µs 32µs
reserve 4 4ms 5ms 6ms 6ms
route 4 15µs 16µs 21µs 21µs
encrypt 4 521µs 543µs 567µs 567µs
dispatch 4 39µs 40µs 50µs 50µs
coordinator_to_provider 4 1.779s 1.78s 1.781s 1.781s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=25.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=32µs (threshold=5ms)
reserve:mean<=50ms PASS mean=4.31375ms (threshold=50ms)
reserve:p95<=200ms PASS p95=6.232ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=520.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=567µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=38.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=50µ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 13.829s
Throughput 3.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 618ms 4ms 3.756s 3.814s
parse 50 23µs 20µs 46µs 90µs
reserve 50 2ms 1ms 3ms 3ms
route 50 25µs 21µs 56µs 57µs
encrypt 50 512µs 486µs 743µs 918µs
dispatch 50 44µs 31µs 104µs 193µs
coordinator_to_provider 50 614ms 1ms 3.746s 3.807s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=23.28µs (threshold=1ms)
parse:p95<=5ms PASS p95=46µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.61746ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.831ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=511.62µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=743µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.92µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=104µ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.912s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.081s 2.072s 2.109s 2.109s
parse 12 20µs 18µs 43µs 43µs
reserve 12 3ms 3ms 5ms 5ms
route 12 16µs 16µs 33µs 33µs
encrypt 12 1ms 1ms 1ms 1ms
dispatch 12 31µs 24µs 90µs 90µs
coordinator_to_provider 12 2.07s 2.063s 2.1s 2.1s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=20µs (threshold=1ms)
parse:p95<=5ms PASS p95=43µs (threshold=5ms)
reserve:mean<=50ms PASS mean=3.182416ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.622ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=796.416µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.078ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=31.083µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=90µ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.777s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.181s 2.181s 2.181s 2.181s
parse 4 19µs 19µs 22µs 22µs
reserve 4 2ms 2ms 2ms 2ms
route 4 18µs 13µs 40µs 40µs
encrypt 4 1ms 1ms 1ms 1ms
dispatch 4 16µs 19µs 19µs 19µs
coordinator_to_provider 4 2.175s 2.175s 2.175s 2.175s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=18.75µs (threshold=1ms)
parse:p95<=5ms PASS p95=22µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.22675ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.42ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=683.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.154ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=16µ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 37
Errors 23
Total Duration 8.061s
Throughput 4.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 37 684ms 6ms 2.542s 2.543s
parse 36 21µs 19µs 40µs 69µs
reserve 36 2ms 2ms 3ms 8ms
route 36 23µs 19µs 45µs 77µs
encrypt 37 1ms 0s 1ms 4ms
dispatch 37 39µs 32µs 99µs 121µs
coordinator_to_provider 37 611ms 1ms 2.532s 2.536s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=21.055µs (threshold=1ms)
parse:p95<=5ms PASS p95=40µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.894555ms (threshold=50ms)
reserve:p95<=200ms PASS p95=3.496ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=599.054µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.107ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=38.891µ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.564s
Throughput 1.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 4 2.158s 2.158s 2.159s 2.159s
parse 4 11µs 9µs 22µs 22µs
reserve 4 2ms 2ms 3ms 3ms
route 4 10µs 9µs 16µs 16µs
encrypt 4 508µs 550µs 679µs 679µs
dispatch 4 22µs 22µs 27µs 27µs
coordinator_to_provider 4 2.153s 2.153s 2.153s 2.153s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=11µs (threshold=1ms)
parse:p95<=5ms PASS p95=22µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.22675ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.673ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=507.75µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=679µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=21.5µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=27µ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.859s
Throughput 5.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 757ms 6ms 2.281s 2.281s
parse 30 36µs 15µs 330µs 343µs
reserve 30 1ms 1ms 3ms 4ms
route 30 27µs 14µs 49µs 289µs
encrypt 30 414µs 352µs 809µs 894µs
dispatch 30 38µs 28µs 106µs 118µs
coordinator_to_provider 30 753ms 4ms 2.275s 2.276s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=36.166µs (threshold=1ms)
parse:p95<=5ms PASS p95=330µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.467666ms (threshold=50ms)
reserve:p95<=200ms PASS p95=2.827ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=413.966µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=809µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=38.166µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=106µ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.622s
Throughput 4.5 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 756ms 7ms 2.277s 2.277s
parse 30 27µs 19µs 128µs 149µs
reserve 30 2ms 2ms 5ms 6ms
route 30 0s 0s 0s 1ms
encrypt 30 1ms 1ms 1ms 2ms
dispatch 30 35µs 27µs 80µs 85µs
coordinator_to_provider 30 751ms 2ms 2.269s 2.27s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=26.766µs (threshold=1ms)
parse:p95<=5ms PASS p95=128µs (threshold=5ms)
reserve:mean<=50ms PASS mean=2.2206ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.634ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=595.633µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.091ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=34.533µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=80µ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.203s
Throughput 2.9 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 12 2.18s 2.174s 2.2s 2.2s
parse 12 78µs 78µs 125µs 125µs
reserve 12 7ms 7ms 7ms 7ms
route 12 21µs 27µs 52µs 52µs
encrypt 12 18ms 18ms 19ms 19ms
dispatch 12 43µs 37µs 74µs 74µs
coordinator_to_provider 12 2.142s 2.136s 2.162s 2.162s

Assertion Report: FAIL

Assertion Result Detail
parse:mean<=1ms PASS mean=78µs (threshold=1ms)
parse:p95<=5ms PASS p95=125µs (threshold=5ms)
reserve:mean<=50ms PASS mean=6.73ms (threshold=50ms)
reserve:p95<=200ms PASS p95=7.085ms (threshold=200ms)
encrypt:mean<=5ms FAIL mean=18.31275ms (threshold=5ms)
encrypt:p95<=50ms PASS p95=19.199ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=42.583µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=74µs (threshold=50ms)

@Gajesh2007
Gajesh2007 merged commit 80fc0ee into master May 25, 2026
29 checks passed
jonathan308 added a commit that referenced this pull request Oct 1, 2026
mlx-swift-lm main now contains #206, #207 and #219 (landed through #246) and
#245. Pin it instead of the stacked SDK branch commit. The pinned tree is
identical to the SDK validated with this stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 1, 2026
mlx-swift-lm main now contains #206, #207 and #219 (landed through #246) and
#245. Pin it instead of the stacked SDK branch commit. The pinned tree is
identical to the SDK validated with this stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 1, 2026
mlx-swift-lm main now contains #206, #207 and #219 (landed through #246) and
#245. Pin it instead of the stacked SDK branch commit. The pinned tree is
identical to the SDK validated with this stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007 pushed a commit that referenced this pull request Oct 1, 2026
… MTP (#1282)

* perf(mimo): default-on decode kernels and target-only adaptive serial MTP

Pin mlx-swift-lm to the stack that enables the exact MiMo short-forward
decode kernels by default and adds `CBv2MTPConfig.allowsAdaptiveSerialRounds`.

- Forward the three kernel rollbacks (`DARKBLOOM_MIMO_FUSED_DECODE_NORMS`,
  `DARKBLOOM_MIMO_DECODE_EXPERTS`, `DARKBLOOM_MIMO_DECODE_ROUTER_GEMV`,
  `0`/`false`/`no`/`off`) to the launchd provider job, so an installed
  provider can restore the stock path.
- Build every native MiMo MTP config through `nativeMiMoMTPConfig`, which
  keeps adaptive plans target-only under serial-target scoring. Each serial
  draft column costs one ordinary target forward, so those rounds could only
  slow decode (25-27 tok/s when the controller locked onto depth 3). MTP stays
  constructed and active with live assistant history; the rectangular opt-in
  keeps adaptive depth.

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

* chore(mimo): pin mlx-swift-lm main 1ee8675a

mlx-swift-lm main now contains #206, #207 and #219 (landed through #246) and
#245. Pin it instead of the stacked SDK branch commit. The pinned tree is
identical to the SDK validated with this stack.

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

---------

Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007 pushed a commit that referenced this pull request Oct 1, 2026
…for reuse (#1299)

* fix(mimo): reuse SSD prefix-cache hits and report cached tokens only for reuse

Every native MiMo V2.6 SSD prefix-cache hit was discarded. The bridge stages
a checkpoint under a placeholder engine request ID and mints the real ID just
before submit; the SDK's native import check compared engine IDs, so each
staged checkpoint was refused (`unsupportedConsumer`). The request prefilled
its whole prompt again and the coordinator received a skipped lookup.

- Pin mlx-swift-lm to the receipt-bound native stage check.
- EngineV2RequestUsageSignal: client-facing cached tokens (standalone usage
  and the provider SSE splice) now count only an actual hit. A matched
  checkpoint whose adoption failed or was skipped used to report its matched
  tokens, which hid this bug locally. Coordinator usage already came from the
  resolved lookup and is unchanged.

Tests: the native MiMo complete-prefix gate gains a bridge-level repeat
(`testNativeCompletePrefixONReusesThePublishedBoundaryThroughTheBridge`): the
second submission of the same prompt must adopt the published boundary with
a resolved hit, saved prefill and byte-identical text. The existing gates
only checked that the first submission published. PrefixCacheReceiptTests
pins the cached-token report for a failed adoption.

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

* chore(mimo): pin mlx-swift-lm main 1ee8675a

mlx-swift-lm main now contains #206, #207 and #219 (landed through #246) and
#245. Pin it instead of the stacked SDK branch commit. The pinned tree is
identical to the SDK validated with this stack.

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

---------

Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007 pushed a commit that referenced this pull request Oct 1, 2026
* perf(mimo): default-on decode kernels and target-only adaptive serial MTP

Pin mlx-swift-lm to the stack that enables the exact MiMo short-forward
decode kernels by default and adds `CBv2MTPConfig.allowsAdaptiveSerialRounds`.

- Forward the three kernel rollbacks (`DARKBLOOM_MIMO_FUSED_DECODE_NORMS`,
  `DARKBLOOM_MIMO_DECODE_EXPERTS`, `DARKBLOOM_MIMO_DECODE_ROUTER_GEMV`,
  `0`/`false`/`no`/`off`) to the launchd provider job, so an installed
  provider can restore the stock path.
- Build every native MiMo MTP config through `nativeMiMoMTPConfig`, which
  keeps adaptive plans target-only under serial-target scoring. Each serial
  draft column costs one ordinary target forward, so those rounds could only
  slow decode (25-27 tok/s when the controller locked onto depth 3). MTP stays
  constructed and active with live assistant history; the rectangular opt-in
  keeps adaptive depth.

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

* perf(mimo): exact rectangular MTP verification by default

Pin mlx-swift-lm to the exact rectangular verification stack (row-exact
multi-row affine projection, fused norms inside the scalar-dense verifier,
scalar-dense default with a guard against drafting through the bulk trunk).

- `nativeMiMoVerificationMode` selects rectangular verification by default.
  A rollback of `DARKBLOOM_MIMO_RECTANGULAR_VERIFY` or of the SDK's
  scalar-dense switch selects serial-target scoring; the provider never
  selects the bulk rectangular trunk, whose reductions differ from serial
  decode.
- The native paged profile keeps serial-target MTP independently of the
  contiguous default.
- LaunchAgent forwards the three verification rollbacks.

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

* chore(mimo): pin mlx-swift-lm main 1ee8675a

mlx-swift-lm main now contains #206, #207 and #219 (landed through #246) and
#245. Pin it instead of the stacked SDK branch commit. The pinned tree is
identical to the SDK validated with this stack.

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

---------

Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

3 active deployments
Preview – d-inference-console-ui-dev — 512fa03c Deployed May 25, 2026 by vercel[bot]
Preview – d-inference — 512fa03c Deployed May 25, 2026 by vercel[bot]
Preview – d-inference-landing — 512fa03c Deployed May 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant