Skip to content

Context windows sized by VRAM/RAM (int8 K/V store)

Choose a tag to compare

@mgorshkov mgorshkov released this 19 Nov 19:08
· 45 commits to main since this release
maxSeqLen was a constant 2048 that no flag could move, and the K/V cache was
f32 with no way to spend less per token, so the engine could not use a long
window on any card.  The window is now requested (Model::setContextLength,
--ctx N on the bench and the probes) and granted by a planner from measured
free VRAM/RAM: weights + the session's fixed 1,408 MiB + the K/V bytes/token
of the model's geometry, picking the first rung that fits from (f32 + int8
decode mirror), (f32), (int8 store) and, on the host, the same ladder bounded
by RAM.  A request that does not fit is reduced to the fit and the limiting
resource is named; below 1024 tokens the load is refused.  The int8 path is a
real K/V store (prefill and decode, arch-1 qwen35 full-attention and the MoE
prefix), not a decode-only mirror, which is what lets a long window fit an
11 GB card.

Default stays 2048, so every published throughput row still describes the
shipped default (re-measured at the default: 9B 2554.9/83.44, Bonsai 878.7/
51.28, 27B 727.4/23.52 -- inside the published spread).

Measured grants and the gates on this tree (RTX 2080 Ti, 11 GB), each
confirmed by a load that requested the window:

  Ornith-1.5-9B q4_k_m   41,984 f32+mirror | 52,480 f32 | 196,352 int8
  Ternary-Bonsai pq2_0   16,640 f32        |   --       |  64,256 int8
  Qwen3.8-27B EXL3       2,560 f32+mirror  |   --       |  12,288 int8

A 44,892-token prompt prefills at 533 tok/s and answers a needle at 64k; a
64k window costs 2-6% of decode and nothing measurable at pp512.  int8 at the
same 2048 window moves the Bonsai logit by 0.0129 (same top-1, same top-3).
Gates: parity 29 [FAIL] (unchanged), suite 114 tests / 97 passed / 0 failed,
27B logits id=198 19.308033 with top-5 198,1133,271,460,317, context gate
exit 0 (six rows), text gate 8/9.

Known, and in BENCHMARKS.md with the caveats: the 35B-A3B's text gate was
already failing at d79d73f (byte-identical logits), arch-2 has no int8 store
so it keeps f32 and its 2048 window, and 256k/1M need more memory than this
card has (11.3-44.6 GiB) plus RoPE scaling this engine does not implement.

Build and CLI defaults, because "the default build does not work" was the
reported failure: a plain `cmake -B build` now enables the CUDA offload when
nvcc is present (it used to be CPU-only, so `tinycoder_bench --gpu` answered
"unknown option: --gpu"), `--gpu` and `--cpu` are parsed in every build (a
CPU-only binary now says it needs a CUDA build and exits 2), and ENABLE_AVX512
defaults from the build host's CPU flags -- unconditionally ON produced a
binary that SIGILL'd at startup on this Broadwell-class Xeon, which is also
why the CPU-only build tree dies on every model.  Verified: clean configure,
no flags, ENABLE_CUDA=ON + ENABLE_AVX512=OFF, 9B at 83.79 tg / 1068.3 pp.

Also fixes: generate() returned an empty logits array on an over-long prompt
and the caller memcpy'd from it (crash at the shipped window), the host K/V
for a partial offload was unbudgeted, and a host-slot mismatch aliased the
last slot instead of reporting.