[GW][HIP][LD] Link vetta-infer to strata-ctl; isolate GPU tests; size KV per pass

End-to-end verified: strata-ctl --serve spawns vetta-infer and serves the
OpenAI-compatible API. Live: 'capital of France' -> Paris (finish stop), and
Italian multi-turn context -> Napoli. Two wire-compat gaps closed:
- accept '--serve <dir>' alias (strata-ctl engine_argv prepends --serve).
- emit the EOS token as 'T <eos>' before 'DONE ... stop', matching the
  reference strata-inkling --serve (strata-ctl's dialect decoder reads the
  end-of-sampling channel token). chat parity now EXACT incl. EOS.

GPU test isolation (the 5th full-model test OOM'd): HIP-visible VRAM is 48 GiB
(model 18 GiB; one live instance peaks ~15 GiB and releases cleanly). The OOM
was the harness, not a leak: the thread-local DeviceBuf pool retains buffers
for each libtest worker thread's lifetime, so 5 engines' weights accumulated
past 48 GiB. Fix: gw gpu_isolated() runs heavy tests under a serial lock with
the pool disabled via a new safe hip::set_buf_pool_enabled (no env mutation,
gw stays unsafe-free), so every drop hipFrees between tests.

KV sizing: LayerState.k_cache/v_cache are now Vec sized to the passes a layer
actually runs (core 3, prelude/coda 1) instead of 3 for every layer, removing
~1.6 GiB of unused KV at max context. Parity unchanged (EXACT 16 tok).

Suite: workspace -D warnings green; 18 ld + 18 hip + 5 gw GPU; 5 Lean 0 sorryAx.
This commit is contained in:
adm committed 2026-12-01 18:26:18 +01:00
1 parent b9cac6d0df
commit 7790f48c27
7 files changed
+97 -18

No files matched your search

+20
View File
@@ -20,6 +20,26 @@ pub mod serve;
#[cfg(feature = "hip")]
pub mod chat;
/// Serializes the heavy full-model GPU integration tests. Each loads the whole
/// Inkling engine (weights + KV), so running them concurrently exhausts GPU
/// memory; only one engine is resident at a time.
#[cfg(all(test, feature = "hip"))]
pub(crate) static GPU_SERIAL: std::sync::Mutex<()> = std::sync::Mutex::new(());
/// Run a heavy GPU test body under the serial lock with the buffer pool OFF.
/// Two isolation guarantees: (1) only one full-model engine is resident at a
/// time (concurrent engines exhaust GPU memory); (2) the DeviceBuf pool is
/// disabled process-wide so every drop calls hipFree and device memory is
/// actually released between tests — the thread-local pool otherwise retains
/// buffers for the lifetime of each libtest worker thread and OOMs the GPU by
/// the fifth test. Safe: no env mutation, no `unsafe` in the gw crate.
#[cfg(all(test, feature = "hip"))]
pub(crate) fn gpu_isolated<F: FnOnce()>(f: F) {
let _serial = GPU_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
vetta_infer_hip::set_buf_pool_enabled(false);
f();
}
/// Python-repr float spelling (always a decimal point), as `strata-ctl` emits.
fn fmt_float(v: f64) -> String {
let s = format!("{v}");