From ea5a867b30beffb8257b5a454534e5510ecd8148 Mon Sep 17 00:00:00 2001 From: Simba Zhang Date: Mon, 12 Oct 2026 04:21:14 -0700 Subject: [PATCH] fix: clamp --parallel to 1 with --stream-experts 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 --- Sources/SwiftLM/Server.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/SwiftLM/Server.swift b/Sources/SwiftLM/Server.swift index ba0e42f..e5b2138 100644 --- a/Sources/SwiftLM/Server.swift +++ b/Sources/SwiftLM/Server.swift @@ -684,6 +684,13 @@ struct MLXServer: AsyncParsableCommand { setenv("SWIFTLM_MTP_ENABLE", "1", 1) } + // SSD expert streaming keeps one persistent pread buffer set per layer, so + // concurrent requests overwrite each other's experts and corrupt the heap. + if self.streamExperts && self.parallel > 1 { + print("[SwiftLM] Warning: --stream-experts supports one request at a time; ignoring --parallel \(self.parallel) and using 1.") + self.parallel = 1 + } + if self.promptCacheEntries < 1 { print("[SwiftLM] Warning: --prompt-cache-entries must be at least 1, got \(self.promptCacheEntries). Using 1.") self.promptCacheEntries = 1