perf(cpp): autotune dual-socket dense models to interleave + all cores - #31
Jackson57279 wants to merge 2 commits into
Conversation
PR #29 async prefetch defaults to --numa single with half the threads on dual-socket boxes. Benchmarks on ai@192.168.1.132 show that dense models like Qwen2.5-32B-Q4_K_M (~18 GiB) decode ~68% faster when weights are interleaved across both sockets and all logical cores are used: --numa single --threads 48: 1.33 tok/s decode --numa interleave --threads 96: 2.26 tok/s decode --auto (after this change): 2.23 tok/s decode Changes: - plan_cpu() now picks interleave + all logical cores for dual-socket dense models > 4 GiB, while tiny models still stay single-node. - Add autotune_test coverage for the 32B-class dense dual-socket case. Also fixes a latent KV-cache indexing bug in forward_batched(): when the KV cache is capped at load time (e.g. 16384 vs advertised 32768), the batched prefill path was indexing with config_.context_size instead of the runtime kv_context_, causing out-of-bounds writes. This crash became visible once interleave + 96 threads exercised the capped-KV path.
…cket Picks up the anyhow 1.0.103 bump (RUSTSEC-2026-0190) and mmap-policy test rework from the base branches. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Triage note (maintainer pass): the +68% dual-socket decode result is compelling and the KV-cache OOB fix in Two things before this can merge:
Also note the interleave/all-cores autotune here overlaps #32's NUMA replication logic; worth reconciling so |
Review: what this is, how it works, what to stealWhat it is. A 3-file follow-on stacked on #29 ( How it works.
Do not steal the NUMA policy. Steal immediately (still a live bug on That 3-line fix is independent of #29 and of the autotune change. Cherry-pick it on its own; do not wait on this stack. Closing: stacked on an unmerged base, NUMA policy superseded, no activity since the 2026-07-09 “needs CI against master” note. |
Builds on #29.
PR #29 defaults dense dual-socket models to single-node with half the threads. Benchmarks on
ai@192.168.1.132show that models like Qwen2.5-32B-Q4_K_M (~18 GiB) decode ~68% faster when weights are interleaved across both sockets and all logical cores are used:--numa single --threads 48--numa interleave --threads 96--auto(after this change)Changes:
plan_cpu()now picksinterleave+ all logical cores for dual-socket dense models > 4 GiB; tiny models stay single-node.autotune_testcoverage for the 32B-class dense dual-socket case.forward_batched(): when KV cache is capped at load time, the batched prefill path was indexing withconfig_.context_sizeinstead of the runtimekv_context_, causing out-of-bounds writes. This crash became visible once interleave + 96 threads exercised the capped-KV path.Validation:
autotune_test,gguf_mmap_policy_test,prefetch_layer_map_testpass locally and onai@192.168.1.132.--autobenchmark on Qwen2.5-32B-Q4_K_M: decode 2.23 tok/s, prefill 6.17 tok/s.Summary by cubic
Autotunes dense dual-socket models to use NUMA interleaving and all logical cores for faster decode on 32B‑class models. Also pulls in base-branch maintenance, including an
anyhow1.0.103 bump and mmap-policy test updates.Performance
plan_cpu()now selects--numa interleaveand all logical cores for dual-socket dense models > 4 GiB; small models stay single-node.autotune_testfor a 32B-class dual-socket case;--autoon Qwen2.5‑32B‑Q4_K_M: 2.23 tok/s decode, 6.17 tok/s prefill.Bug Fixes
forward_batched(), index KV cache withkv_context_(notconfig_.context_size) to prevent OOB writes when the KV cache is capped.Written for commit 079f7cb. Summary will update on new commits.