Files
Deadcode 3b13fd3266 radiance 2.3.0
New models. Thinking Machines' Inkling 2 Mini by gostar (#584-#586): its text backbone and loop, the
release's NVFP4 and MXFP8 checkpoint read by the converter, an int8 trunk, the vision tower, tensor
parallelism, tool calls (with Warzuponus) and an image processor that matches transformers bit for
bit (millaguie). Inkling's routed experts are served in IQR-V4's four-bit trellis (moe_gemm_iqr),
fitted by GPTQ against Hessians the plugin now records (`--calib-dir`), its token embedding in int8
(read in place by embed_lookup), and incoai's DFlash2 drafter in four bits in place of the release's
DSpark. That container, 14.4 GiB with the vision tower, decodes 190 / 427 / 658 tokens a second at 1
/ 4 / 8 streams at tp 2 on two R9700 with `draft-window: adaptive` (code 240 / 550 / 790,
step-by-step arithmetic 358 / 811 / 1116): 19-43% ahead of the same target with the release's DSpark
drafter and 45-83% ahead of the all-int8 container (26.1 GiB, 124 / 263 / 386), at a mean KL of
0.0066 against the release's weights (int8: 0.0042). DeepSeek-V4.1-Flash on 2.x by baKon (#583),
with its vision tower, its IQ1_S and IQ2_XXS containers and linears and experts served in
llama.cpp's own blocks; parts ported from mikoskinen/r9700-exact-serving by Dad_Vibes' fork.
GLM-5.3-Flash on 2.x with its IQR / IQ8R container, an int8 latent cache and four-card serving by
AnimusNull (#566). Gemma 4 dense on EXL3-V3 by keptn42 (#537), on the EXL3 dense rows and
qwen35_exl3 tensor parallelism by Hero422. NVIDIA's 2-bit Nemotron-3.5-Bolt-74B-A9B on one card by
keptn42 (#477). Wan 2.2 TI2V-5B text-to-video and first-frame video by rkcth (#535). LFM3-1.7B on
RDNA3 iGPUs by DokterSmol (#578). Qwen3.8-27B in bf16 with the DFlash2 drafter, and bf16x12, bf16
weights packed losslessly in 12.25 bits, by eddie168 (#577). Int8 experts for drama-3 by morevgalex
(#598).

Speculative decoding. Draft trees for Qwen3.8-27B's DFlash2 drafts by Kezi (#450, opt-in): one card,
+17% at one stream and +14% at two. --draft-max-lanes and --draft-min-accept, two gates on a block
drafter, and --draft-window-ckpt, its window KV kept in the checkpoint slots, by rkcth (#600-#602).
`draft-window: adaptive` verifies each sequence's drafts up to the first one unlikely to be kept. A
verify's rows share each K and V tile in Inkling's attention by gostar (#608): 93 to 118 tokens a
second at a 70k-token prompt on one card.

Generation. Krea 2 instruction edits with one or two references and registered outfill, LoRA on the
image generators with bias deltas and row-mixer adapters applied per request, and MiniMax-H3's
model-declared sparse attention profiles, by rkcth (#534, #542, #543, #605-#609). MiniMax-H3's audio
reference guide pinned from a frame by 1beb (#595). LTX-2's chunk ceiling raised to 40 by Itoash
(#570).

Fleets and memory. memory.queue-reserve, the hardware queues a card keeps ready, by kevinjd (#589).
memory.pinned-numa-node by Foundry (#580). memory.card-headroom-mib on single-model tensor-parallel
budgets by zihaomu (#624). Parked weights rebuilt on the CPU, memory ownership kept across a failed
handoff and quiescent callbacks serialised, by rkcth (#557-#561). A warm load may unload a parked
model (#592); the first card listed chooses the architecture (#458).

Kernels. libr3d's packed dense IQR GEMM and routed IQR expert rows on gfx1100, and libhalo's GEMV
decode for Qwen3.8-Flash-Next's MoE down, by zihaomu (#562, #620, #622). GGML IQ2_XXS and IQ3_XXS
packed on the card by baKon.

Dashboard. KV cache in tokens (in use, capacity now and with all flexible space), live figures
through long prefill steps, step / decode / prefill / acceptance lines without holes, and expert hit
rates only on tiered models. Seven tile and history defects fixed by Noblistic (#597), vision
encoder and per-card hardware figures by davetha (#574), per-LoRA attribution by dowjames (#552).

Fixed. return_tokens / return_token_ids on the OpenAI endpoints (#571). reasoning_effort "none" and
"minimal" reach a template that takes them as levels, by millaguie (#608). Misaligned loads in the
windowed paged attention over an int8 cache (#540). A retired 27B head refused by name (#541).
rad-convert's GPU trellis jobs kept fed, and --reuse-only, by gostar (#575). jinja's tojson takes
sort_keys by Warzuponus (#582). hfget measures file sizes with stat, by kepler_62f (#623). The
tested C++ compiler is stated in the build guide by lowell80 (#551). The codebase was cleaned up:
shared helpers instead of repeated blocks, and the int8 linear, activation and GEMM code no longer
named after the retired fp8 formats.

Inkling 2 Mini is served in one form: IQR-V4 experts with the DFlash2 drafter
(StillDeadcode/inkling-2-mini-iq4r-v4 on Hugging Face, or
data/recipes/inkling2-mini-iq4r-v4.recipe). A container with the release's DSpark drafter, or with
NVFP4, int8 or 4-bit experts, is refused by name and needs converting again.

Plugin ABI 44: out-of-tree plugins need to be rebuilt.

Thanks to @gostar, @baKon, @Dad_Vibes, @AnimusNull, @keptn42, @Hero422, @rkcth, @DokterSmol,
@eddie168, @morevgalex, @Kezi, @1beb, @Itoash, @kevinjd, @Foundry, @zihaomu, @Noblistic, @davetha,
@dowjames, @Warzuponus, @millaguie, @kepler_62f, @lowell80 and @Code000.
2026-11-26 15:28:37 +01:00

685 lines
37 KiB
C++

#include "metrics.h"
#include "iface.h"
#include <algorithm>
#include <cmath>
#include <cstdio>
namespace rad {
namespace server {
/* ------------------------------------------------------------------ primitives */
Histogram::Histogram(std::vector<double> bounds) : bounds_(std::move(bounds)) {
cnt_.reset(new std::atomic<uint64_t>[bounds_.size()]);
for (size_t i = 0; i < bounds_.size(); ++i) cnt_[i].store(0);
}
void Histogram::observe(double v) {
if (!std::isfinite(v)) return; /* a NaN latency is a bug upstream, not a data point */
/* Cumulative: every bucket whose bound is >= v counts this observation. A linear scan, since
* the lists are twenty-odd entries.
*
* The count first, then the buckets widest first, each with release. A scrape reads the
* buckets narrowest first and the count last, with acquire, so an observation it sees in one
* bucket it also sees in every wider one and in the count: the buckets it renders never
* decrease and never exceed the count. */
n_.fetch_add(1, std::memory_order_release);
for (size_t i = bounds_.size(); i-- > 0 && v <= bounds_[i];)
cnt_[i].fetch_add(1, std::memory_order_release);
double cur = sum_.load(std::memory_order_relaxed);
while (!sum_.compare_exchange_weak(cur, cur + v, std::memory_order_relaxed)) {}
}
std::vector<double> buckets_ttft() {
return {0.001, 0.005, 0.01, 0.02, 0.04, 0.06, 0.08, 0.1, 0.25, 0.5, 0.75,
1.0, 2.5, 5.0, 7.5, 10.0, 20.0, 40.0, 80.0, 160.0, 640.0, 2560.0};
}
std::vector<double> buckets_tpot() {
return {0.01, 0.025, 0.05, 0.075, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5,
0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 20.0, 40.0, 80.0};
}
std::vector<double> buckets_latency() {
return {0.3, 0.5, 0.8, 1.0, 1.5, 2.0, 2.5, 5.0, 10.0, 15.0, 20.0,
30.0, 40.0, 50.0, 60.0, 120.0, 240.0, 480.0, 960.0, 1920.0, 7680.0};
}
/* vLLM's build_1_2_5_buckets: mantissas 1, 2, 5 at every decade, up to max_value (a 32K-context
* model gets 1..20000). */
std::vector<double> buckets_1_2_5(int64_t max_value) {
std::vector<double> out;
if (max_value < 1) max_value = 1;
const int mant[3] = {1, 2, 5};
for (int exp = 0; exp < 12; ++exp) {
for (int m = 0; m < 3; ++m) {
double v = (double)mant[m] * std::pow(10.0, exp);
if (v > (double)max_value) return out;
out.push_back(v);
}
}
return out;
}
/* ------------------------------------------------------------------ registry */
std::string esc_label(const std::string& s) {
std::string o;
for (char c : s) {
if (c == '\\' || c == '"') { o.push_back('\\'); o.push_back(c); }
else if (c == '\n') o += "\\n";
else o.push_back(c);
}
return o;
}
Metrics::Metrics(std::string model_name, int64_t max_model_len)
: model_(std::move(model_name)),
h_ttft_(buckets_ttft()),
h_tpot_(buckets_tpot()),
h_e2e_(buckets_latency()),
h_decode_(buckets_latency()),
h_queue_(buckets_latency()),
h_prompt_tokens_(buckets_1_2_5(max_model_len > 0 ? max_model_len : 32768)),
h_generation_tokens_(buckets_1_2_5(max_model_len > 0 ? max_model_len : 32768)),
h_params_n_({1, 2, 5, 10, 20}),
h_params_max_tokens_(buckets_1_2_5(max_model_len > 0 ? max_model_len : 32768)) {
labels_ = "{model_name=\"" + esc_label(model_) + "\",engine=\"0\"}";
}
static const char* reason_str(SuccessReason r) {
switch (r) {
case SuccessReason::Stop: return "stop";
case SuccessReason::Length: return "length";
case SuccessReason::ToolCalls: return "tool_calls";
case SuccessReason::Abort: return "abort";
case SuccessReason::Error: return "error";
default: return "stop";
}
}
void Metrics::set_cache_config(const std::string& dtype, int64_t block_size, bool prefix_caching,
int64_t prefix_cache_mib) {
cache_labels_ = labels_.substr(0, labels_.size() - 1) + ",cache_dtype=\"" + esc_label(dtype) +
"\",block_size=\"" + std::to_string(block_size) +
"\",enable_prefix_caching=\"" + (prefix_caching ? "True" : "False") +
"\",prefix_cache_mib=\"" + std::to_string(prefix_cache_mib) + "\"}";
}
void Metrics::observe_request(int64_t n_prompt, int64_t n_generated,
double ttft_s, double tpot_s, double e2e_s, double decode_s,
double queue_s, int n_choices, int64_t max_tokens, SuccessReason r) {
c_prompt_tokens_.inc((double)n_prompt);
c_generation_tokens_.inc((double)n_generated);
c_success_[(size_t)r].inc();
h_prompt_tokens_.observe((double)n_prompt);
h_generation_tokens_.observe((double)n_generated);
h_params_n_.observe((double)n_choices);
if (max_tokens > 0) h_params_max_tokens_.observe((double)max_tokens);
if (ttft_s >= 0.0) h_ttft_.observe(ttft_s);
/* TPOT is undefined for a one-token generation; recording a zero would drag every quantile
* down. */
if (tpot_s >= 0.0 && n_generated > 1) h_tpot_.observe(tpot_s);
if (e2e_s >= 0.0) h_e2e_.observe(e2e_s);
if (decode_s >= 0.0 && n_generated > 1) h_decode_.observe(decode_s);
if (queue_s >= 0.0) h_queue_.observe(queue_s);
}
void Metrics::observe_rejected() { c_rejected_.inc(); }
void Metrics::observe_disconnect() { c_disconnect_.inc(); }
void Metrics::observe_overflow() { c_overflow_.inc(); }
void Metrics::observe_http(int status) {
if (status >= 500) c_http_5xx_.inc();
else if (status >= 400) c_http_4xx_.inc();
else c_http_2xx_.inc();
}
void Metrics::sample(const SchedMetrics& m) {
std::lock_guard<std::mutex> lk(sample_mu_);
g_running_.set((double)m.running);
g_waiting_.set((double)m.waiting);
g_preempted_.set((double)m.preempted);
g_kv_util_.set(m.kv_util);
g_kv_max_tokens_.set((double)m.kv_tokens_max);
g_kv_max_bytes_.set((double)m.kv_bytes_carved);
g_kv_resident_blocks_.set((double)m.kv_resident_blocks);
g_prefix_hit_.set(m.prefix_hit_rate);
g_prefill_tps_.set(m.prefill_tps);
g_decode_tps_.set(m.decode_tps);
g_draft_accept_.set(m.draft_acceptance);
/* Nanoseconds in the scheduler, seconds on the wire, as engine_step_seconds_* use. */
g_step_best_.set((double)m.step_ns_decode_best / 1e9);
g_step_recent_.set((double)m.step_ns_decode_recent / 1e9);
g_mixed_step_target_cap_.set((double)m.mixed_step_target_prefill_cap);
const int seen = std::max(0, std::min(m.draft_depth_seen, (int)MAX_DRAFT_POS));
for (int j = 0; j < seen; ++j) {
const int64_t r = m.draft_pos_reached[j];
g_draft_pos_reached_[j].set((double)r);
g_draft_pos_accepted_[j].set((double)m.draft_pos_accepted[j]);
g_draft_pos_[j].set(r ? (double)m.draft_pos_accepted[j] / (double)r : 0.0);
}
/* Published after the gauges it bounds, so a concurrent render never lists a position whose
* gauge has not been written yet. */
draft_pos_seen_.store(seen, std::memory_order_release);
if (m.draft_adaptive) {
g_draft_depth_adapt_.set(m.draft_depth_adaptive);
int top = 0;
for (int d = 1; d <= (int)MAX_DRAFT_POS; ++d) {
g_draft_vdepth_[d].set((double)m.draft_verify_depth[d]);
if (m.draft_verify_depth[d] > 0) top = d;
}
/* After the gauges, for the reason above. */
draft_vdepth_top_.store(top, std::memory_order_release);
draft_adapt_on_.store(true, std::memory_order_release);
}
c_preemptions_.advance_to(m.preemptions);
c_preempt_forced_.advance_to(m.preempt_forced);
c_steps_.advance_to(m.steps);
c_steps_prefill_.advance_to(m.steps_prefill);
c_steps_mixed_.advance_to(m.steps_mixed);
c_steps_decode_.advance_to(m.steps_decode);
c_steps_ahead_.advance_to(m.steps_ahead);
c_prefill_capped_.advance_to(m.prefill_chunks_capped);
c_steps_held_.advance_to(m.steps_held);
c_mixed_step_target_steps_.advance_to(m.mixed_step_target_steps);
c_mixed_step_target_misses_.advance_to(m.mixed_step_target_misses);
c_rows_unspec_.advance_to(m.decode_rows_unspeculated);
c_step_secs_.advance_to((double)m.step_ns * 1e-9);
c_step_secs_decode_.advance_to((double)m.step_ns_decode * 1e-9);
c_prefill_tokens_.advance_to(m.prefill_tokens);
c_decode_tokens_.advance_to(m.decode_tokens);
c_draft_tokens_.advance_to(m.draft_tokens);
c_draft_accepted_.advance_to(m.draft_accepted);
c_draft_refills_.advance_to(m.draft_refills);
c_draft_refill_tokens_.advance_to(m.draft_refill_tokens);
c_window_seed_failures_.advance_to(m.window_seed_failures);
c_draft_window_stale_ckpts_.advance_to(m.draft_window_stale_ckpts);
c_draft_gated_steps_.advance_to(m.draft_gated_steps);
c_draft_acc_gated_steps_.advance_to(m.draft_acc_gated_steps);
c_draft_reach_declined_steps_.advance_to(m.draft_reach_declined_steps);
g_draft_spec_off_seqs_.set((double)m.draft_spec_off_seqs);
c_lookup_proposals_.advance_to(m.lookup_proposals);
c_lookup_held_.advance_to(m.lookup_held);
c_lookup_held_drafts_.advance_to(m.lookup_held_drafts);
c_lookup_held_hits_.advance_to(m.lookup_held_hits);
c_suffix_steps_.advance_to(m.suffix_steps);
c_suffix_rows_.advance_to(m.suffix_rows);
c_suffix_accepted_.advance_to(m.suffix_accepted);
c_suffix_held_ahead_.advance_to(m.suffix_held_ahead);
c_draft_zero_cycles_.advance_to(m.draft_zero_cycles);
c_draft_probe_cycles_.advance_to(m.draft_probe_cycles);
c_draft_zero_moves_.advance_to(m.draft_zero_moves);
c_hybrid_lookup_.advance_to(m.hybrid_lookup);
c_hybrid_head_.advance_to(m.hybrid_head);
c_hybrid_unahead_.advance_to(m.hybrid_unahead);
c_attn_cached_.advance_to(m.attn_cached_tokens);
c_linear_cached_.advance_to(m.linear_cached_tokens);
c_prefix_queries_.advance_to(m.prefix_queries);
c_checkpoints_.advance_to(m.checkpoints_written);
/* The cache's own cumulative counts, turned into deltas like the others. */
c_prefix_evict_.advance_to(m.prefix_evictions);
c_prefix_ckpt_evict_.advance_to(m.prefix_ckpt_evictions);
c_prefix_expired_.advance_to(m.prefix_expired);
c_prefix_ckpt_expired_.advance_to(m.prefix_ckpt_expired);
c_prefix_released_.advance_to(m.prefix_released);
c_prefix_ckpt_released_.advance_to(m.prefix_ckpt_released);
c_ckpt_retired_.advance_to(m.prefix_ckpt_retired);
c_ckpt_lru_.advance_to(m.prefix_ckpt_lru);
c_ckpt_refused_.advance_to(m.prefix_ckpt_refused);
c_cut_no_snapshot_.advance_to(m.hit_cut_no_snapshot);
c_cut_window_.advance_to(m.hit_cut_window);
c_cut_adopt_.advance_to(m.hit_cut_adopt);
c_cut_resumed_below_.advance_to(m.hit_cut_resumed_below);
c_restore_cuts_.advance_to(m.prefix_restore_cuts);
c_cut_tokens_.advance_to(m.hit_cut_tokens);
c_kv_stream_misses_.advance_to((double)m.kv_stream_misses);
c_kv_stream_bytes_.advance_to((double)m.kv_stream_bytes_in);
g_linear_hit_.set(m.linear_hit_rate);
}
/* ------------------------------------------------------------------ exposition */
namespace {
/* Prometheus wants a bare decimal; %g would emit "1e+06" for a bucket bound, which parses, and
* "inf" for +Inf, which does not. 17 significant digits round-trips a double exactly. */
std::string num(double v) {
if (std::isinf(v)) return v > 0 ? "+Inf" : "-Inf";
if (v == (double)(long long)v && std::fabs(v) < 1e15) {
char b[32];
snprintf(b, sizeof b, "%lld", (long long)v);
return b;
}
char b[64];
snprintf(b, sizeof b, "%.17g", v);
return b;
}
struct Writer {
std::string out;
void help(const char* name, const char* doc, const char* type) {
out += "# HELP "; out += name; out += ' '; out += doc; out += '\n';
out += "# TYPE "; out += name; out += ' '; out += type; out += '\n';
}
void gauge(const char* name, const char* doc, const std::string& labels, double v) {
help(name, doc, "gauge");
out += name; out += labels; out += ' '; out += num(v); out += '\n';
}
void counter(const char* name, const char* doc, const std::string& labels, double v) {
/* The _total suffix is part of the exposed family name for a counter, which is what the
* Python client does and therefore what the dashboards match on. */
help(name, doc, "counter");
out += name; out += labels; out += ' '; out += num(v); out += '\n';
}
/* The buckets in ascending order, then the count once for both +Inf and _count, the order
* Histogram::observe makes consistent. */
void hist(const char* name, const char* doc, const std::string& labels, const Histogram& h) {
help(name, doc, "histogram");
for (size_t i = 0; i < h.bounds().size(); ++i) {
out += name; out += "_bucket";
out += labels.substr(0, labels.size() - 1); /* drop the closing brace */
out += ",le=\""; out += num(h.bounds()[i]); out += "\"} ";
out += num((double)h.bucket(i)); out += '\n';
}
const double n = (double)h.count();
out += name; out += "_bucket";
out += labels.substr(0, labels.size() - 1);
out += ",le=\"+Inf\"} ";
out += num(n); out += '\n';
out += name; out += "_sum"; out += labels; out += ' '; out += num(h.sum()); out += '\n';
out += name; out += "_count"; out += labels; out += ' ';
out += num(n); out += '\n';
}
};
} /* namespace */
std::string Metrics::render() const {
Writer w;
w.out.reserve(8192);
const std::string& L = labels_;
/* ---------------- vLLM-compatible: gauges ---------------- */
w.gauge("vllm:num_requests_running",
"Number of requests currently running on GPU.", L, g_running_.get());
w.gauge("vllm:num_requests_waiting",
"Number of requests waiting to be processed.", L, g_waiting_.get());
w.gauge("vllm:gpu_cache_usage_perc",
"GPU KV-cache usage. 1 means 100 percent usage.", L, g_kv_util_.get());
w.gauge("vllm:kv_cache_usage_perc",
"KV-cache usage. 1 means 100 percent usage.", L, g_kv_util_.get());
w.gauge("radiance:kv_cache_max_tokens",
"Tokens of context the KV cache holds with every block it lends the experts taken "
"back.", L, g_kv_max_tokens_.get());
w.gauge("radiance:kv_cache_max_bytes",
"VRAM the KV cache holds with every block it lends the experts taken back, one card.",
L, g_kv_max_bytes_.get());
w.gauge("radiance:kv_resident_blocks",
"Blocks of every streamed KV group the device ring holds; 0 when no group streams.",
L, g_kv_resident_blocks_.get());
w.counter("radiance:kv_stream_misses_total",
"Blocks copied into a streamed KV group's ring from the host mirror.",
L, c_kv_stream_misses_.get());
/* Labelled by direction; the resolve only copies in. */
w.help("radiance:kv_stream_bytes_total",
"Bytes a streamed KV group's resolve moved, by direction.", "counter");
w.out += "radiance:kv_stream_bytes_total";
w.out += L.substr(0, L.size() - 1);
w.out += ",dir=\"in\"} ";
w.out += num(c_kv_stream_bytes_.get());
w.out += '\n';
w.gauge("vllm:gpu_prefix_cache_hit_rate",
"GPU prefix cache block hit rate.", L, g_prefix_hit_.get());
/* The same as counters, which sum over time and across instances where the gauge cannot.
* Hits are the tokens a request did not compute again: on a hybrid model the checkpoint it
* resumed from bounds them, not the attention blocks found. */
w.counter("vllm:prefix_cache_queries_total",
"Prompt tokens of admitted requests, each looked up in the prefix cache.",
L, c_prefix_queries_.get());
w.counter("vllm:prefix_cache_hits_total",
"Prompt tokens served from the prefix cache instead of computed.",
L, c_linear_cached_.get());
if (!cache_labels_.empty())
w.gauge("vllm:cache_config_info", "The KV cache's settings, as labels.", cache_labels_, 1.0);
/* ---------------- vLLM-compatible: counters ---------------- */
w.counter("vllm:prompt_tokens_total",
"Number of prefill tokens processed.", L, c_prompt_tokens_.get());
w.counter("vllm:generation_tokens_total",
"Number of generation tokens processed.", L, c_generation_tokens_.get());
w.counter("vllm:num_preemptions_total",
"Cumulative number of preemptions from the engine.", L, c_preemptions_.get());
w.counter("radiance:preempt_forced_total",
"Preempted prefill waits that ended by reclaiming cache blocks and forcing a "
"lowest-priority running victim (--preempt-wait-ms).", L, c_preempt_forced_.get());
w.help("vllm:request_success_total",
"Count of successfully processed requests.", "counter");
for (size_t i = 0; i < (size_t)SuccessReason::N_; ++i) {
w.out += "vllm:request_success_total";
w.out += L.substr(0, L.size() - 1);
w.out += ",finished_reason=\"";
w.out += reason_str((SuccessReason)i);
w.out += "\"} ";
w.out += num(c_success_[i].get());
w.out += '\n';
}
/* ---------------- vLLM-compatible: histograms ---------------- */
w.hist("vllm:time_to_first_token_seconds",
"Histogram of time to first token in seconds.", L, h_ttft_);
w.hist("vllm:time_per_output_token_seconds",
"Histogram of time per output token in seconds.", L, h_tpot_);
/* Current vLLM's name for the same measurement; both spellings are emitted. */
w.hist("vllm:inter_token_latency_seconds",
"Histogram of inter-token latency in seconds.", L, h_tpot_);
w.hist("vllm:e2e_request_latency_seconds",
"Histogram of end to end request latency in seconds.", L, h_e2e_);
w.hist("vllm:request_decode_time_seconds",
"Histogram of time spent in the decode phase, in seconds.", L, h_decode_);
w.hist("vllm:request_queue_time_seconds",
"Histogram of time a request waited before the scheduler admitted it, in seconds.",
L, h_queue_);
w.hist("vllm:request_prompt_tokens",
"Number of prefill tokens processed.", L, h_prompt_tokens_);
w.hist("vllm:request_generation_tokens",
"Number of generation tokens processed.", L, h_generation_tokens_);
w.hist("vllm:request_params_n",
"Histogram of the n request parameter.", L, h_params_n_);
w.hist("vllm:request_params_max_tokens",
"Histogram of the max_tokens request parameter.", L, h_params_max_tokens_);
/* ---------------- radiance-specific ----------------
* Under our own prefix, never under vllm:. */
w.gauge("radiance:prefill_tokens_per_second",
"Prefill throughput over the scheduler's recent window.", L, g_prefill_tps_.get());
w.gauge("radiance:decode_tokens_per_second",
"Decode throughput over the scheduler's recent window.", L, g_decode_tps_.get());
/* The decode floor the dashboard's step tile shows. Each series is omitted until its window
* has been measured, because a 0-second step would plot as the fastest ever. */
if (g_step_best_.get() > 0)
w.gauge("radiance:decode_step_seconds_best",
"Fastest single-sequence decode window this process has run, in seconds per "
"step: the mean of 32 consecutive single-stream steps. With speculation a step "
"emits 1 + accepted tokens. Resets on restart.", L, g_step_best_.get());
if (g_step_recent_.get() > 0)
w.gauge("radiance:decode_step_seconds_recent",
"Most recent single-sequence decode window, in seconds per step (see _best). "
"Holds its value while no single-stream window completes.",
L, g_step_recent_.get());
w.counter("radiance:engine_steps_total",
"Scheduler steps executed. One forward pass of the model, plus whatever draft "
"rounds followed it; with speculation a step emits more than one token.",
L, c_steps_.get());
/* Steps by shape, and how much of the decode ran unspeculated.
* `radiance:decode_rows_unspeculated_total` counts rows that took no draft for any reason
* (depth 0, a request that may not speculate, a drafter with nothing to propose); its rate
* against engine_steps_total shows how much of the decode speculation misses. */
w.counter("radiance:engine_steps_prefill_total",
"Scheduler steps carrying only prefill chunks.", L, c_steps_prefill_.get());
w.counter("radiance:engine_steps_mixed_total",
"Scheduler steps carrying both a prefill chunk and a decode row.",
L, c_steps_mixed_.get());
w.counter("radiance:engine_steps_decode_total",
"Scheduler steps carrying only decode rows.", L, c_steps_decode_.get());
w.counter("radiance:engine_steps_ahead_total",
"Steps whose forward pass was issued behind the step before, ahead of its commit.",
L, c_steps_ahead_.get());
w.counter("radiance:engine_prefill_chunks_capped_total",
"Prefill chunks held back so decode rows and waiting requests got into the step "
"(--busy-prefill-chunk).",
L, c_prefill_capped_.get());
w.counter("radiance:engine_steps_held_total",
"Decode-only steps run after a prefill chunk while other sequences decode "
"(--prefill-interleave).", L, c_steps_held_.get());
w.counter("radiance:mixed_step_target_steps_total",
"Mixed prefill/decode steps observed by --mixed-step-target-ms.",
L, c_mixed_step_target_steps_.get());
w.counter("radiance:mixed_step_target_misses_total",
"Mixed steps whose completed service time exceeded --mixed-step-target-ms.",
L, c_mixed_step_target_misses_.get());
if (g_mixed_step_target_cap_.get() > 0)
w.gauge("radiance:mixed_step_target_prefill_cap",
"Current learned prefill-row cap used while decode sequences are active.",
L, g_mixed_step_target_cap_.get());
w.counter("radiance:decode_rows_unspeculated_total",
"Decode rows that took no draft, for any reason.",
L, c_rows_unspec_.get());
/* Step time as a counter. Divided by engine_steps_decode_total it gives the cost of a decode
* step; wall clock over a step count does so only for a saturated window with no prefill. */
w.counter("radiance:engine_step_seconds_total",
"Seconds spent inside a scheduler step, all shapes.", L, c_step_secs_.get());
w.counter("radiance:engine_step_seconds_decode_total",
"Seconds spent inside a scheduler step carrying only decode rows.",
L, c_step_secs_decode_.get());
/* Exact totals beside the rate gauges. Two runs with different prefill/decode mixes have
* incomparable rates but comparable totals. vllm:generation_tokens_total is charged when a
* request finishes, so it reads zero over a window in which nothing finishes; these are
* charged per step. */
w.counter("radiance:prefill_tokens_total",
"Prompt tokens the engine has computed, exact.", L, c_prefill_tokens_.get());
w.counter("radiance:decode_tokens_total",
"Tokens the engine has generated, exact, counted when the step commits rather "
"than when the request finishes.", L, c_decode_tokens_.get());
w.counter("radiance:draft_tokens_total",
"Speculative tokens proposed.", L, c_draft_tokens_.get());
w.counter("radiance:draft_accepted_total",
"Speculative tokens accepted; the pair the acceptance ratio is computed from.",
L, c_draft_accepted_.get());
w.counter("radiance:draft_refills_total",
"Prefix hits ended a drafter window early so a windowed block drafter has context.",
L, c_draft_refills_.get());
w.counter("radiance:draft_refill_tokens_total",
"Cached prompt tokens those hits gave back to be recomputed.",
L, c_draft_refill_tokens_.get());
w.counter("radiance:prefix_window_seed_failures_total",
"Prefix hits dropped because the window blocks a checkpoint restore needs were not free.",
L, c_window_seed_failures_.get());
w.counter("radiance:draft_window_stale_ckpt_total",
"Checkpoints not committed because the drafter's window could not be saved in them (no drafter context pass behind the step, or its window rows were not held); a later request recomputes instead of resuming there.",
L, c_draft_window_stale_ckpts_.get());
w.counter("radiance:draft_gated_steps_total",
"Steps the block drafter did not draft because more sequences decoded than --draft-max-lanes.",
L, c_draft_gated_steps_.get());
w.counter("radiance:draft_acc_gated_steps_total",
"Sequence-steps the block drafter did not propose for a sequence whose acceptance fell below --draft-min-accept.",
L, c_draft_acc_gated_steps_.get());
w.counter("radiance:draft_reach_declined_steps_total",
"Sequence-steps the block drafter did not propose because the sequence's draft cache has a hole a prefix-cache hit left and the drafter's window has not yet slid past it.",
L, c_draft_reach_declined_steps_.get());
w.gauge("radiance:draft_spec_off_sequences",
"Running sequences the block drafter is stopped for under --draft-min-accept right now.",
L, g_draft_spec_off_seqs_.get());
w.counter("radiance:lookup_proposals_total",
"Prompt-lookup proposals made, with prompt lookup the only drafter.",
L, c_lookup_proposals_.get());
w.counter("radiance:lookup_held_total",
"Prompt-lookup proposals held back unverified: not expected to pay for their "
"verify rows at the measured step cost.", L, c_lookup_held_.get());
w.counter("radiance:lookup_held_drafts_total",
"Drafts in the held-back proposals.", L, c_lookup_held_drafts_.get());
w.counter("radiance:lookup_held_hits_total",
"Of the held-back proposals scored against the text that followed, the drafts "
"that came true: what verifying them would have accepted.",
L, c_lookup_held_hits_.get());
w.counter("radiance:suffix_steps_total",
"Verify steps that carried a --draft-suffix chain of the sequence's own history.",
L, c_suffix_steps_.get());
w.counter("radiance:suffix_rows_total",
"Draft rows those suffix steps verified.", L, c_suffix_rows_.get());
w.counter("radiance:suffix_accepted_total",
"Of those rows, the drafts accepted.", L, c_suffix_accepted_.get());
w.counter("radiance:suffix_held_ahead_total",
"Decode steps not issued ahead of the previous commit because the sequence's "
"history ended in a recurring pattern (--draft-suffix).", L, c_suffix_held_ahead_.get());
/* Depth 0 and the hybrid (--draft-depth0 / --draft-hybrid), once either acted. */
if (c_draft_zero_cycles_.get() > 0 || c_draft_probe_cycles_.get() > 0 ||
c_draft_zero_moves_.get() > 0) {
w.counter("radiance:draft_zero_cycles_total",
"Cycles the adaptive window ran at depth 0: no head pass, no verify row.",
L, c_draft_zero_cycles_.get());
w.counter("radiance:draft_probe_cycles_total",
"Probe cycles of depth 0: the drafting depth from 0, or plain steps measured "
"while drafting.", L, c_draft_probe_cycles_.get());
w.counter("radiance:draft_zero_moves_total",
"Moves between depth 0 and the drafting depth.", L, c_draft_zero_moves_.get());
}
if (c_hybrid_lookup_.get() > 0 || c_hybrid_head_.get() > 0 || c_hybrid_unahead_.get() > 0) {
w.counter("radiance:draft_hybrid_lookup_total",
"Proposals the hybrid took from prompt lookup over the head's (a long match).",
L, c_hybrid_lookup_.get());
w.counter("radiance:draft_hybrid_head_total",
"Proposals the hybrid left to the head.", L, c_hybrid_head_.get());
w.counter("radiance:draft_hybrid_unahead_total",
"Steps the hybrid kept from issuing ahead: a running sequence matched long.",
L, c_hybrid_unahead_.get());
}
/* Decoupled prefix caching (spec §7.3). vllm:gpu_prefix_cache_hit_rate is the attention hit
* rate, as in vLLM. The linear side hits at a different granularity (whole checkpoints, not
* blocks), so it is reported separately rather than averaged in. */
w.gauge("radiance:linear_prefix_cache_hit_rate",
"Fraction of prompt tokens served from a linear-state checkpoint (spec 7.3).",
L, g_linear_hit_.get());
w.counter("radiance:attn_cached_tokens_total",
"Prompt tokens served from the paged attention prefix cache.", L, c_attn_cached_.get());
w.counter("radiance:linear_cached_tokens_total",
"Prompt tokens served from a linear-state checkpoint.", L, c_linear_cached_.get());
w.counter("radiance:linear_checkpoints_written_total",
"Linear-state checkpoints written.", L, c_checkpoints_.get());
/* Leading indicator of prefix-cache collapse: the hit rate falls only after a reusable prefix
* is gone, while evictions rise as it is dropped. Above ~75% pool utilisation the cache
* starts evicting prefixes the next turn wants. */
w.counter("radiance:prefix_cache_evictions_total",
"Prefix-cache entries evicted (attention blocks).", L, c_prefix_evict_.get());
w.counter("radiance:prefix_cache_ckpt_evictions_total",
"Prefix-cache linear-state checkpoints evicted.", L, c_prefix_ckpt_evict_.get());
w.counter("radiance:prefix_cache_expired_total",
"Prefix-cache entries no request used for --prefix-cache-ttl, taken out.", L,
c_prefix_expired_.get());
w.counter("radiance:prefix_cache_ckpt_expired_total",
"Prefix-cache linear-state checkpoints taken out by --prefix-cache-ttl.", L,
c_prefix_ckpt_expired_.get());
/* Why snapshots went, and why hits were cut: a hybrid server that re-prefills long prompts
* shows it here before the linear hit rate says so. */
{
const std::string base = L.substr(0, L.size() - 1);
auto labelled = [&](const char* name, const char* label, const char* value, double v) {
w.out += name; w.out += base; w.out += ','; w.out += label; w.out += "=\"";
w.out += value; w.out += "\"} "; w.out += num(v); w.out += '\n';
};
w.help("radiance:prefix_cache_ckpt_evictions_by_reason_total",
"Linear-state checkpoints evicted, by reason: released by --checkpoint-policy, or "
"the least recently used of a store retention left full.", "counter");
labelled("radiance:prefix_cache_ckpt_evictions_by_reason_total", "reason", "retention",
c_ckpt_retired_.get());
labelled("radiance:prefix_cache_ckpt_evictions_by_reason_total", "reason", "store_full",
c_ckpt_lru_.get());
w.help("radiance:prefix_cache_released_total",
"Prefix-cache entries and linear-state snapshots a client released on purpose "
"(DELETE /sessions).", "counter");
labelled("radiance:prefix_cache_released_total", "what", "entries",
c_prefix_released_.get());
labelled("radiance:prefix_cache_released_total", "what", "snapshots",
c_prefix_ckpt_released_.get());
w.counter("radiance:prefix_cache_ckpt_refused_total",
"Checkpoints not written because every snapshot slot was in use by a restore "
"in the same step.", L, c_ckpt_refused_.get());
w.help("radiance:prefix_hit_cuts_total",
"Admissions whose prefix hit was cut, by reason: reused nothing for want of a "
"snapshot at or below the hit, for a windowed group no window snapshot covers, or "
"for blocks that could not be adopted; or resumed at a snapshot more than one "
"checkpoint interval below the hit.", "counter");
labelled("radiance:prefix_hit_cuts_total", "reason", "no_snapshot",
c_cut_no_snapshot_.get());
labelled("radiance:prefix_hit_cuts_total", "reason", "windowed_group", c_cut_window_.get());
labelled("radiance:prefix_hit_cuts_total", "reason", "adopt_failed", c_cut_adopt_.get());
labelled("radiance:prefix_hit_cuts_total", "reason", "resumed_below",
c_cut_resumed_below_.get());
w.counter("radiance:prefix_restore_cuts_total",
"Restores from the host tier the pool could not hold whole, even after giving "
"up the VRAM copies of other stored conversations; each came back only in "
"part, on a model with recurrent state up to the deepest snapshot the room "
"reaches.", L, c_restore_cuts_.get());
w.counter("radiance:prefix_hit_cut_tokens_total",
"Prompt tokens the attention cache held and admission computed again, because "
"the hit resumed at a snapshot below it or reused nothing.", L,
c_cut_tokens_.get());
}
w.gauge("radiance:draft_acceptance_ratio",
"Fraction of speculative draft tokens accepted.", L, g_draft_accept_.get());
/* Conditional acceptance per draft position: of the verifies that reached position j (every
* earlier one accepted), the fraction that took j too. Unlike the pooled ratio, this tells a
* drafter that decays from one whose later rounds are broken. `_reached_total` is the evidence
* per position; `_accepted_total` gives the ratio over any window (an adaptive window can end
* at j with j taken, so the next position's reach is not enough). */
const int seen = draft_pos_seen_.load(std::memory_order_acquire);
if (seen > 0) {
const std::string base = L.substr(0, L.size() - 1);
w.help("radiance:draft_position_acceptance_ratio",
"Conditional acceptance at each draft position, given every earlier one was taken.",
"gauge");
for (int j = 0; j < seen; ++j)
w.out += "radiance:draft_position_acceptance_ratio" + base + ",position=\"" +
std::to_string(j) + "\"} " + num(g_draft_pos_[j].get()) + '\n';
w.help("radiance:draft_position_reached_total",
"Verifies that evaluated each draft position.", "counter");
for (int j = 0; j < seen; ++j)
w.out += "radiance:draft_position_reached_total" + base + ",position=\"" +
std::to_string(j) + "\"} " + num(g_draft_pos_reached_[j].get()) + '\n';
w.help("radiance:draft_position_accepted_total",
"Verifies that accepted each draft position.", "counter");
for (int j = 0; j < seen; ++j)
w.out += "radiance:draft_position_accepted_total" + base + ",position=\"" +
std::to_string(j) + "\"} " + num(g_draft_pos_accepted_[j].get()) + '\n';
}
/* Adaptive draft window, only under --draft-window adaptive: the current mean window (at one
* sequence, that sequence's window) and its history as verifies by drafts carried. */
if (draft_adapt_on_.load(std::memory_order_acquire)) {
w.gauge("radiance:draft_depth_adaptive",
"Mean draft window the adaptive policy gives the running sequences.",
L, g_draft_depth_adapt_.get());
const int top = draft_vdepth_top_.load(std::memory_order_acquire);
if (top > 0) {
const std::string base = L.substr(0, L.size() - 1);
w.help("radiance:draft_verify_depth_total",
"Verifies by the number of drafts they carried, under the adaptive window.",
"counter");
for (int d = 1; d <= top; ++d)
w.out += "radiance:draft_verify_depth_total" + base + ",depth=\"" +
std::to_string(d) + "\"} " + num(g_draft_vdepth_[d].get()) + '\n';
}
}
w.gauge("radiance:num_requests_preempted",
"Requests currently preempted and awaiting recompute.", L, g_preempted_.get());
w.gauge("radiance:http_queue_depth",
"Requests admitted by the HTTP layer and not yet finished.", L, queue_depth_.get());
w.counter("radiance:http_admission_rejected_total",
"Requests refused with 429 because the admission queue was full.",
L, c_rejected_.get());
w.counter("radiance:client_disconnect_total",
"Streams cancelled because the client went away.", L, c_disconnect_.get());
w.counter("radiance:stream_overflow_total",
"Requests failed because the HTTP reader could not drain the sink.",
L, c_overflow_.get());
w.help("radiance:http_responses_total", "HTTP responses by status class.", "counter");
w.out += "radiance:http_responses_total" + L.substr(0, L.size() - 1) + ",class=\"2xx\"} "
+ num(c_http_2xx_.get()) + '\n';
w.out += "radiance:http_responses_total" + L.substr(0, L.size() - 1) + ",class=\"4xx\"} "
+ num(c_http_4xx_.get()) + '\n';
w.out += "radiance:http_responses_total" + L.substr(0, L.size() - 1) + ",class=\"5xx\"} "
+ num(c_http_5xx_.get()) + '\n';
return w.out;
}
} /* namespace server */
} /* namespace rad */