Repository navigation
Conversation
Rebased onto main: the finer auto sizes (every 1024 above 8192) are superseded by Niko1221#583's bisection, which already finds the largest chunk that fits. What remains is the equal-chunk split: n = ceil(tokens / max_chunk) chunks of ceil(tokens / n), rounded to 256, so a prompt never pays an extra streaming pass for a tail of 1024+ tokens and borrows no more cache slots than that count needs. Full chunks plus a short last one stay when the tail is under stream_all_min(): it moves only the experts its own tokens route to (16,402 in 3 equal chunks read 22% slower than 2 x 8,192 + 18). bench/results/2026-10-03-prompt-chunks: the original v0.1.38 A/B that motivated this (its finer-sizes column is now Niko1221#583's job).
Contributor
Author
|
Closing as superseded: Niko shipped the equal-chunk idea in 0.1.40 as Happy to post a 5070 Ti row for |
This was referenced Oct 6, 2026
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.
Rebased variant of @architectds's equal-chunk idea from #693 — the idea and the original data are theirs; the
auto:16384sweep part of the original is superseded by #583's bisection, so this keeps only the chunk-splitting change. q8atnight asked for a fresh PR against main before adding a 3090 row (#693), so here it is.What this does
request_chunkcurrently returnsmax_chunkfor every full chunk and lets the tail be whatever is left. This splits a segment into equal chunks instead:n = ceil(tokens / max_chunk)chunks ofceil(tokens / n), rounded to 256 — with one exception kept from the current behavior: when the last piece would fall belowPrefill::stream_all_min_tokens(), full chunks + short tail stay, because a sub-threshold tail moves only the experts its own tokens route to, while equal chunks would all stream every expert (measured: 16,402 tokens in 3 equal chunks read 22% slower than 2 × 8,192 + 18).The cost model is the streaming threshold: a chunk at or above
stream_all_min_tokens()streams every expert the GPU does not hold (~1.7 s each on PCIe 3.0, whatever its length), so a long prompt's cost is its number of such chunks — a bigger chunk pays only where it saves one, and equal chunks borrow no more slots than that count needs.Measured (RTX 5070 Ti 16 GB, Windows, IQ3_S,
--prefill auto:32768, engine built frommainat6f32ec0)Two binaries — stock main (
97E3A38E…) and this patch (4088639E…), same toolchain, same base commit. ABBA swap-boot legs (cross-boot variance here is ~5%, single boots prove nothing), 3 greedy probes per leg, steady-state runs averaged:The 40K row is a built-in null control: bisection's tail rule keeps the layout identical there, so its +1.1% is pure build-pair drift — call the real gain ≈ +3% at 22.6K, marginal at 26.6K, zero where the layout doesn't change. Consistent with the original 5070 Ti claim (+2.2% at 20,036).
bench/results/2026-10-03-prompt-chunks/carries the raw ABBA JSON and needle probes.For @q8atnight
--prefill 6144this never fires (the rule only re-splits totals above the threshold), so nothing changes there.Honest caveat: not bit-identical
Different chunk boundaries shift accumulation order, so a fixed prompt's greedy continuation differs between builds (both coherent, needles retrieve). Anything asserting exact tokens across prefill layouts will need updating — per your gate rule this needs a fresh long-gate reference before adoption, which is exactly what we're not claiming here.
Safety on constrained boxes
This never raises a chunk above what bisection picked — it only splits an already-chosen total into equal pieces (22,588: 20,224+2,364 → 11,520+11,068). On layer-split / low-RAM boxes the chunks get smaller, not bigger.