Repository navigation
Studio backend tests: pin the logical CPU count in the oversubscribed-threads spill test - #11120
Conversation
…-threads spill test test_oversubscribed_decode_threads_decline_spill_planning stubs os.sched_getaffinity to 16 CPUs to say "affinity is the whole machine", but _spilled_decode_threads takes the logical count from psutil.cpu_count(logical = True), which the test leaves real. On a host wider than 16 threads that 16-CPU affinity reads as a taskset, the function declines on the affinity arm, and the oversubscription the test is about is never reached: both halves come back None and the second assertion fails. Green iff the host has 16 or fewer logical CPUs, which is why it has survived since #9863 on 2026-08-29 -- GitHub-hosted runners are 2 to 4 vCPU and never show it. It reproduces on any wide self-hosted runner; measured on a 192-thread host. taskset does not reproduce it, because psutil.cpu_count ignores affinity and still reports the whole machine. Stub psutil as well. _SmtHost is already defined at module scope as the 16 logical / 8 physical host this test assumed, and the two affinity tests directly above it pin psutil the same way for the same reason, so this is the established pattern in the file rather than a new one. The assertions are unchanged and both still bite. Dropping the `if actual > physical: return None` arm turns the first one red; making the in-budget arm return None turns the second one red.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Merged current main in. All eight failing checks here were inherited from main rather than caused by this PR: they ran on 2026-09-16 16:32, before the repairs landed, and every failing test is one that has since been fixed on main.
Verified locally against the merge: the six suites that were red now give 417 passed, 2 skipped. The merge also absorbs the
|
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…-threads spill test (unslothai#11120) * Studio backend tests: pin the logical CPU count in the oversubscribed-threads spill test test_oversubscribed_decode_threads_decline_spill_planning stubs os.sched_getaffinity to 16 CPUs to say "affinity is the whole machine", but _spilled_decode_threads takes the logical count from psutil.cpu_count(logical = True), which the test leaves real. On a host wider than 16 threads that 16-CPU affinity reads as a taskset, the function declines on the affinity arm, and the oversubscription the test is about is never reached: both halves come back None and the second assertion fails. Green iff the host has 16 or fewer logical CPUs, which is why it has survived since unslothai#9863 on 2026-08-29 -- GitHub-hosted runners are 2 to 4 vCPU and never show it. It reproduces on any wide self-hosted runner; measured on a 192-thread host. taskset does not reproduce it, because psutil.cpu_count ignores affinity and still reports the whole machine. Stub psutil as well. _SmtHost is already defined at module scope as the 16 logical / 8 physical host this test assumed, and the two affinity tests directly above it pin psutil the same way for the same reason, so this is the established pattern in the file rather than a new one. The assertions are unchanged and both still bite. Dropping the `if actual > physical: return None` arm turns the first one red; making the in-budget arm return None turns the second one red. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
test_oversubscribed_decode_threads_decline_spill_planningfails on any host with more than 16 logical CPUs. It is not flaky. The dependency is exact.The dependency
The test stubs
os.sched_getaffinityto return 16 CPUs, meaning "affinity is the whole machine, nothing is restricted". But_spilled_decode_threadstakes the logical count frompsutil.cpu_count(logical = True), which the test leaves real:On a wider host,
affinity_count = 16against a reallogicalof 32 or 192 reads as a taskset, so the function declines on the affinity arm and the oversubscription the test exists to check is never reached. Both calls come backNone, and the second assertion fails withassert (None is not None).Measured against a stubbed host width, everything else in the test held fixed:
Green iff the host has 16 or fewer logical CPUs.
Two things worth knowing before anyone tries to reproduce it:
tasksetdoes not reproduce it.psutil.cpu_countignores affinity and reports the whole machine, sotaskset -c 0-3leaveslogicalat its real value and the test still fails.mainatcf335fa47, on a 192-thread host.The fix
Stub
psutilas well, so the 16-CPU affinity reads as unrestricted the way the test intends._SmtHostis already defined at module scope as exactly the 16 logical / 8 physical host this test assumed, and the two affinity tests immediately above it pinpsutilthe same way for the same reason, so this follows the file's existing pattern rather than introducing one.One line plus a comment. No product code changes. The product is correct here: declining to price a spill under a restricted affinity is a deliberate abstain that hands placement back to llama.cpp, and the test was reporting the right thing for the wrong reason.
Can it still fail
The assertions are untouched and both arms still bite.
if actual > physical: return Nonearm from_spilled_decode_threadsturns the first assertion red:_plan(...)returns aPlanwhereNonewas required.Noneinstead ofmax(1, actual)turns the second assertion red:assert (None is not None).studio/backend/tests/test_offload_planner_seam.pyis 157 passed locally,ruff checkclean.