serve: a checkpoint whose copy runs out of memory is skipped, it no longer ends the engine (#3350)
A conversation checkpoint is an optimization, like parking, but the writer treated a failed copy as fatal: "conversation snapshot running-state copy: out of memory" (cudaErrorMemoryAllocation from the snapshot copy: the private copy stream's first creation or the driver's staging on a nearly full card, not host RAM) made the prefill fail and the engine exit, 21 times in 4 h for one reporter and 16 in 34 h for another, each exit a reload and the in-flight requests lost. Now, after a failed save, checkpoint_failure_is_survivable() clears the non-sticky allocation error and synchronizes the device: when that is clean the checkpoint is skipped with a line on stderr and the request goes on (a layer split's stage part is left empty, which already means "no checkpoint at this length"; the message-boundary / turn / root checkpoints after a prompt chunk do the same). A device that is unwell (a sticky error, a GPU that stopped answering) still ends the request exactly as before. Same edits in sycl/src/program/generate.cpp. STRATA_TEST_COPY_FAIL_AT=N (tests only, like STRATA_TEST_SLOW_COPY_US): the N-th snapshot copy of the process fails with cudaErrorMemoryAllocation, so the case can be made without a full card. Unset, nothing changes. Not changed: "verify: instantiate: out of memory" (graph capture), which the reporter saw once.
This commit is contained in:
1 parent
3cd33d504c
commit
f62589fdbe
3 files changed
+85
-8
No files matched your search
@@ -1745,6 +1745,15 @@ bool checkpoint_save(ConvCheckpoint& c, const strata::core::SessionState& ss, co
|
||||
return false;
|
||||
}
|
||||
|
||||
/// #3350: a conversation checkpoint is an optimization, like parking. After a failed save: true when the failure was
|
||||
/// only the copy's memory (a host or driver allocation, which does not stick), so the caller goes on without that
|
||||
/// checkpoint; false when the GPU itself is unwell (a sticky error comes back from the synchronize), which still ends
|
||||
/// the request as before.
|
||||
bool checkpoint_failure_is_survivable() {
|
||||
(void) cudaGetLastError(); // clears a failed allocation; a sticky error is not cleared and is returned again below
|
||||
return cudaDeviceSynchronize() == cudaSuccess;
|
||||
}
|
||||
|
||||
/// Puts a checkpoint's running state back; the positional cells below it are the caller's to guarantee.
|
||||
bool checkpoint_restore(const ConvCheckpoint& c, strata::core::SessionState& ss, const strata::core::ModelGeometry& g) {
|
||||
std::string error;
|
||||
@@ -10060,7 +10069,15 @@ int main(int argc, char** argv) {
|
||||
} else {
|
||||
saved = checkpoint_at(done, nullptr, tail_checkpoint && !periodic_checkpoint);
|
||||
}
|
||||
if (!saved) { e = "saving a conversation checkpoint failed" + ckpt_why; return false; }
|
||||
if (!saved) {
|
||||
// #3350: only a GPU that is unwell ends the request; a copy that ran out of memory skips this checkpoint
|
||||
if (!ckpt_why.empty() || !checkpoint_failure_is_survivable()) {
|
||||
e = "saving a conversation checkpoint failed" + ckpt_why;
|
||||
return false;
|
||||
}
|
||||
std::fprintf(stderr, "strata serve: checkpoint at %lld skipped: its state could not be copied out (see "
|
||||
"above); the request goes on without it\n", (long long) done);
|
||||
}
|
||||
if (periodic_checkpoint) pp_next_check = done + o.prompt_cache_every;
|
||||
if (tail_checkpoint) pp_tail_saved = true;
|
||||
}
|
||||
@@ -10077,7 +10094,16 @@ int main(int argc, char** argv) {
|
||||
part_next[i] = done + o.prompt_cache_every;
|
||||
ConvCheckpoint part; // this stage's state at `done` (its stream is synchronized)
|
||||
part.ids.assign(cur.begin(), cur.begin() + done);
|
||||
if (!checkpoint_save(part, stage_ss, g)) { e = "saving a checkpoint part failed"; return false; }
|
||||
if (!checkpoint_save(part, stage_ss, g)) {
|
||||
// #3350: the copy ran out of memory (not the GPU): leave this part out. The set at `done` is then
|
||||
// incomplete and the checkpoint is skipped below, as for a part that was never made
|
||||
if (!checkpoint_failure_is_survivable()) { e = "saving a checkpoint part failed"; return false; }
|
||||
std::fprintf(stderr, "strata serve: checkpoint at %lld skipped: stage %zu's state could not be copied "
|
||||
"out (see above); the request goes on without it\n", (long long) done, i);
|
||||
std::lock_guard<std::mutex> lk(part_mu);
|
||||
part_at[done].resize(stages.size() + 1); // (marks the set as seen; its empty parts make it incomplete)
|
||||
return true;
|
||||
}
|
||||
std::lock_guard<std::mutex> lk(part_mu);
|
||||
auto& v = part_at[done];
|
||||
v.resize(stages.size() + 1);
|
||||
@@ -14278,8 +14304,12 @@ int main(int argc, char** argv) {
|
||||
at = to;
|
||||
if ((to == turn_at || to == root_at || to == message_at || to == pin_at) &&
|
||||
!checkpoint_at(to, nullptr, to == message_at && to != turn_at && to != root_at && to != pin_at)) { // the tail kind leaves first
|
||||
std::printf("ERR saving a conversation checkpoint failed%s\n", ckpt_why.c_str());
|
||||
return 1;
|
||||
if (!ckpt_why.empty() || !checkpoint_failure_is_survivable()) { // #3350: only an unwell GPU ends the request
|
||||
std::printf("ERR saving a conversation checkpoint failed%s\n", ckpt_why.c_str());
|
||||
return 1;
|
||||
}
|
||||
std::fprintf(stderr, "strata serve: checkpoint at %lld skipped: its state could not be copied out (see "
|
||||
"above); the request goes on without it\n", (long long) to);
|
||||
}
|
||||
if (to == pin_at && !pin_checkpoint(pin_at))
|
||||
std::fprintf(stderr, "strata serve: pin=%lld: its checkpoint was not kept\n", (long long) pin_at);
|
||||
|
||||
Reference in new issue
Block a user