mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
Conversation cache: skip a restore only when a card would have to create its copy stream and has no room for it (#2409)
Problem. #2408 / PR #2409: restoring a large parked conversation on a layer split ended the server with a CUDA out of memory on a later card. The PR checks the free VRAM of every card against --vram-reserve-mib before a restore. Its own review points out that a loaded card is always below that reserve, so the check would skip nearly every restore on a split (and on one GPU). It is not ported. What a restore allocates. conversation_snapshot_restore writes into the session's existing buffers (pools(st), the GDN state, the indexer tails); refresh_residency only launches kv_stream_reset or copies into the existing ring. The elastic K/V growth (kvg_ensure) allocates, but only on one GPU. The one thing a restore can create on a card is the calling thread's private copy stream for it (conversation_copy.hpp private_stream), which it takes from the pool of finished threads when there is one (#3350). A failed restore is fatal by contract (the session may be half written). So the need is one stream and one event, and only for a card whose stream does not exist yet (a snapshot loaded from disk, or a restore on a thread that never copied on that card). Change. conv_cache.hpp: kRestoreFirstUseMib (64) and restore_fits(free, stream_ready, n, need): a restore is refused only for a card that has no copy stream yet and less than 64 MiB free. conversation_copy_stream_ready(device) says whether a card has one. generate.cpp: before the restore, each card of the run is checked; a snapshot that would not fit goes back to the cache and the prompt is read again, with a log line. A card that has its stream is never refused, however full. No sample (a failed cudaMemGetInfo) means the restore goes ahead as it did. Tests. conv_cache_test: the predicate (cards with a stream are admitted at any free size; the edge at the need; no sample / no cards / no need). conversation_copy_streams_test: copy_stream_ready before and after the first copy, in the pool after a thread ends, and the measured cost of a card's first copy stream and event (printed; the test requires under 16 MiB, so 64 MiB leaves a wide margin). conversation_snapshot_test: after the first restore, six more restores of two images leave the free VRAM where it was. Not covered. The pure predicate and the generate.cpp code build on z440 (CUDA 13.0); the GPU tests are listed in the stream notes. No model run: gates/2409-restore-guard.sh (a held-VRAM start on a layer split) shows the skip line and an unchanged answer on the second turn.
This commit is contained in:
1 parent
2a9a67c174
commit
8c0301484e
8 files changed
+140
No files matched your search
@@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
using strata::program::conv_cache::eviction_victim;
|
||||
using strata::program::conv_cache::restore_fits;
|
||||
using strata::program::conv_cache::spread_victim;
|
||||
|
||||
namespace {
|
||||
@@ -132,6 +133,24 @@ int main() {
|
||||
check(eviction_victim(s4.data(), s4.size(), 4, nullptr, all) == 2, "everything pinned: the oldest pin leaves, never the root");
|
||||
check(eviction_victim(s4.data(), s4.size(), 1, nullptr, all) == 0, "a one-slot budget keeps no pin: the oldest leaves");
|
||||
}
|
||||
{ // #2409: a restore is refused only for a card that must create its copy stream and has no room for it
|
||||
constexpr uint64_t need = strata::program::conv_cache::kRestoreFirstUseMib << 20;
|
||||
const uint64_t loaded[] = {300ull << 20, 104ull << 20}; // a loaded card: far under --vram-reserve-mib
|
||||
const uint8_t ready[] = {1, 1};
|
||||
check(restore_fits(loaded, ready, 2, need), "cards with their stream already: any amount free admits (the #2409 review's case)");
|
||||
const uint8_t later_new[] = {1, 0};
|
||||
check(restore_fits(loaded, later_new, 2, need), "a card that must create its stream, with 104 MiB free: admitted");
|
||||
const uint64_t full[] = {300ull << 20, 20ull << 20};
|
||||
check(!restore_fits(full, later_new, 2, need), "a card that must create its stream, with 20 MiB free: reread instead");
|
||||
check(restore_fits(full, ready, 2, need), "the same full card with its stream: admitted");
|
||||
const uint64_t edge[] = {need, need - 1};
|
||||
const uint8_t none[] = {0, 0};
|
||||
check(!restore_fits(edge, none, 2, need), "one byte under the need refuses");
|
||||
check(restore_fits(edge, none, 1, need), "exactly the need admits");
|
||||
check(restore_fits(nullptr, none, 2, need) && restore_fits(full, nullptr, 2, need) && restore_fits(full, none, 0, need) &&
|
||||
restore_fits(full, none, 2, 0),
|
||||
"no sample, no cards, no need: do not refuse");
|
||||
}
|
||||
std::printf(g_fail ? "FAIL\n" : "PASS\n");
|
||||
return g_fail ? 1 : 0;
|
||||
}
|
||||
Reference in new issue
Block a user