Skip to content

fix(cpu-moe): size the CPU pool to the cgroup CPU quota - #931

Draft
RaunakGengiti2725 wants to merge 1 commit into
FlashML-org:mainfrom
RaunakGengiti2725:pr/cpu-quota-pool
Draft

RaunakGengiti2725 wants to merge 1 commit into
FlashML-org:mainfrom
RaunakGengiti2725:pr/cpu-quota-pool

Conversation

@RaunakGengiti2725

@RaunakGengiti2725 RaunakGengiti2725 commented Nov 20, 2026 •

Copy link
Copy Markdown

Fixes #938.

With --moe-cpu-threads unset, the spinning pool took every physical core, even under a smaller container CPU quota, so hybrid decode ran 5x slower. It now takes at most floor(quota) - 3 cores (coordinator included), the quota being the smallest cpu.max of the cgroup and its parents (v1 as fallback), and logs the cap. With an explicit count or no quota the pool is unchanged; the torch intra-op thread clamp counts the quota even with an explicit count (no unit test).

A/B against main 2fb371e. GPU RTX 5090 (575 W), CPU EPYC 9354, driver 615.71.09, checkpoint nvidia/Qwen3.6-35B-A3B-NVFP4, cpu.max 15.36 CPUs of 128 visible. Both arms, same FREETOKEN_BENCHBW_PATH: ft serve --model nvidia/Qwen3.6-35B-A3B-NVFP4 --enable-timings-report --moe-strategy hybrid --moe-cache-rate 0.2 --max-running-requests 1, --moe-cpu-threads unset.

main tok/s, math / code this PR tok/s, math / code workers, main / PR
round 1 32.7 / 32.4 160.5 / 183.5 63 / 11
round 2 29.6 / 36.6 155.8 / 178.3 63 / 11
mean 31.2 / 34.5 158.2 / 180.9 63 / 11

Server timings; 2 passes, 256 warm-up, 512 timed tokens, 2 rounds reversed. The branch logged CPU MoE pool: 12 of 64 physical cores, to fit the cgroup CPU quota of 15.36 CPUs.

Tests (10 CPU-only cases in tests/moe/test_cpu_moe_fp8_block.py, run on a Mac) fail if the pool stops leaving 3 CPUs, takes the nearest quota, lets a max level end the walk, loses the v1 fallback, or caps an explicit count. Removing reps = reps[:fit] fails 4.

Tested on real hardware by me.

With an automatic thread count the spinning pool took one thread per physical
core, even in a container whose CPU quota is below that. It now takes at most
floor(quota) - 3, where the quota is the smallest cpu.max of the process's cgroup
and its parents (cgroup v1 files as a fallback). With an explicit
--moe-cpu-threads, or a cgroup without a quota, the pool size is unchanged; the
torch intra-op thread clamp counts the quota in both the automatic and the
explicit case. The 3 is measured on two machines: 2.08 CPUs left beside the pool
was throttled, 2.44 and 3.08 were not.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CPU MoE pool ignores the cgroup CPU quota, so hybrid decode runs 5x slower in containers

1 participant