Repository navigation
fix(streaming): read non-expert weights before serving (GPU watchdog timeout on cold start) - #80
Merged
Merged
Conversation
…atchdog timeout on cold start 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.
Proposed changes
Possible fix for SharpAI/SwiftLM#216 (
--stream-expertsintermittently killed bykIOGPUCommandBufferCallbackErrorTimeout, correlated with a cold page cache).Mechanism (from reading the code, see the issue comment): with
--stream-expertsthe model is loaded withlazyLoad = true, so theelseofif !lazyLoad { materializeModelForInference }never reads any weights. Every non-expert weight stays an unevaluated safetensorsLoadnode.Loadruns on the CPU stream (preadonio::thread_pool), and a GPU op that consumes it gets an event wait encoded into its command buffer. On a cold page cache (or a slow external disk) the first forward pass can keep a command buffer waiting longer than the GPU watchdog allows.Change: for a streaming model, after loading, evaluate all parameters except the
SwitchLinearexpertweighttensors (placeholders paged from SSD on demand; evaluating them would allocate the full expert stack). Scales and biases are small and are read normally. New helpermaterializeNonExpertWeightsinLoad.swift; non-streaming loading is unchanged.Evidence / limits:
--stream-experts, after the page cache had been evicted: startup took 86 s (the preload read), then the first 213-token request completed (368 s, very cold experts) with no GPU timeout. Before the change a comparable cold start crashed (350 s). That is one run: the crash is probabilistic, so this is encouraging but not proof.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changesAI usage
accurately describes the code changes.
🤖 Generated with Claude Code