kv-grow: kvg_trim uploads the residency table with res_put, which waits for the copy

kvg_trim refilled the slots the K/V gave back and then uploaded host_res with a plain cudaMemcpy from pageable memory.
That returns once the table is staged, before its DMA lands, and nothing after it waited for stream 0: the next
request's session_zero syncs main_stream only, and a prompt part of --short-read tokens or fewer goes straight to
ver.run, whose graph reads hits_.d_res on the verifier's cudaStreamNonBlocking stream. res_put (#550) is the upload
every other residency change uses: the same copy, then cudaStreamSynchronize(nullptr).

kvg_ensure's upload needs nothing: qsa_kv_elastic_grow ends in cudaDeviceSynchronize before anything reads the table.
Only --kv-grow (opt-in) runs kvg_trim, so the default path is unchanged.
This commit is contained in:
sergiywith authored and Niko1221 committed 2026-10-09 15:20:05 +02:00
1 parent e85567b617
commit d0336684e5
1 file changed
+2 -2
+2 -2
View File
@@ -6299,8 +6299,8 @@ int main(int argc, char** argv) {
}
for (const auto& [i, s] : filled) host_res[i] = s;
kvg.refilled += (int64_t) filled.size();
if (cudaMemcpy(d_res, host_res.data(), host_res.size() * sizeof(int32_t), cudaMemcpyHostToDevice) != cudaSuccess)
return false;
// res_put waits for its copy: the next reader can be a verify window (a non-blocking stream) right away
if (res_put(d_res) != cudaSuccess) return false;
for (const strata::core::VmmChunk h : kvg.spare) strata::core::vmm_chunk_free(h); // new ones, if any
kvg.spare.clear();
++kvg.trims;