Repository navigation
Conversation
…ead on one CPU strata-poly leaves its CPU expert threads to the scheduler on Linux. --pin-workers (or STRATA_POLY_PIN_WORKERS) pins each worker thread to one CPU: `auto` puts one thread on every performance core but the first (where the calling thread runs), then the efficiency cores (/sys/devices/cpu_atom/cpus), then the cores' second hardware threads; a list such as 2,4,6-9 pins them in that order. It reads the process's own affinity mask, so it stays within the NUMA node the engine already binds to. Default off: nothing changes unless it is set. Not on Windows (logs that the threads are not pinned). Qwen4-35B-A3B UD-IQ4_XS, RTX 4060 Laptop + i9-12900H, --kv q8_0, 300 tokens, interleaved, 5 rounds each: balance_performance EPP (default): unpinned 80.85 +- 3.68, auto 80.24 +- 1.03 tok/s performance EPP: unpinned 77.31 +- 3.61, auto 75.90 +- 3.01 tok/s Not faster; less run-to-run spread with the default power setting only. workers_test: CPU list parsing, the order for a hybrid Intel and an AMD-like layout, and pinning a real pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018j62UGHq9crCFFy7fHrCcW
Collaborator
|
Integrated on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
On Linux strata-poly leaves its CPU expert threads to the scheduler (only the NUMA binding of
stay_near()narrows where they may run). On a hybrid CPU the scheduler moves them between performance cores, efficiency cores and the second hardware threads of busy cores, and a user has no way to choose.--pin-workers(orSTRATA_POLY_PIN_WORKERS) pins each worker thread to one CPU, either by a CPU list or byauto.It is not faster. Qwen4-35B-A3B UD-IQ4_XS on an RTX 4060 Laptop with an i9-12900H,
--kv q8_0, 300 tokens, the arms interleaved, 5 rounds each:--pin-workers autobalance_performance(the default)performanceWith the default power setting the speed varied less from run to run (an earlier 5-round pair, with pinning through an experiment build, gave the same picture: 79.00 ± 6.61 against 78.73 ± 1.11); with
performanceit did not, and both arms were slower on this laptop. The option is for users who want to choose where the threads run (keep cores free for other programs, benchmark with less spread, try layouts), not a speed-up.Related discussion
none (no issue).
Approach
Workers::pin(cpus): worker thread i goes tocpus[i % n](pthread_setaffinity_np); the calling thread, which does a share of the work, is left alone. Returns the number pinned; 0 on other systems.auto=worker_cpu_order(cpu_slots()):cpu_slots()reads the process's affinity mask (so it stays within the NUMA nodestay_near()chose),/sys/devices/cpu_atom/cpus(a hybrid Intel CPU's efficiency cores) and each CPU'score_id/physical_package_id. The order: the first hardware thread of every performance core but the first (where the calling thread usually runs), then the efficiency cores, then the second hardware threads, then the first core's. On the i9-12900H, 13 workers: CPUs 2,4,6,8,10,12-19.2,4,6-9pins in that order; a bad list (3-1,2,,4,x) stops the load with a clear error.offor empty: nothing.terminal/data/settings-register.json(opt-in),docs/SETTINGS.mdregenerated, a row in the options table ofdocs/GLM.md.SetThreadAffinityMask/ CPU sets), a different kernel per core type.Validation
Revision
b490766d4(the engine runs on the same code before the docs row was reworded). Linux, i9-12900H (6 P-cores with two threads each, 8 E-cores), RTX 4060 Laptop 8 GB, CUDA 13.4 build container; Qwen4-35B-A3B UD-IQ4_XS (Unsloth).Passed:
poly_workers_test(built with-DSTRATA_BUILD_TESTS=ON): CPU list parsing (good and bad lists), theautoorder for a hybrid Intel layout and an AMD-like one without efficiency cores, an empty layout, and pinning a real 8-thread pool (7 pinned); 4,000 checks passed.--pin-workers autologs "13 CPU threads pinned to CPUs 2,4,6,8,10,12,13,14,15,16,17,18,19"; a bad list stops with the error; the decode numbers above.python3 tools/settings_register.py --checkandpython3 -m unittest tools.test_settings_register: OK.Failed:
autoputs the second threads after the efficiency cores.Not run:
Limits
🤖 Generated with Claude Code