35 std::lock_guard<std::mutex> lock(mutex_);
36 if (samples_.load(std::memory_order_relaxed) == 0) {
37 ewma_tok_s_.store(
sample_tok_s, std::memory_order_relaxed);
39 double prev = ewma_tok_s_.load(std::memory_order_relaxed);
42 std::memory_order_relaxed);
44 samples_.fetch_add(1, std::memory_order_relaxed);
45 logger->info(
"Throughput sample: {:.1f} tok/s, EWMA={:.1f} tok/s, "
48 ewma_tok_s_.load(std::memory_order_relaxed),
49 samples_.load(std::memory_order_relaxed));
59 return ewma_tok_s_.load(std::memory_order_relaxed);
75 (
static_cast<double>(token_count) /
tps) * 1000.0);
107 return samples_.load(std::memory_order_relaxed);
116 std::lock_guard<std::mutex> lock(mutex_);
117 ewma_tok_s_.store(0.0, std::memory_order_relaxed);
118 samples_.store(0, std::memory_order_relaxed);
long long elapsed_ms
Wall time, spawn to reap.
double tok_per_sec() const
Current smoothed throughput estimate.
int sample_count() const
Number of recorded samples.
void reset()
Reset all throughput data.
int recommend_tokens(int64_t time_budget_ms, float headroom=0.9f, int floor=64) const
Recommend max_tokens to fit within a time budget.
void record(int tokens_generated, int64_t elapsed_ms)
Record a completed generation sample.
int64_t predict_ms(int token_count) const
Predict wall-clock time for generating N tokens.
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Activate model on GPU (WARM → ACTIVE).
@ optional
optional: every escape asks the host's path approver
ThroughputTracker – real-time throughput measurement and prediction.