Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion engine/src/program/generate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19727,6 +19727,23 @@ int main(int argc, char** argv) {
spill.size(), (unsigned long long) (spill.bytes() >> 20));
incoming.emplace(std::move(image));
taken = sp; // (the restore below resumes at the SSD entry's prefix, not at the RAM tier's)
// The entry's live state can be longer than this prompt (a fork reads a prefix of it): the
// resume then lands on the longest common prefix, which is no checkpoint's depth, and the
// admission below asked for a checkpoint of exactly that length and ended the engine with
// "ERR restoring a conversation checkpoint failed" (#7648). Resume at the deepest checkpoint
// at or below the prefix instead; with none, read the prompt from 0 rather than mount a state
// the request overwrites.
if (taken.live) {
int64_t depth = -1;
for (const auto& c : incoming->checkpoints)
if ((int64_t) c.ids.size() <= taken.tokens && (int64_t) c.ids.size() > depth)
depth = (int64_t) c.ids.size();
if (depth > 0) {
taken.tokens = depth;
} else {
taken.tokens = 0;
}
}
} else {
std::fprintf(stderr, "strata serve: conversation cache: could not read %zu tokens back from the SSD tier "
"(%s); the prompt is read again\n", sp_tokens, why.c_str());
Expand Down Expand Up @@ -20115,7 +20132,11 @@ int main(int argc, char** argv) {
if ((int64_t) c.ids.size() == parked.tokens) { live = c.ids; live_imgs = c.imgs; }
cvec_cached = donor->cvec;
resume = parked.tokens;
from_live = false;
// A borrow whose donor matched with its live state mounts that state at this depth: there is no
// checkpoint of exactly this length, and the slot read below asked for one and ended the engine with
// "ERR restoring a conversation checkpoint failed" (#7648). A checkpoint match keeps its depth,
// which IS a checkpoint.
from_live = parked.live;
conversations.count_borrow();
std::fprintf(stderr, "strata serve: conversation cache: borrowed %lld tokens from a parked "
"conversation, which stays parked, in %.1f ms; parked=%zu bytes=%zu borrowed=%zu\n",
Expand Down
Loading