Repository navigation
[mirror] unslothai/llama.cpp#345: MoE cache seeds a long first prompt chunk from the last prompt's routing - #9
Draft
LeoBorcherding wants to merge 2 commits into
Conversation
…t's routing With experts in host memory and the MoE cache, the last large ubatch of each llama_decode call seeds the cache. When that ubatch had no earlier routing in the prompt (the first server chunk, or a whole prompt in one chunk) it read its own ids first, so its expert uploads ran on the compute stream after a per-layer readback instead of ahead on the prefetch copy queue. Keep the routing counts across prompts. A long seeding ubatch with no routing of its own now copies all experts ahead like any other large ubatch and seeds from the last prompt's routing. Later chunks of the same prompt still seed from the prompt's own routing. A small ubatch with outputs (the server's last prompt tokens) also reads the routing of the large ubatch before it, so the fallback follows the last prompt. Short chunks keep the routed-only copy: they leave many experts unrouted and have little compute to hide the copies under.
…cache ggml_backend_cuda_copy_regions_async returned false on HIP, so the prefetch copy of a large ubatch could only take long runs of cached experts from the MoE cache and uploaded the rest from host memory again. With the cache seeded from the last prompt that was every expert of every layer: 23.5 GB per 4.58k-token prompt on an R9700 at ub 8192, 16 GB of it already in VRAM. On HIP the device copies now go through the copy-regions kernel and the uploads are one hipMemcpyAsync each (there is no batched copy API), so a cached expert is copied from the cache and only the misses are uploaded.
Owner
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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.
Mirror of unslothai#345 at
153050ec5on its base (unslothai#268 headfd7489efb), for Codex review. Do not merge.