mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #269] [CLOSED] Split prefill: run the whole prompt on the main GPU (--prefill-main) #2536
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2536
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/269
Author: @mijkathegreat
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:prefill-main-split📝 Commits (2)
c64ff6fSplit prefill: run the whole prompt on the main GPU (--prefill-main)1cce9b4Order a split's GPUs by PCIe link: the widest link is CUDA0📊 Changes
4 files changed (+231 additions, -9 deletions)
View changed files
📝
include/strata/core/session.hpp(+7 -0)📝
serve/server.py(+32 -2)📝
src/core/session.cpp(+118 -0)📝
src/program/generate.cpp(+74 -7)📄 Description
One GPU outruns the split on prefill
Same rig, same model (IQ3_XXS), same calibrated config, greedy, fresh process per run:
Test rig: 2× RTX 5090 Laptop — one internal on PCIe 5.0 x8 (26.7 GB/s measured to the pinned host arena), one in a TB5 enclosure (Gen4 x4, 5.3 GB/s); 64 GB RAM, Windows 11 / WDDM. Prompts of 15.5k–20k tokens.
Why the split loses to one card
The batched prompt path is bound by streaming expert misses from the host arena, not by compute — one GPU already finishes an 8192-token chunk faster than its misses can be delivered. A layer split does not split that stream; it adds obstacles:
So the second GPU does not add bandwidth where prefill needs it — it adds a slow link and takes away the pin.
This PR: prefill everything on the main GPU
Same binary, same config —
STRATA_PREFILL_MAIN=1(+STRATA_PIN_LIMIT_GIB=20) vs off:Up to +54% prefill over the stock split, decode unchanged or slightly better (the second card's VRAM goes to its expert cache instead of prompt-path buffers). Output verified clean: byte-identical greedy continuations on short prompts, correct long-prompt answers, decode cache hit 98.9%, no non-finite values under
STRATA_DBG_NAN.The remaining gap to single-GPU (1520 vs 1704) is not the prompt path itself — that is now literally the single-GPU path — but the memory system around having a second context: the Windows registration budget tops out at ~20–22 GiB with two contexts (single-GPU mode pins the whole ~39 GiB arena, and past the ceiling registrations fail and poison the contexts); the main cache's profile covers only its own layers
[0, K), so the later layers stream cold during the prompt; plus the hand-off copy per segment.Principles of the solution
sp.set_stage(0, -1, nullptr)); the stages skip their prompt-path init and keep that VRAM for their caches. Decode stays stock-split — only the prompt path moves.session_copy_layers()copies layers[K, n_layers)of the session — GDN rows, whole QSA carve blocks, and the streamed KV host pools — withcudaMemcpyPeerhops. A plain two-step pinned staging copy silently lands nothing across Thunderbolt on WDDM (destination reads back as zeros after a "successful" copy), so the driver-owned peer path is used directly.host_resarray. During the batched prompt those ids are masked out inhost_resitself, and a per-request snapshot restores the true table before the verify windows. A stale copy of the table once made the prompt path read its lent workspace as expert weights — NaN from the first QSA layer onward; that is the bug class this guards against.STRATA_PIN_LIMIT_GIBraises the Windows multi-GPU registration cap. 20 GiB is measured safe on 64 GB RAM; 22 is the ceiling — above it, registrations fail and poison the contexts.Both changes are off by default: without the environment variable the binary is byte-for-byte stock behavior.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.