mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #501] [CLOSED] verify: pin the serve host thread the session loop already pins #2668
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#2668
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/501
Author: @yannickloth
Created: 10/2/2026
Status: ❌ Closed
Base:
main← Head:perf/verify-host-pin📝 Commits (1)
c6e5d7averify: pin the serve host thread the session loop already pins📊 Changes
4 files changed (+97 additions, -0 deletions)
View changed files
📝
CMakeLists.txt(+8 -0)📝
include/strata/core/verify.hpp(+15 -0)📝
src/core/verify.cpp(+44 -0)➕
tests/core/verify_host_pin_test.cpp(+30 -0)📄 Description
Pin the serve/spec host thread the way the session loop already pins its host.
What this targets
SessionLoopScratch::initpins the host thread to the coreExpertPoolreserves(
physical_cores(false)[0]; workers come fromphysical_cores(true)), because the hostjoins the pool drain with the default
host_works(generate.cpp:2637) - the startuplog's "8 expert-pool workers + the host thread".
Verifier::run(verify.cpp) spins onthe doorbell and then calls the same pool, but never pinned, so its host was free to land
on a worker's core or SMT sibling. See #494: the CPU pool is 53% of a fresh round / 26%
warm, and the host is one of the ~9 draining threads.
Measured first (#494): no collision on this host
On production 0.1.35 there is no collision to fix:
SessionLoopScratch::initis calledunconditionally in
main()(generate.cpp:3607) before the serve/verifier block(
:4200), so the serve host is already on the reserved core. During an active servedecode the only busy non-worker thread is the engine main thread, with
Cpus_allowed_list: 0, and the 8 workers on2,4,6,8,10,12,14,16; 120 x 50 ms samplesgive exactly nine busy threads, the host on core 0 in every sample.
The fix
Verifiernow carries the same pin/restore asSessionLoopScratch:host_pin_core(split): the first physical corephysical_cores(true)drops (never aworker's), or -1 under a layer split / when no such core exists.
maybe_pin_host()once at the top ofrun(), before the spin:STRATA_NO_VERIFY_PINis the off arm; refuses when the calling thread's affinity does not include the core;
pins once and records the previous mask and thread id.
serialize.
No numerics change, no token-loop change, no pool worker-count or affinity change.
A/B (same binary,
STRATA_NO_VERIFY_PIN)Local
build/strata,bench/e2e.sh, fixed prompt,max_tokens 200, interleaved, 6runs per arm, alternating order:
Mean delta -0.3%, median -5.1%: not the >3% win
tools/calibrate.pyrequires(the host is noisy, +/-20%). This is a robustness fix, ~0 perf: it makes the
reservation local to the verifier instead of depending on the session scratch that
happens to run first.
Evidence
and the workers on 2..16;
/proc/<pid>/task/*/statusconfirms.verify_host_pin_test,pool_test,pool_stress,expert_parity,file_expert_source_test,expert_layout_test,expert_cache_per_layer_testand 10CPU/GPU parity tests pass.
expert_multi_testfails its pre-existing no-AVX-512refusal (this host has AVX2 + AVX-VNNI).
verify_host_pin_testasserts the chosen core is not a worker core, and that a layersplit returns -1.
Caveat
This is a single-GPU host, so the layer-split guard is verified by inspection and by the
unit test, not by running a multi-GPU split.
maybe_pin_hostskips whenevernext_ != nullptr || lb_ > 0 || le_ < g.n_layers, i.e. every stage.Refs #494, #489, #485.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.