faceebb50 chose the chunk from the memory left after the experts only. On a 24 GB card with UD-Q4_K_XL at 32K the 1024 chunk took the room the
global K/V needs to grow, so the K/V tail went to host RAM and decode at 30K tokens fell with 2 slots from 80.9 to 36.0 tok/s (3 slots 14.7).
The chunk now also has to leave slots x (context - the window allocated at start) x bytes per position free (none when K/V offload is on).
RTX 4090, UD-Q4_K_XL, 32K, decode tok/s at 30K tokens, 1 / 2 / 3 slots:
faceebb50 87.7 / 36.0 / 14.7
this change 86.6 / 79.8 / 24.0
STRATA_INK_CHUNK_AUTO=0 (chunk 512, the old default) 87.7 / 80.9 / 25.4
3 slots spill by the engine's own auto host-offload decision, not by the chunk (the same with the old default).
ink_chunk_test covers the three cases.
The chunk (prompt tokens per forward step, default 512) limited prefill: RTX 5090, strata-inkling --bench, one stream, 4K prompt, SQ-20: 512 -> 8.1K tok/s,
1024 -> 9.5K, 2048 -> 10.5K, 4096 -> 10.7K (16K prompt 7.0K -> 8.9K at 2048, 32K 6.1K -> 7.5K); UD-Q4_K_XL 4.07K -> 4.47K at 2048, flat after; nothing
is lost up to 8192. A bigger chunk costs working memory: the runner and K/V took 1460 / 1822 / 2710 / 4558 MiB at chunk 512 / 1024 / 2048 / 4096 on an
RTX 4090 (SQ-20 all resident, 5255 MiB free after the experts; the engine caps max_batch at 4096) and 1440 / 1804 MiB at 512 / 1024 on an RTX 3060 Ti
8 GB, where 2048 did not fit and the halve-on-fail retry (859276060) brought it back to 1024.
- strata/core/ink_chunk.hpp: ink_auto_chunk(free_after_load_mib, slots): the largest of 2048 / 1024 that fits (the memory the runner takes at that chunk
+ 1500 MiB margin for K/V growth, the drafter and the desktop), else 512; capped by the slot count: 2048 for 1-3 slots, 1024 for 4-15, 512 from 16.
The experts are placed first, with their reserve computed for chunk 512, so a bigger chunk never displaces an expert: a hybrid card with little left
keeps 512, a card whose experts are all resident gets 2048. Test ink_chunk_test (the 4090 and 3060 Ti ledgers, the cap, monotone in memory).
- InkCudaBackend::init resolves the chunk after the experts are placed and logs "[InkCUDA] prefill chunk N (auto: M MiB free after the experts, S slot(s);
--chunk N sets it)"; effective_chunk() reports what the runner really got; ink_serve (token_budget) and --bench use it. --chunk N still wins,
STRATA_INK_CHUNK_AUTO=0 keeps 512. HIP, SYCL, Metal and CPU keep 512 (BackendOpts::chunk_auto is read only by the CUDA backend).
- The slot cap comes from the mixed-work case, 32 slots, a 16K prompt arriving among 31 decoders, longest wait of a decoding slot at chunk 512 / 1024 /
2048: RTX 3060 Ti 8 GB (SQ-10 hybrid) 2322 / 2210 / 43,424 ms (the long prompt read in 91 / 56 / 218 s); RTX 4090 (SQ-20 resident) 2096 / 3974 ms with the
long prompt at 108 / 110 s; RTX 3060 12 GB 3897 ms at 512, 2804 ms at 1024. Throughput of 32 requests of 512 tokens at once (prompt + output tok/s):
8 GB 55 (512) / 83 (1024) / 125 (2048); 12 GB 65 / 95; 4090 43 / 51. These ran on boxes whose CPUs were loaded by other jobs: relative numbers only.
- Equivalence: RTX 4090 SQ-20 (resident): greedy tokens identical between the auto chunk (2048) and --chunk 512 for prompts of 15, 200, 3000, 16000 and 30000
tokens; serve prefill 3000 / 16000 / 30000 tokens 2788 / 2979 / 4608 -> 3088 / 3247 / 5053 tok/s. Hybrid SQ-10 (8 and 12 GB): identical up to 3000
tokens, different at 16K (and 30K on the 8 GB card) between the two chunks, with the 512 runs of the two cards also differing from each other (expert
promotion of the hybrid path); a same-chunk repeat is queued.
- No OOM and no retry in any gate run (8 / 12 / 24 GB, 1 and 32 slots).