Skip to content

Per-model CPU thread pools and RAM optimization

Choose a tag to compare

@mgorshkov mgorshkov released this 20 Nov 13:26
· 44 commits to main since this release
CPU pools: each Model owns its ThreadPool; forward() binds it for the calling
thread, workers resolve current() to their own owner, and the process-wide
instance() remains the fallback for callers that never bind.

RAM: the host-side LM-head embedding table is now built only in the form the
dispatch actually selects -- Q8_K when the source type has a Q8_K dot kernel,
FP16 otherwise (PQ2_0, BF16) -- and the Q8_K table is built row by row from the
quantized source instead of dequantizing the whole matrix into F32 first.  For
a 248320 x 5120 vocab the old code kept F32 (5.1 GB) + FP16 (2.5 GB) + Q8_K
(1.3 GB) resident for the life of the process although at most one is ever
read; F32/FP16 are now opt-in via TINYCODER_EMB_TABLE=f32|f16|all.  The
row-streamed Q8_K build is asserted byte-identical to the whole-matrix build by
unit_tests/EmbeddingTableTest.cpp.

Halved the core build's warning count to zero on the way (unused kqsx,
L, gemmPrefill, profSlot, int8S8Supported, nWords, mask, sw, sh0, startBit, c
and a stale kt0; the Q3_K GEMV launch bound was 64*NW x 8 = 2048 > 1024
threads/SM, so ptxas dropped the occupancy hint -- it now names the block size
the launches use, 32*NW; kResidualNormQ81 no longer marks its in-place x/y as
restrict).

Verified on this tree, RTX 2080 Ti, default env:

  peak RSS (VmRSS, 8-token prompt)      before    after
  Ternary-Bonsai-2-27B pq2_0            16.8 GiB  11.7 GiB   (anon 9.7 -> 4.9)
  Qwen3.8-27B EXL3 1.60bpw              25.8 GiB  18.3 GiB   (anon 18.2 -> 10.9)
  Ornith-1.5-35B q4_k_m                 26.6 GiB  23.1 GiB   (anon 20.8 = CPU experts)

  suite            119 tests, 102 passed, 0 failed, 17 skipped
  exl3_gpu_parity  29 [FAIL] baseline, identity probes maxAbsDiff=0.000000
  logits probe     id=198 logit=19.3076, top-5 198/1133/271/460/317
  pp512/tg128      725.7/23.43, 723.6/23.39, 721.7/23.35  (published 727.5/23.60)
  core build       0 warnings