Repository navigation
fix: clamp --parallel to 1 with --stream-experts - #231
Merged
Merged
Conversation
SSD expert streaming keeps one persistent pread buffer set per layer; concurrent requests overwrote each other's experts and corrupted the heap (OLMoE, --parallel 3: 12/18 failures, garbled output, crash). Warn and use 1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--parallel N>1with--stream-expertscorrupts the heap and garbles output.Repro (OLMoE-1B-7B-0125-Instruct-4bit, 6 concurrent chat requests x 3 rounds, half streaming, temperature 0):
--parallel 3 --stream-experts: 12/18 requests failed, streamed text interleaved across requests, then the server crashed (EXC_BREAKPOINT inside libsystem_malloc freelist, called fromrms_normon the generation queue).--parallel 3without--stream-experts: 18/18 ok, server alive.Cause: the SSD streaming fast path in
SwitchGLU(mlx-swift-lmSwitchLayers.swift) keeps one persistent pread buffer set per layer (_persistentGate/_persistentUp/_persistentDown) plus last-token routing prediction state. Concurrent requests pread into the same buffers and mutate the same graph state. The design is single-request.Fix: with
--stream-experts, print a warning and forceparallel = 1. Requests queue instead of running concurrently. Per-request buffers would be the real fix for concurrency, but that is a larger change.Verified after the fix: same stress, 18/18 ok, server alive. No unit test: the clamp lives in
run(), so the stress run is the check.Needs the OLMoE tokenizer support from #230 to repro with that model; the clamp itself is independent.
🤖 Generated with Claude Code