Repository navigation
feat(cluster): make TP and pipeline serving request-safe - #3258
Conversation
…erator reaper - abort_request(request_id): flags the request (its generator stops at the next yield boundary) and closes only that request's backend connection, replacing the all-or-nothing client close for single-request aborts (G3). Signature mirrors AsyncEngineCore.abort_request. - abort_all_requests: flags all tracked requests, writes the rank-side cancel file, closes the shared client, then waits (bounded, default 15s) for BOTH the coordinator counter and rank-0 marker telemetry to report zero active requests — unload no longer trusts client close as drain evidence (G5). - reap_orphaned_generators: pop-only sweep parallel to AsyncEngineCore._reap_orphaned_collectors; requests whose backend finished but whose consumer abandoned the generator are reaped after a grace period, so _active_requests can't leak and wedge (or spuriously unblock) quiescence-gated unload (G4). Driven from has_active_requests and abort_all_requests. - ReadTimeout now also writes the rank-side cancel file: 300s of inactivity means a stalled rank, and the old path let the request run to completion with nobody reading (G5). - Non-distributed engines are untouched; all changes are confined to DistributedBatchedEngine.
…han reaper telemetry: force_cancel_all removes active uids through the registered BatchGenerator, degrades safely with no generator/uids or a failing batch loop, and the cancel file is consumed exactly once per epoch with an ack while foreign-deployment files are ignored. engine: abort_request flags one request and closes only its connection; an aborted stream surfaces DistributedRequestAborted at the next yield boundary and drains the counter; abort_all_requests writes the rank-side cancel file and swaps the client; _wait_for_backend_drain requires rank-side marker evidence and expires unconfirmed when ranks survive; the orphan reaper drops only finished-and-abandoned requests and runs from has_active_requests; a read timeout drops the cancel file. Note: tests/test_distributed_engine.py imports omlx.engine.batched -> engine_core -> mlx, so it needs the full env (WS3 build); the same holds on the base branch.
|
Restacked backend 4/4 onto current |
f155c20 to
dcb7189
Compare
|
@jonathan308, thank you for the thoughtful work on this important part of distributed serving. I’ve taken another pass through the PR to consolidate my findings and avoid asking you to make changes over multiple rounds. Please take a look and let me know what you think. I found several integration pieces present in #3118 but missing from this split:
Please preserve #3257’s authentication improvements and the follow-up fixes already on main when restoring these pieces. I’ll verify the restored integration paths when the update is ready. If you happen to rerun your two-Mac setup, any observations would be helpful. Once I’ve verified the update and CI passes, I can proceed with merging. |
|
@jundot thanks checking what's missing & my tests from the old hardware setup won't be the same waiting on new hardware coming this week . Still can get tests done just different reference hardware this time . |
|
@jundot I restored the integration paths from your consolidated review in
Validation on the branch: 335 passed, 3 skipped across endpoint integration, control-plane, telemetry/cancellation, prompt snapshots, inference worker, distributed engine, SSE, admin cache clearing, and server tests. A full local run reached 11,298 passing after the endpoint follow-up; the remaining 11 failures are local MLX ABI/version checks ( |
|
@jonathan308, thanks for addressing the review so quickly. I verified the restored cancellation and cache paths, including cancelling one request while another continues generating. The authentication improvements are preserved, and Python 3.11–3.13 CI has passed. LGTM, I’ll merge this. |
While PR jundot#3258 bounded continuous-batching prefill to 1 chunk via PrefillCancellationTimeBudget, sequential serving routes (_serve_single, used when callers pass an explicit seed or on non-batchable architectures) still ran the entire prompt prefill synchronously inside stream_generate without checking the cancellation context. This hooks cooperative cancellation into _TelemetryQueue during prompt progress reports, polling cancel requests and checking context._should_stop after every chunk. On disconnect, prefill halts within one chunk and cleans up cleanly across all ranks. Relates to jundot#3013.
Important
Stacked draft (4/4). Depends on #3155, #3256, and #3257. This is opened now so the full backend series is visible upstream. Until the dependencies merge, GitHub shows their inherited commits because the dependency branches live on the fork. This branch will be restacked after each merge so the final review is the 20-commit incremental serving/cancellation/telemetry/cache delta.
Incremental fork review and green CI: jonathan308/omlx#6.
Scope
Deliberately excluded
Validation
git diff --check: passed