Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
generation_summary.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
28#pragma once
29
30#include <string>
31
32namespace entropic {
33
45 int token_count = 0;
46 std::string finish_reason;
47 double generation_time_ms = 0.0;
48 double throughput_tok_s = 0.0;
49 int n_drafted = 0;
50 int n_accepted = 0;
51};
52
69inline std::string format_generation_summary(const GenerationSummary& s) {
70 char buf[256];
71 int n = std::snprintf(
72 buf, sizeof(buf),
73 "Generated: %d tokens, finish=%s, %.0fms, %.1f tok/s",
74 s.token_count, s.finish_reason.c_str(),
75 s.generation_time_ms, s.throughput_tok_s);
76 std::string out(buf, n > 0 ? static_cast<size_t>(n) : 0U);
77
78 // Only when speculation actually ran. A plain decode printing
79 // "drafted=0, accepted=0, accept_rate=0.000" would be noise on every
80 // line, and would make "did speculation run" ambiguous in the logs.
81 if (s.n_drafted > 0) {
82 const double rate = static_cast<double>(s.n_accepted)
83 / static_cast<double>(s.n_drafted);
84 n = std::snprintf(buf, sizeof(buf),
85 ", drafted=%d, accepted=%d, accept_rate=%.3f",
86 s.n_drafted, s.n_accepted, rate);
87 out.append(buf, n > 0 ? static_cast<size_t>(n) : 0U);
88 }
89 return out;
90}
91
92} // namespace entropic
Activate model on GPU (WARM → ACTIVE).
@ optional
optional: every escape asks the host's path approver
std::string format_generation_summary(const GenerationSummary &s)
Format the one-line generation summary.
The numbers a finished generation reports, whatever produced it.
int n_drafted
Speculative: tokens proposed (0 = plain).
int token_count
Tokens actually generated.
double throughput_tok_s
token_count / seconds.
int n_accepted
Speculative: tokens accepted.
double generation_time_ms
Wall clock for the generation.
std::string finish_reason
stop / length / error / cancel.