Skip to content

prefill: bytes_needed sizes the MoE buffers for the layout init picks (with or without an expert source) - #1283

Closed
sergqwer wants to merge 1 commit into
Niko1221:mainfrom
sergqwer:pr/prefill-bytes-needed
Closed

sergqwer wants to merge 1 commit into
Niko1221:mainfrom
sergqwer:pr/prefill-bytes-needed

Conversation

@sergqwer

@sergqwer sergqwer commented Oct 7, 2026

Copy link
Copy Markdown

Replaces #1042, which GitHub closed when main's history was rewritten. The closing note says this was not a rejection. It is the same commit, cherry-picked onto the new main (v0.1.40.1).


Prefill::bytes_needed() sizes the region the prompt path borrows from the expert cache. It must count exactly what carve() allocates. 0.1.39 took the first part of #547 with #583 (the xn / grs count). This is what is left.

The MoE layout. bytes_needed sizes the MoE scratch with fused_layout(T, true) for every caller. carve takes the fused layout only when init gets an ExpertSource (fused_layout(T, m.src != nullptr)). So a prompt path without one is lent the fused layout's smaller MoE buffers, and its unfused buffers do not fit in them.

The change. bytes_needed_impl takes a src flag. So do bytes_needed, bytes_needed_no_ring and 0.1.40's bytes_needed_owned (#796), all defaulting to true. Every caller in generate.cpp passes srcp != nullptr, the same source it hands init. That includes STRATA_OWNED_PRICE=exact's sizing.

Identity. With an ExpertSource (every normal run) nothing changes. The logits and the 32 greedy tokens after a 32K prompt equal v0.1.40 on IQ2_XS: identical bytes, same expert cache. The engine's sources here are the same bytes as on that branch, because 0.1.40.1 changed only the server and setup.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio

… (with or without an expert source)

0.1.39 took this PR's first part with Niko1221#583 (the xn / grs count, STRATA_RING_BYTES). What is left: bytes_needed
counted the fused layout's smaller MoE buffers for every caller (fused_layout(T, true)), while init takes them only
when it gets an ExpertSource (fused_layout(T, m.src != nullptr)). A prompt path without one was lent fewer bytes than
its unfused buffers take. bytes_needed, bytes_needed_no_ring and (0.1.40) bytes_needed_owned - STRATA_OWNED_PRICE=exact's
sizing - now take the same `src` the callers pass to init.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio
@sergqwer

sergqwer commented Oct 7, 2026

Copy link
Copy Markdown
Author

Rebased onto e8ca9af (v0.1.40.2). The only conflict was the new cpu_pool_ member next to bytes_needed_impl's declaration; the callers 0.1.40.2 added (the layer split's stage pricing, the reserve's minimum slots) keep the default src = true, which is what they computed before.

Default identity against v0.1.40.2 on IQ2_XS (--expert-cache 12000, first-token logits and 32 greedy tokens):

prompt v0.1.40.2 this PR
2K logits 64b3666efb, tokens c0e83a232a logits 64b3666efb, tokens c0e83a232a
32K logits e2d48a1269, tokens 36abf09521 logits e2d48a1269, tokens 36abf09521

@sergqwer
sergqwer force-pushed the pr/prefill-bytes-needed branch from ac45e87 to e7635b6 Compare October 7, 2026 14:43
fragtion pushed a commit to fragtion/StrataPool that referenced this pull request Oct 7, 2026
…uffers for the layout init picks (with or without an expert source)

prefill: bytes_needed sizes the MoE buffers for the layout init picks (with or without an expert source)

0.1.39 took this PR's first part with Niko1221#583 (the xn / grs count, STRATA_RING_BYTES). What is left: bytes_needed
counted the fused layout's smaller MoE buffers for every caller (fused_layout(T, true)), while init takes them only
when it gets an ExpertSource (fused_layout(T, m.src != nullptr)). A prompt path without one was lent fewer bytes than
its unfused buffers take. bytes_needed, bytes_needed_no_ring and (0.1.40) bytes_needed_owned - STRATA_OWNED_PRICE=exact's
sizing - now take the same `src` the callers pass to init.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157fjixQD2nRxvCvtXq66DD
@sergqwer

Copy link
Copy Markdown
Author

Thank you for taking this in 0.1.42 (a26fcbc, the same change). Closing.

@sergqwer sergqwer closed this Oct 10, 2026
fragtion added a commit to fragtion/StrataPool that referenced this pull request Oct 12, 2026
…-support

Upstream now carries these of our picks, in its own versions: Niko1221#1237 (pinned stage buffers, now with fences and
the STRATA_STAGE_PIN switch), Niko1221#1332, Niko1221#1359, Niko1221#1372, Niko1221#1370, Niko1221#1251, Niko1221#1190 and Niko1221#1283.

CPU help for short prompts: Strata's own CPU prefill share (0.1.41: on by default below 1,024 tokens on one NVIDIA
GPU; -20..-34% prompt time at 512-1,000 tokens on an RTX 3060 in upstream's measurement) replaces architectds' CPU
assist, which measured +11% at ~560 tokens on our desktop.  prefill.cpp is upstream's, with the pool's hooks
(remote_next to the workers, a headless worker stage) and Niko1221#1368's quantize-once put back.  A pool PC runs its own
layers alone (no local stages), so the share's default applies on every PC.

Pipelined decode: upstream's N-stage loop (front stages + the last) with the pool's remote stage as the last
(pl_remote via stage_ver_p, pl_ns = 2 on a pool coordinator), and architectds' verified-path-first yield, the
lookup carried across windows and the pool head's penalty rows ported onto it.

Batch: upstream's batch_step (the adaptive tier in batch windows, per-stage timing, Niko1221#879 non-finite logits) with
Niko1221#1290's per-slot row width and the pool head's slot histories; the pool's batch groups keep their PoolLink stage.

Also: the conversation cache's eviction keeps both the pool-borrowed entry and pinned prefixes (evict_oldest);
the verifier's adaptive-tier gate (STRATA_ADAPT_OVERLAP) also guards the overlapped split's prelaunch (Niko1221#1120);
the server's read-once body takes upstream's size limit; replicas and the pool roles both start engines;
serve/pool.py keeps the engine's newer spawn tuple; the worker's parking reads available_host_bytes(); setup
tests that need a ready-made engine are skipped (StrataPool compiles its own).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157fjixQD2nRxvCvtXq66DD
DarthCY-K pushed a commit to DarthCY-K/Strata that referenced this pull request Oct 20, 2026
…ured PCIe share, Niko1221#1690 Niko1221#1693 Niko1221#1696 Niko1221#1283 as upstream's code) - README, docs/NVFP4.md and the bundle version

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant