[HIP][LD][GW] Bound VRAM across requests: unpooled KV + FP16 serve KV + bucketed flash scratch
Federico saw VRAM grow ~7 GiB per agent step (44.9/48 GiB, near OOM). Root cause: the KV cache scales with max_seq=prompt+max_new (varies per request) and the exact-size DeviceBuf pool retained every distinct KV size, so a multi-turn chat accumulated KV without bound. The full-attn flash scores scratch (n_win grows per token) leaked similarly. - DeviceBuf gains a 'pooled' flag + alloc_unpooled(): always hipFree on drop, never pooled. KV (k_cache/v_cache) uses it -> freed at request end, no accumulation. Per-token fixed-size intermediates stay pooled (decode speed). - flash_scores_scratch buckets the allocation to a power of two so the pool reuses it as cur_pos grows (kernel still strides by actual n_win <= bucket). - KV dtype: FP16 for the resident serve (exact strata KvDtype::FP16 default, parity-verified EXACT, half the VRAM of F32). Safe process-wide switch set_kv_f16(); InklingEngine::new opts in. The ld CPU-oracle parity tests keep the F32 default (VETTA_F32_KV=1 also forces F32). Measured (new binary, 3 requests of 200/400/600 prompt tokens): VRAM 7.66 -> 8.07 -> 8.33 GiB (small bounded expert lazy-load growth, NOT +7 GiB/step); clean release to 0.34 GiB on QUIT. Parity EXACT (16 tok); 18 ld + 18 hip + 5 gw GPU green; workspace -D warnings green; 5 Lean 0 sorryAx.
This commit is contained in:
1 parent
b1f65942c8
commit
c9713c8bc1
3 files changed
+68
-22
No files matched your search
@@ -63,6 +63,10 @@ pub struct InklingEngine {
|
||||
impl InklingEngine {
|
||||
/// Load the archive + `config.json` and derive the forward dimensions.
|
||||
pub fn new(dir: &str) -> Result<Self, String> {
|
||||
// Production KV dtype: FP16 (exact strata default, parity-verified EXACT,
|
||||
// half the VRAM of the F32 CPU-oracle baseline). The ld parity tests keep
|
||||
// the F32 default; the resident serve opts in here.
|
||||
vetta_infer_ld::layer::set_kv_f16(true);
|
||||
let ar = SafetensorsArchive::open(dir)?;
|
||||
let cfg_path = ar.dir.join("config.json");
|
||||
let raw = std::fs::read_to_string(&cfg_path)
|
||||
|
||||
Reference in new issue
Block a user