mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4039] [Engine] opt-in smaller prompt scratch (STRATA_PF_GROUP_SCRATCH, STRATA_PF_HC_REGION): bigger --prefill auto chunks, bitwise, 8 GB cards +18-24% prompt #4885
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#4885
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/4039
Author: @merbanan
Created: 10/25/2026
Status: 🔄 Open
Base:
main← Head:pr/prefill-group-scratch📝 Commits (3)
b824998prefill: STRATA_PF_GROUP_SCRATCH=1, the MMQ path's GU / H / Hq hold one expert group's rows (opt-in, bitwise)37a7febprefill: STRATA_PF_HC_REGION=1, the hyper-connection read's scratch in the shared region (opt-in, bitwise)c4dd0afdocs: STRATA_PF_GROUP_SCRATCH and STRATA_PF_HC_REGION in DETAILS.md📊 Changes
2 files changed (+164 additions, -13 deletions)
View changed files
📝
docs/DETAILS.md(+6 -0)📝
src/prefill/prefill.cpp(+158 -13)📄 Description
Problem and result
A streamed prompt chunk sends every non-resident expert over PCIe once, so on a card where the experts don't fit, the chunk size sets how often an expert crosses the link per prompt token.
--prefill autocaps the chunk by the prompt path's buffers, which live in the cache slots it borrows. On an 8 GB card that cap is what limits prefill.Two of those buffers are larger than they need to be:
With both switches on,
--prefill autopicks a bigger chunk and prompts read faster; the answers are the same bytes.Approach
Both are opt-in and off by default:
STRATA_PF_GROUP_SCRATCH=1: GU / H / Hq hold one expert group's rows. The cap is T (one expert's most) plus three times a group's average; a group past it runs as sub-ranges of its experts, each with its own relative bounds appended to the bounds table. Only taken when every layer runs MMQ (no fused experts, no FP16 fallback); a layer that would take another path stops the prompt with a message instead of overrunning the smaller buffers.STRATA_PF_GROUP_CAP=<rows>forces a smaller cap (test knob).STRATA_PF_HC_REGION=1: the hyper-connection scratch is a fourth set of the shared region. A half's read is done with it before that half's set is written, and the fused write at a half's end runs after the half's last region reader on the same stream. Same kernels on the same values. Off with the unfused hyper-connection path.bytes_neededcounts the same carve, including GROUP_SCRATCH's larger bounds table. Documented in docs/DETAILS.md.Validation
Environment: RTX 2060 SUPER 8 GB (sm_75), Ryzen 9 3900X, 92 GB RAM, Linux 7.0, CUDA build with gcc-13 (
-DCMAKE_CUDA_ARCHITECTURES=75 -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_BUILD_TESTS=ON), Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS native pack,--kv k8v4 --spec 3 --mtp ... --expert-cache auto --prefill auto --max-context 131072. Baseline: main7dd5cf18, built and run the same way.Passed:
--prefill autochunk: 3840 -> 5888 tokensFailed: none observed.
Not run:
Limits
GROUP_SCRATCH only applies when every layer takes MMQ, so it is a no-op with the fused prompt experts. The gain is largest where the prompt chunk is VRAM-bound (8 GB cards streaming experts); on a card where the chunk is already large, expect little.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.