mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1438] [CLOSED] perf(peer): add opt-in byte-capacity-aware expert placement #3454
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#3454
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/1438
Author: @agorevski
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:perf/capacity-aware-peer-placement📝 Commits (4)
0645ca3Add opt-in capacity-aware peer expert placement88a738ePreserve capacity-plan holdbacks and report actual residency1f7b830Keep retry sizing independent of retained peer ownershipb19c396Separate writeback reserve initialization from peer override📊 Changes
7 files changed (+479 additions, -16 deletions)
View changed files
📝
CMakeLists.txt(+4 -0)📝
docs/SECOND_GPU.md(+46 -1)📝
include/strata/core/peer_experts.hpp(+8 -0)➕
include/strata/core/peer_placement.hpp(+117 -0)📝
src/core/peer_experts.cpp(+37 -5)📝
src/program/generate.cpp(+118 -10)➕
tests/core/peer_placement_test.cpp(+149 -0)📄 Description
Title
Capacity-aware peer expert placement (opt-in)
Issue: Related to #1304 (multi-GPU prompt performance), #2052 (asymmetric-GPU recommendations), #765 (VRAM budgeting), and #831 (profile-limited residency). This PR does not claim to resolve those broader reports.
Summary
Add byte-capacity-aware primary/peer expert placement behind the exact opt-in
STRATA_PEER_CAPACITY_AWARE=1and explicit--peer-device N. Rebased ontoorigin/mainata0116b2782a5b82622358c04a06496485d12b2d6.Current local HEAD:
b19c396f84641fe3ee7d30c4e8aa1f234ee2667d.A large primary cache can swallow the experts moved behind the legacy
8,700-rank boundary. Unequal GPUs need independent aligned-byte budgets.
Reciprocal square-root profile rank is a heat proxy, not measured routing
frequency. No default placement or CPU-pool mode is changed.
What changed
capacities, peer slot limits, unique ownership, unprofiled tails and bounded
relocation.
residents, skips oversize pairs, deduplicates candidates and backfills dropped
primary pairs where peer room remains.
priced: reserve, owned prefill, still-unbound draft buffers and pipeline.
Previously the post-write check tested only reserve plus pipeline, a real
budget-consistency defect.
owned_prefill_mibremains upstream's existingcomposable calculation; no BF16 persistent-cache symbols or APIs are added.
Baseline writeback reserve initialization and the peer's complete-holdback
override are separate, so independent reserve changes can compose without
adding an already-priced owned cost twice.
without retaining a second ownership plan through allocation. Final
primary/peer/missed counts come from actual residency after
peer backfill, not allocated slot counts or the original plan. Pricing and
live-free correction diagnostics make the reason for a trim visible.
9,614/13,586/1,376, exact prefix alignment, repeated/zero trims, heterogeneous
slots, full holdback arithmetic and zero-free fallback.
requires a native pack, a profile, and a shared non-elastic cache with the
CPU pool; legacy HOT settings are ignored only when enabled.
Extra Notes
Contributor evidence, not new measurements
ruibeikaa's full Windows hardware report
tested pristine 0.1.40.3 plus the original PR, greedy 256-token requests, three
interleaved placement arms over six starts:
die and NVLink: +6.5% decode (77.0 to 72.4 ms/window), +17.5% prompt
(233 to 274 tok/s), equal outputs across all arms.
Planned 10,230/13,586/760 became actual 9,614/13,586/1,376.
Capacity-loss investigation and limitation
The original and rebased paths subtract the primary budget once.
open_sizedsums aligned slot bytes;ExpertCache::opendoes not subtract asecond reserve. The legacy repricing path is excluded by
!peer_capacity.Primary loss can occur only in allocation-failure retries or the post-write
live-free correction before filling. Its zero/near-zero-free fallback gives
back at least 1 GiB on the first two corrections, consistent with the report's
approximately 1 GiB loss, but the contributor comment does not include those
intervening log lines. A WDDM/live-free cause is therefore plausible, not
proved. The complete-holdback bug above would under-reserve, not establish
that the 616 pairs were unnecessarily lost.
Holdback timing was checked against upstream initialization: MTP weights,
private K/V, native head and main logits are already allocated before pricing;
MtpDrafter::bind_bytescounts only its still-null bind-time buffers.Between capacity-aware pricing and the primary writeback check there are no
draft binds, owned-prefill initializations, or pipeline allocations, only the
expert-cache allocation/retry path. Serve initializes
spand binds thesolo/batch drafters later; plain generate likewise initializes
prefillandbinds the drafter later. Thus these costs are genuinely still pending at
writeback. Pipeline windows are disabled when
--peer-deviceis active, sotheir composed cost is zero in this mode.
This update does not claim to recover those 616 pairs or prove the root
cause of the contributor's Windows capacity loss. Runtime allocation/free
logs from that pair are still needed. A real capacity correction must not be
disabled just to match the optimistic initial plan.
The proposed reply requests the same run's pricing, allocation-retry,
post-write correction, actual residency, and final WDDM free-memory lines.
This bounded code investigation and comment response are complete; the
missing Windows evidence is a stated measurement limitation, not a promise
of further code changes or recovered capacity.
Related-issue verification
Verified directly with
gh issue view N --json number,title,state,url,body:two RTX 2080 Ti 22 GB/NVLink, Flash-Next IQ3_S below 400 prompt tok/s.
Relevant performance context, not proof this placement solves that run.
GPUs: RTX 4080 16 GB plus RTX 3060 12 GB performs worse than the 4080
alone, even after trying expert-cache-only use. Relevant heterogeneous
context; no setup recommendation change or mixed-size validation here.
residency: asks for coherent mandatory-allocation pricing before expert
cache sizing at large context. The holdback correction is related, not a
unified-budget or auto-prefill solution.
--expert-cache N: documents partial-profile underfill and slot capacity
versus true residency. The opt-in cold tail and actual residency log are
relevant; this is already closed and the general legacy/per-layer policies
are not changed by this PR.
Validation
Working directory for every command:
All passed, GCC 13.3.0; CTest passed 1/1 selected test.
All passed. Generate emits the existing unused-variable
wwarning.Host checks use CUDA headers but do not link or execute the CUDA runtime.
A full GPU engine build was not run.
No model servers, GPU workloads, or two-GPU runtime tests were run. GPU use
is restricted to physical GPU 3; the pair remains untested. Windows runtime,
mixed-size hardware, actual GPU allocation/backfill, throughput and answer
parity of this rebased update are unverified. Windows/performance/answer
evidence above is contributor-only and applies to the original PR.
Original
1762e1f1is preserved onbackup/pr1438-1762e1f1-20261012. The original dirty checkout and installed engine were preserved.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
STRATA_MTP_Q8_SM60=1, opt-in) #4766STRATA_MMQ_WS=1, opt-in) #4767