mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1436] [CLOSED] fix(serve): isolate CPU cores for independent Linux replicas #3456
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#3456
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/1436
Author: @agorevski
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:fix/independent-server-cpu-affinity📝 Commits (1)
ce54434Isolate physical CPU cores for independent Linux server replicas📊 Changes
5 files changed (+660 additions, -0 deletions)
View changed files
📝
.gitignore(+1 -0)📝
docs/DETAILS.md(+23 -0)➕
serve/cpu_affinity.py(+68 -0)➕
serve/test_cpu_affinity.py(+214 -0)➕
setup_multigpu.sh(+354 -0)📄 Description
Title
Issue: Not linked to an existing issue.
Isolate CPU cores for independent Linux server replicas
Summary
Status after the 2026-10-12 rebase: this PR remains closed and superseded. As the maintainer
explained, v0.1.42 adopted
the CPU allocator for the server's opt-in replicas mode. The branch is now rebased onto
a0116b2782a5b82622358c04a06496485d12b2d6; it preserves the upstream helper, which is no longera new file in this PR's diff. The remaining changes are the reference launcher, its tests and documentation.
This rebase does not reopen the PR or recommend replacing the supported upstream replica mode.
Independent one-GPU servers can select overlapping host and expert-worker cores. Reducing their worker counts alone does not prevent that contention. Give each selected replica a disjoint physical-core affinity mask, preserving allowed SMT siblings and the launcher's existing CPU restriction.
This PR adds the entire reference
setup_multigpu.shlauncher. It was a pre-existing, locally staged addition, absent from upstream based5ea7133; this is not just an affinity patch to a launcher already shipped upstream. The PR is independent of engine optimizations and does not include local configuration files or installed-engine changes.What changed
serve/cpu_affinity.py: group allowed CPUs by Linux sysfs physical-package/core IDs, then partition available physical cores fairly. Keep allowed SMT siblings together without adding CPUs outside the mask. A single instance without reservations retains the full allowed mask. Reserve entire physical cores occupied by running unselected managed server PIDs.setup_multigpu.sh(new executable): publish the full current root-relative reference launcher with its existing GPU selection, PID checks/restarts, API-key handling, 200 W power limit, health polling, and log streaming. Add per-servertasksetmasks, fail CPU allocation before stopping any servers when insufficient cores remain, and useflockto serialize allocation and spawning. Unselected managed servers remain running; children do not inherit the allocation lock.serve/test_cpu_affinity.py: 10 tests cover fair 18-core partitioning, restricted masks, socket/core IDs, reserved siblings, single-instance behavior, insufficient cores/missing topology, inherited server masks, concurrent-launch rejection, and unselected managed servers. Launcher fixtures mock GPU, power, network, and log-tail operations; they use this worktree for scratch files and stop fixture servers before removing them..gitignore: ignore the root.strata-multigpu.lockfile.docs/DETAILS.md: add the independent Linux server CPU-contention paragraph, reference-launcher prerequisites, measured core-selection example, and limitations.Extra Notes
Related issue: #1138 measures CPU contention on Windows through process/thread priority.
This Linux affinity work concerns the same contention class, but does not implement Windows priority
control and does not resolve that issue.
Scope and prerequisites
The CPU allocator is generalized to Linux physical-package/core topology; the launcher is deliberately not a general fleet manager. It retains the local four-NVIDIA-GPU IQ3_S replica conventions: GPU IDs 0-3, default selection of all four, ports 8080-8083, and existing root-level
strata-iq3_s_gpu0.jsonthroughstrata-iq3_s_gpu3.jsonfor whichever GPUs are selected. These model configuration files are not supplied by this PR. Users also need the configured models/engine, the root.venv/bin/pythonenvironment, Bash, Linux sysfs and process affinity support,taskset,flock,ss,curl,nvidia-smi, and the usual shell/log utilities.On each launcher startup, selected GPUs are set to 200 W, using
sudo nvidia-smiwhen not root. Hardware must support that limit, and permissions must allow it;sudomay prompt. No power-limit value was changed. Selected managed servers are stopped before the power-limit operation; a later power-limit failure prevents new server launches but does not restore stopped servers or already changed limits.The default binding is
0.0.0.0. Before any server binds, the launcher requires a non-empty, newline-free API key, taking it from--api-key,STRATA_API_KEY, the key file, or generating one, then always passing--api-keyto the server. The default key file is$HOME/.config/strata/api-key, overridable withSTRATA_API_KEY_FILE. Use--host 127.0.0.1for local-only access. No actual keys, local JSON configurations, logs, PID files,claude.sh, orlaunch.share included.Behavior on the next launcher startup
Existing servers are not modified by applying this PR. Affinity applies when the launcher next starts/restarts the selected instances. It excludes physical cores reserved by running unselected managed instances recorded in matching PID files; unrelated processes and unmanaged servers are not isolated by this mechanism. If insufficient free cores remain, allocation fails before stopping servers; restart the managed instances together or expand the launcher's allowed mask. The lock covers allocation and spawning, not the subsequent health-polling/log-streaming lifetime.
On an 18-physical-core, 36-thread Xeon W-2295, four selected servers receive 5/5/4/4 physical cores. A previously observed real single GPU-3 IQ3_S engine under mask
14,15,16,17,32,33,34,35selected host CPU 14 and worker CPUs 15-17; the SMT siblings 32-35 were also inherited. This observation is not a new fleet benchmark for this PR. A single selected server without reservations instead keeps the full allowed mask.The benefit is removal of overlapping physical-core affinity among managed replicas, not a claimed fleet-throughput improvement. Shared DRAM and memory-bandwidth contention remain.
Validation
Rebase validation on 2026-10-12, from the independent worktree:
/home/algore/GIT/strata/.venv/bin/python -m unittest serve.test_cpu_affinity— passed, 10 tests;bash -n setup_multigpu.sh— passed;git diff origin/main...HEAD --check— passed. No real launcher or GPU workload was run.Original pre-rebase validation:
Run from the independent
cpu-isolationworktree:/home/algore/GIT/strata/.venv/bin/python -m unittest serve.test_cpu_affinity— passed, 10 tests, no skips.bash -n setup_multigpu.sh— passed.git diff --check— passed.git diff --cached --check— passed.100755. No fixture scratch directories remained.GPU fleet not tested. The real launcher was not run; no GPU workload, real network/power operation, server restart, or power-limit change was performed. The original dirty checkout, source configuration files, and installed engines were left unchanged.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.