mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #178] [CLOSED] Calibration: measure more CPU-lane threads than the engine's own (STRATA_GLM_CPU_LANE_MAX) #375
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#375
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/mw00/project-maya/pull/178
Author: @Jw88888
Created: 10/14/2026
Status: ❌ Closed
Base:
main← Head:calibrate-more-threads📝 Commits (2)
8feffa4Calibration: more CPU-lane threads than the engine's own are measured too - the engine runs with STRATA_GLM_CPU_LANE_MAX (a pool of the PC's CPUs, the engine's own count active, the rest asleep), so a request's cpu_threads can try up to the CPUs less two; upward only while each count beats the best so far. A KVM guest's 16 vCPUs have no SMT siblings and the engine takes two thirds of them: the calibration kept 10 before and keeps 14 now (Maya-L, one RTX 3090 Ti, --bench decode 14.9 -> 17.6 tok/s, #177)556ed79Calibration's higher thread counts: only up to the pool the engine reports (INFO cpu_threads_max) - a pool a split of 3+ GPUs shares, or DFlash2's two lanes, does not take STRATA_GLM_CPU_LANE_MAX, and a request above it ran the engine's own count again under the higher count's name; the bigger pool only on one GPU without SMT siblings. Workers left out by set_active wait on a condition of their own, outside sleeping_ - every batch's notify_all woke them to sleep again, which made the lower counts measure slower (32 vCPUs, 10 of a pool of 32 active: 19.4 -> 7.1 us a synthetic batch; a pool of its own count unchanged, 7.4 / 7.2). DFlash2's two-lane line names the active count (#178's review)📊 Changes
9 files changed (+198 additions, -31 deletions)
View changed files
📝
docs/SETTINGS.md(+4 -1)📝
include/strata/core/glm_model.hpp(+3 -1)📝
maya.py(+5 -5)📝
serve/server.py(+1 -1)📝
src/core/glm_fast_path.cu(+18 -3)📝
src/core/glm_fast_state.hpp(+27 -9)📝
src/program/generate.cpp(+5 -3)📝
tools/calibrate_glm.py(+58 -3)📝
tools/test_calibrate_glm.py(+77 -5)📄 Description
Follow-up to #177.
./maya.sh --calibrateonly measures fewer CPU-lane threads than the engine's own count: it lowers the active count of the pool the engine started with. So it cannot find a count above the engine's own. On a KVM guest with 16 vCPUs (no SMT siblings visible) the engine takes two thirds of them (10), and 14 decodes about 18% faster. The calibration kept 10. With this change it measures counts above too, and keeps 14.Two commits on v1.1.11: 1a1eb52 (the change) and 7847aba (the review's fixes: the reported pool size, the sleeping workers, one GPU without SMT, the DFlash2 log line).
The change
Engine:
STRATA_GLM_CPU_LANE_MAX=N(unset by default, so nothing changes without it).cpu_threadscan then go up to N without a restart.cpu_threadsreturns to the lane's own count (FastState::cpu_threads0), not to the whole pool, so the calibration's "engine's own" baseline stays the engine's own.cpu_threads0.cpu_threads_max(Glm5Model::cpu_lane_threads_max()), so a caller knows the most threads a request gets.Engine:
Workersthreads aboveactive()wait on a condition variable of their own (idle_cv_) that onlyset_activewakes (undermu_, so no wake-up is missed). They are not counted insleeping_. Before, every batch'snotify_allwoke them to sleep again, and their presence maderun()notify at all. The fewer threads active, the more of them there were, which slowed the lower counts the calibration measures. This also removes that cost from the existing downward sweep.tools/calibrate_glm.py:STRATA_GLM_CPU_LANE_MAXset to the CPUs the process may use (sched_getaffinity, at most 64). This applies only on one GPU and where no CPU'sthread_siblings_listnames a sibling (lane_max_env,smt_visible). With SMT the engine's own count is already a thread per physical core, and a split has a pool per GPU or a shared one.more_thread_candidates). It goes up to the pool the engine reports (cpu_threads_max) and never above it. Without that key (an older engine) there is no upward sweep.MIN_GAINas before.Tests: seven new cases in
tools/test_calibrate_glm.py. The fake engine now has a pool that capscpu_threadsasset_activedoes, and records the count that really ran.MAXis never asked for more. This is the review's case (22 shared threads,MAX64, one 1% high measurement and a winning 0.10 share); it fails on 1a1eb52 alone.cpu_threads_maxgets no upward sweep.lane_max_envandsmt_visibleon a fake sysfs.more_thread_candidates.Docs:
STRATA_GLM_CPU_LANE_MAXrow in the tuning table (docs/SETTINGS.md, where the README's table moved).docs/SETTINGS.mdandmaya.pysays "fewer and more" threads.strata_tunecomment.The engine's own choice of thread count is not changed.
The machine
--prefill auto,--kv-streaming on, the shipped expert profile, no vision. Every off-card expert fits in the RAM tier (0 disk reads a token).Before and after
16 vCPUs (first commit, on v1.1.7)
tools/calibrate_glm.pyon the installer's config (no"env"), main's tool and engine, then the first commit's:MIN_GAIN)PCIE_SHARE=0.10,CPU_LANE=14The first commit's lower counts here still carried the sleeping-worker cost the review found (10 threads: 14.6 against main's 15.1). 7847aba removes it (below). These 16-vCPU runs were not repeated after the guest moved to 32 vCPUs.
./maya.sh --bench: the installer's config against the same config with onlySTRATA_GLM_CPU_LANE=14, four runs alternating, a fresh engine each:32 vCPUs (both commits, on v1.1.11)
tools/calibrate_glm.py, same stock config, main's tool and engine, then this branch's:PCIE_SHARE=0.10,CPU_LANE=16PCIE_SHARE=0.10,CPU_LANE=26WorkersaloneWorkerscopied verbatim from main's header and this branch's into one program. The job is synthetic (about 4,000 multiply-adds),spin_us20000 as the engine uses, best of three alternating runs, 32 vCPUs:Checks
On the same Linux box, with the repository's CI commands, on this branch over v1.1.11:
tools/check_hip_compat.py: every CUDA name has a mapping (no new CUDA calls).python -m unittest discover -s serve -p "test_*.py" -t .: 189 tests OK (3 skipped).python -m unittest discover -s tools -p "test_*.py": 272 tests OK (27 skipped), against 265 on main.The engine was built for sm_86 only.
Output
Different thread counts can change which expert runs on the CPU or the GPU, so the last bits of an answer can change, as CONTRIBUTING says. With
STRATA_GLM_CPU_LANE_MAXunset, the lane's pool and its counts are as before. TheWorkerschange only affects threads aboveactive(), which a pool has only withMAXset or while the calibration's downward sweep runs.Not measured
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.