[HIP][Core] Zero-VRAM PrefixCache in pinned host RAM (PinnedBuf) + DSpark SWA ring
Close Punto 3 of the flat-VRAM plan:
- Add PinnedBuf (hipHostMallocDefault / hipHostFree with stream 0 sync on drop) and pipelined async 1D/2D D2H/H2D copy helpers in vetta_kernels.{h,hip} and vetta-infer-hip.
- Migrate LayerSnapshot (KV + ShortConv hist) and DsparkSnapshot (drafter KV + frnn_last) from VRAM DeviceBuf to host PinnedBuf (0 bytes VRAM per checkpoint).
- Size DSpark SWA layers 0/2 in DsparkContext to DS_SWA_RING=1280 (-258 MiB VRAM at 32k context).
- Add GPU regression tests: pinned_buf_zero_vram_and_roundtrip_2d (+0.00 MiB VRAM on 64 MiB alloc) and serve_gen_pinned_prefix_cache_vram_flat (4 turns up to 2100 tok, 8/8 checkpoints full, VETTA_SPEC=1: 20674->20672->20676->20676 MiB, +2.00 MiB delta).
- Update README.md, docs/ORIENTATION.md, and review/2026-12-02-fix-drafter-e-ottimizzazioni.md.
This commit is contained in:
1 parent
c1c5221642
commit
1772050087
9 files changed
+370
-88
No files matched your search
@@ -82,6 +82,45 @@ extern "C" int vetta_buf_copy2d(void* dst, size_t dpitch, const void* src,
|
||||
HIP_CHECK(hipMemcpy2D(dst, dpitch, src, spitch, width, height, hipMemcpyDeviceToDevice));
|
||||
return 0;
|
||||
}
|
||||
// Pinned host RAM buffers for zero-VRAM PrefixCache checkpoints (matches strata
|
||||
// PromptCkpt): hipHostMallocDefault lives in host RAM (0 bytes VRAM) and transfers
|
||||
// via SDMA on stream 0 with hipMemcpy[2D]Async. vetta_host_free syncs stream 0
|
||||
// before hipHostFree so in-flight async copies never race with eviction/drop.
|
||||
extern "C" int vetta_host_alloc(void** out, size_t bytes) {
|
||||
if (!out) return 1;
|
||||
HIP_CHECK(hipHostMalloc(out, bytes, hipHostMallocDefault));
|
||||
return 0;
|
||||
}
|
||||
extern "C" int vetta_host_free(void* p) {
|
||||
if (!p) return 0;
|
||||
(void)hipStreamSynchronize((hipStream_t)0);
|
||||
HIP_CHECK(hipHostFree(p));
|
||||
return 0;
|
||||
}
|
||||
extern "C" int vetta_buf_d2h_async(void* dst_host, const void* src_dev, size_t bytes) {
|
||||
if (bytes == 0) return 0;
|
||||
HIP_CHECK(hipMemcpyAsync(dst_host, src_dev, bytes, hipMemcpyDeviceToHost, (hipStream_t)0));
|
||||
return 0;
|
||||
}
|
||||
extern "C" int vetta_buf_h2d_async(void* dst_dev, const void* src_host, size_t bytes) {
|
||||
if (bytes == 0) return 0;
|
||||
HIP_CHECK(hipMemcpyAsync(dst_dev, src_host, bytes, hipMemcpyHostToDevice, (hipStream_t)0));
|
||||
return 0;
|
||||
}
|
||||
extern "C" int vetta_buf_copy2d_d2h_async(void* dst_host, size_t dpitch, const void* src_dev,
|
||||
size_t spitch, size_t width, size_t height) {
|
||||
if (width == 0 || height == 0) return 0;
|
||||
HIP_CHECK(hipMemcpy2DAsync(dst_host, dpitch, src_dev, spitch, width, height,
|
||||
hipMemcpyDeviceToHost, (hipStream_t)0));
|
||||
return 0;
|
||||
}
|
||||
extern "C" int vetta_buf_copy2d_h2d_async(void* dst_dev, size_t dpitch, const void* src_host,
|
||||
size_t spitch, size_t width, size_t height) {
|
||||
if (width == 0 || height == 0) return 0;
|
||||
HIP_CHECK(hipMemcpy2DAsync(dst_dev, dpitch, src_host, spitch, width, height,
|
||||
hipMemcpyHostToDevice, (hipStream_t)0));
|
||||
return 0;
|
||||
}
|
||||
// Block until all queued GPU work completes (profiling phase boundaries; the
|
||||
// batched forward is otherwise fully async with no host sync until final d2h).
|
||||
extern "C" int vetta_synchronize(void) {
|
||||
|
||||
Reference in new issue
Block a user