Skip to main content

cherenkov/control/
stats.rs

1//! Statistics responses shared by the server and its clients.
2
3use crate::qwen4_exp::gpu::{ExpertCounters, GpuTiming, LayerStats, ReadStats};
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Snapshot<T> {
8    #[serde(flatten)]
9    pub observation: Observation,
10    #[serde(flatten)]
11    pub data: T,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct Observation {
16    pub observed_at_uptime_seconds: f64,
17    pub elapsed_seconds: f64,
18    pub gpu_timestamps_available: bool,
19    pub gpu_timing: GpuTiming,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct Summary {
24    #[serde(default)]
25    pub prefill: crate::qwen4_exp::gpu::prefill::PrefillStats,
26    pub streaming: LayerStats,
27    pub reads: ReadStats,
28    #[serde(flatten)]
29    pub rates: Rates,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct Rates {
34    pub bytes_per_second: Option<f64>,
35    pub reads_per_second: Option<f64>,
36    pub gpu_handoff_gap_fraction: Option<f64>,
37    pub gpu_stage_fraction: Option<f64>,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct Page<T> {
42    pub offset: usize,
43    pub next_offset: Option<usize>,
44    pub total: usize,
45    pub data: Vec<T>,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct Layer {
50    pub layer: usize,
51    pub name: String,
52    pub experts: usize,
53    #[serde(flatten)]
54    pub counters: ExpertCounters,
55    pub streaming: LayerStats,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct Expert {
60    pub layer: usize,
61    pub expert: usize,
62    #[serde(flatten)]
63    pub counters: ExpertCounters,
64}