A prompt cancelled mid-read is logged and recorded with the tokens it read (#471)
The engine's `strata serve: prompt ...` line now says "= 0 reused + 12288 of 98179 read in ... (cancelled)" with the rate from the tokens read, and DONE gets a 15th field: the prompt tokens actually read. The server's /metrics history and totals count reused + read for a cancelled read (prompt_total keeps the whole prompt); an older engine's DONE line (no such field) is read as before.
This commit is contained in:
1 parent
5b734e427c
commit
512ae42f7c
3 files changed
+103
-12
No files matched your search
@@ -3697,7 +3697,7 @@ int main(int argc, char** argv) {
|
||||
// and each generated token is written to stdout as `T <id>` as soon as its verify window is done, followed by
|
||||
//
|
||||
// DONE <generated> <prompt_tokens> <prompt_ms> <decode_ms> <stop|length|cancel> <drafts accepted>
|
||||
// <drafts offered> <prompt tokens reused>
|
||||
// <drafts offered> <prompt tokens reused> ... <prompt tokens read> (see the DONE line below; #471)
|
||||
//
|
||||
// Before that, `RESUME <n>` (n prompt tokens are not read again), `PP <position> <prompt_tokens> <ms> <tok/s>`
|
||||
// after every prompt chunk, and `REUSED <n>` once the prompt is read. (`ERR <message>` instead when a request
|
||||
@@ -4373,6 +4373,9 @@ int main(int argc, char** argv) {
|
||||
return true;
|
||||
};
|
||||
int64_t pp_total = 0, pp_from = 0, pp_next_check = 0;
|
||||
// #471: the position the prompt pass has read up to (a chunk's or a window's end): what a request cancelled
|
||||
// mid-read reports as read, instead of the whole prompt
|
||||
int64_t pp_reached = 0;
|
||||
Clock::time_point pp_t0 = Clock::now();
|
||||
auto imgs_below = [&](const std::vector<ImgKey>& all, int64_t L) {
|
||||
std::vector<ImgKey> v;
|
||||
@@ -4436,6 +4439,7 @@ int main(int argc, char** argv) {
|
||||
batched ? "batched" : "token", mtp.kv_state().kv_mode, (long long) T);
|
||||
// progress for the server window: PP <position reached> <prompt tokens> <ms> <fresh tokens/s>
|
||||
const int64_t done = p0 + T;
|
||||
pp_reached = done;
|
||||
const double ms = std::chrono::duration<double, std::milli>(Clock::now() - pp_t0).count();
|
||||
std::printf("PP %lld %lld %.0f %.1f\n", (long long) done, (long long) pp_total, ms,
|
||||
ms > 0.0 ? 1000.0 * (double) (done - pp_from) / ms : 0.0);
|
||||
@@ -5063,6 +5067,7 @@ int main(int argc, char** argv) {
|
||||
conversations.limit_reuse(read_from);
|
||||
pp_total = n;
|
||||
pp_from = read_from;
|
||||
pp_reached = read_from;
|
||||
pp_t0 = r0;
|
||||
pp_next_check = reread_to > 0 ? INT64_MAX : resume + o.prompt_cache_every;
|
||||
{
|
||||
@@ -5128,6 +5133,7 @@ int main(int argc, char** argv) {
|
||||
return false;
|
||||
if (!ver.commit(T, e) || !mtp.prefill(ver.final_R_all(), nxt.data(), T, q, e)) return false;
|
||||
q += T;
|
||||
pp_reached = q; // #471
|
||||
}
|
||||
// the batched prompt path (other streams), checkpoints and snapshots may follow: the last commit first
|
||||
if (!ver.wait_commit(e)) return false;
|
||||
@@ -5628,20 +5634,30 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
const int64_t req_hits = drive.d.cache_hits - decode_hits0;
|
||||
const int64_t req_look = (drive.d.cache_hits + drive.d.cache_admitted + drive.d.cache_refused) - decode_look0;
|
||||
// #471: the prompt tokens this request read - all the fresh ones, or as far as the prompt pass got when a
|
||||
// cancel stopped it part-way (a cancelled request used to be logged and counted as having read them all)
|
||||
const int64_t fresh = n - resume;
|
||||
const int64_t read_n = cancelled ? std::clamp<int64_t>(pp_reached - resume, 0, fresh) : fresh;
|
||||
// DONE <generated> <prompt> <prompt ms> <decode ms> <finish> <drafts accepted> <drafts offered> <reused> [hits] [lookups]
|
||||
// [RAM blobs] [file blobs] [file MB] (CS-T tiers; appended, so an older server reads the rest)
|
||||
std::printf("DONE %lld %lld %.1f %.1f %s %lld %lld %lld %lld %lld %lld %lld %.1f\n", (long long) produced_n,
|
||||
// [prompt tokens read] (#471: fewer than <prompt> - <reused> when a cancel stopped the read)
|
||||
std::printf("DONE %lld %lld %.1f %.1f %s %lld %lld %lld %lld %lld %lld %lld %.1f %lld\n", (long long) produced_n,
|
||||
(long long) n, prompt_ms, decode_ms, finish, (long long) draft_accepted, (long long) draft_offered,
|
||||
(long long) resume, (long long) req_hits, (long long) req_look,
|
||||
(long long) (src.ram_reads() - ram0), (long long) (src.file_reads() - files0),
|
||||
(double) (src.file_read_bytes() - file_bytes0) / 1e6);
|
||||
(double) (src.file_read_bytes() - file_bytes0) / 1e6, (long long) read_n);
|
||||
std::fflush(stdout);
|
||||
if (drive.routing != nullptr) std::fflush(drive.routing); // the routing trace survives a crash and is watchable mid-session
|
||||
const int64_t fresh = n - resume;
|
||||
std::fprintf(stderr, "strata serve: prompt %lld tokens = %lld reused + %lld read in %.0f ms (%.1f tok/s), "
|
||||
// "12288 of 98179" when cancelled mid-read (#471), the rate from what was read
|
||||
char read_txt[64];
|
||||
if (cancelled)
|
||||
std::snprintf(read_txt, sizeof(read_txt), "%lld of %lld", (long long) read_n, (long long) fresh);
|
||||
else
|
||||
std::snprintf(read_txt, sizeof(read_txt), "%lld", (long long) fresh);
|
||||
std::fprintf(stderr, "strata serve: prompt %lld tokens = %lld reused + %s read in %.0f ms (%.1f tok/s), "
|
||||
"%lld generated in %.0f ms (%.1f tok/s), drafts accepted %lld of %lld, %zu checkpoints%s\n",
|
||||
(long long) n, (long long) resume, (long long) fresh, prompt_ms,
|
||||
prompt_ms > 0 ? 1000.0 * fresh / prompt_ms : 0.0, (long long) produced_n, decode_ms,
|
||||
(long long) n, (long long) resume, read_txt, prompt_ms,
|
||||
prompt_ms > 0 ? 1000.0 * read_n / prompt_ms : 0.0, (long long) produced_n, decode_ms,
|
||||
decode_ms > 0 ? 1000.0 * produced_n / decode_ms : 0.0, (long long) draft_accepted,
|
||||
(long long) draft_offered, checks.size(), cancelled ? " (cancelled)" : "");
|
||||
// the VRAM share of the experts the pool looked up while decoding; experts it sent over PCIe for the GPU
|
||||
|
||||
Reference in new issue
Block a user