mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 07:18:50 +00:00
The elastic global K/V grew one visit at a time (new buffer, copy, free the old one), so the card needed one old visit buffer extra and a long request stopped 1.2 to 1.8 GB short of the
context that had been planned ("VRAM exhausted growing elastic global KV cache", 503), and the plan was set before the drafter (DSpark's fused weights, DFlash 2 codebooks and rings)
took its memory.
- ink_runner.cuh: with ONE slot on ONE card (no layer split, no elastic 1M mode, K/V not split to host at the start) every global visit's K, V and scale buffers are address ranges for the
requested context (strata::core::VmmRange, src/core/vmm.cpp, now also linked into the CUDA backend) and physical memory is mapped behind them as the context grows; the pointers never
move, so no peak of old + new. A failed mapping falls back to the host tail (kv_spill_tail, the earlier code, now a function) or to a refused request, as before.
STRATA_INK_KV_VMM=0 takes the earlier growth back.
- ink_dspark.cuh: the classic drafter's global context grows the same way (ctx_vmm).
- ink_cuda_backend.cu: after the drafter has loaded (--kv-offload off), max_ctx is set to what the card holds (ink_kv_reach_ctx, 256 MiB kept free), up or down, never above
--max-context ("max_ctx A -> B" line); --kv-prealloc / STRATA_INK_KV_PREALLOC=1 maps that whole context at start-up (and refuses to start, with a message, if the mapping fails); a request
that fails to grow says how much video memory is free now and what to do.
- ink_serve.h + InkBackend::kv_reachable_tokens(): a prompt the card can no longer hold (another program took video memory after the plan, --kv-offload off) is refused at the start with
a message instead of ending with 0 tokens; the engine stays up.
- strata/core/ink_kv_grow.hpp: ink_kv_reach_ctx() and its test (ink_kv_grow_test). Register: STRATA_INK_KV_PREALLOC (opt-in), STRATA_INK_KV_VMM (rollback); docs/INKLING_KV.md, SETTINGS.md.
Measured (RTX 4090, SQ-20 v2, --kv fp8 --kv-offload off, prompts of 90K / 100K / 110K / 128K tokens; VRAM ballast taken before the first allocation to get the Windows 4090's room;
phaseA-tests/rel0224/ink-kv/RESULTS.md, REPLY-6770.md): no ballast: tokens identical old / new / --kv-prealloc, decode equal; 700 MiB ballast, classic drafter: old ends the 110K request at
100,864 tokens with 0 tokens, new answers it; default drafter: old plans 104,192 and refuses 110K and 128K, new answers both; 1,300 MiB: old plans 74,240, new raises it to 109,568 and
answers a 100K prompt; every answer identical to the unballasted run; short prompts: same tokens, speed within 0.5%; ballast after the start: --kv-offload auto answers (host tail), off
refuses with a message. An RTX A6000 with a 128K prompt: identical tokens. Builds: CUDA sm_86 and sm_89 (Linux), sm_120 (MSVC), HIP gfx1151.