Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ebecef1
Add request latency histograms and process metrics
WynnD Nov 26, 2026
d64c3ea
Exclude cancelled responses and reuse host helpers
WynnD Nov 27, 2026
a34c4d0
Hoist completion values and tighten stat parsing
WynnD Nov 27, 2026
54e06b3
Remove process metrics from the request latency change
WynnD Nov 27, 2026
10c0b93
Add per-request histograms that match vLLM's request metrics
WynnD Nov 27, 2026
01f1e92
Count lookup tokens, output-limit stops, parked requests, and queue r…
WynnD Nov 27, 2026
1501868
Document how Flare's metrics correspond to vLLM's
WynnD Nov 27, 2026
49373bc
State request-histogram populations from the code and drop duplicate …
WynnD Nov 27, 2026
055663a
Place request-histogram docs and test rows apart from the KV-page gauges
WynnD Nov 28, 2026
6624592
Reuse GraphKind::samples for model-step metrics and stamp scheduled t…
WynnD Nov 28, 2026
fb50f07
Render every observed histogram through Histogram
WynnD Nov 28, 2026
ba1bc41
Exclude only tool-limit-cancelled choices from HTTP response histograms
WynnD Nov 28, 2026
6b736d2
Skip idle model steps, bind admission labels to their enum, and trim …
WynnD Nov 28, 2026
3b1ebbf
Report the first scheduled model step in Chat performance
WynnD Nov 27, 2026
d277c12
Report vLLM per-request metrics from runtime instants
WynnD Nov 27, 2026
65116f5
Report the content-token instant of per-request metrics as null
WynnD Nov 28, 2026
3320a72
Export RequestTimes and report the earliest first scheduled step
WynnD Nov 28, 2026
8be24e2
Read per-request metrics from the [server] configuration
WynnD Nov 28, 2026
cad6bf0
State the per-request metrics boundaries and the include_usage gap
WynnD Nov 28, 2026
80b4cfb
Accept [server] per_request_metrics in the Ignition configuration
WynnD Nov 28, 2026
696082b
Document where Orbit reads per_request_metrics and that the flag only…
WynnD Nov 28, 2026
0f6cd4f
Define the per-request metrics null cases and token timestamps in the…
WynnD Nov 28, 2026
e3829e6
Share the step-generates test predicate and trim encoder metrics comm…
WynnD Nov 28, 2026
3e8fd28
Report the first content token of per-request metrics in streams
WynnD Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 172 additions & 4 deletions docs/api.md

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions docs/cli-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ defaulting to `~/.config/flare/orbit.toml` and
`~/.config/flare/orbit/controller.key`. `flare orbit run` takes the serving
flags of `flare run` and applies them to every rank; `--host`, `--port`,
`--served-model-name`, `--scheduler-policy`, `--scheduler-terminal-value`,
`--scheduler-terminal-age-price`, and `--api-key-file` apply to rank zero. `--api-key-file` names a file rank zero must be able to read; Orbit does
`--scheduler-terminal-age-price`, `--api-key-file`, and `--enable-per-request-metrics` apply to rank zero. `--api-key-file` names a file rank zero must be able to read; Orbit does
not upload it. Core inputs are Hugging Face repositories
`ORG/NAME[@REVISION]`, controller-local files, or `NODE:/absolute/path` on a
paired node. Orbit downloads repository cores on a candidate node and
Expand Down Expand Up @@ -733,6 +733,7 @@ Help exits with status 0; usage errors go to stderr with status 2. Its options a
| `--port N` | Listener port | `[server] port`, otherwise `8000` |
| `--served-model-name ALIAS` | Replace the core's serving aliases with this nonblank alias | Core aliases |
| `--api-key-file PATH` | File containing the serving API key; an empty file disables authentication | `[server] api_key`, otherwise no authentication |
| `--enable-per-request-metrics` | Add vLLM's per-request `metrics` timing object to OpenAI Chat, Completions, and Responses output; see [per-request metrics](api.md#per-request-metrics). The flag can only enable the option; `[server] per_request_metrics` sets it per host | `[server] per_request_metrics`, read on rank zero's node under `flare orbit run`, otherwise off |
| `--max-concurrency N` | Reduce concurrency within captured batch capacities | Model/default configuration, otherwise core default |
| `--kv-cache-limit concurrency\|context\|memory` | Bound shared KV history by prepared context times selected concurrency, one prepared context, or available memory | `memory` |
| `--memory-limit LIMIT` | Per-GPU occupied size (`30G`), free-memory reserve (`-30G`, including `-0G`), or fraction of total memory (`0.8`) | `[memory] reserve`, otherwise core serving reserve |
Expand Down Expand Up @@ -1314,7 +1315,7 @@ An absent default file supplies no overrides; an explicitly selected missing
file or an invalid runtime setting is an error. Help does not read the file.

Native `flare run` applies `[server] host`, `port`, `api_key`, `thinking_token_budget`,
and `scheduler_checkpoint_extra_work_fraction`,
`scheduler_checkpoint_extra_work_fraction`, and `per_request_metrics`,
`[memory] reserve`, `[defaults] max_concurrency`, `[models.<name>] max_concurrency`, all `[prefix_cache]`
settings, and `[paths] prefix_cache`. Prepared-model acquisition and cache commands
use `[paths] core_cache`. Flags override these defaults, including explicit
Expand Down Expand Up @@ -1345,6 +1346,7 @@ port = 8000
api_key = "" # Empty: no authentication.
# thinking_token_budget = 1536 # Optional default reasoning-token cap.
# scheduler_checkpoint_extra_work_fraction = 0.05 # Fraction of productive work for extra captures.
# per_request_metrics = false # Add vLLM's per-request `metrics` to OpenAI output.

[defaults]
model = "qwen3.8-flash"
Expand Down Expand Up @@ -1380,7 +1382,9 @@ export_staging = "" # Rank files an export assembles from; empty:
cuda = "/opt/cuda" # Explicit CUDA toolkit directory for native builds.
```

Ignition rejects any section or key outside its schema. Native Flare ignores
Ignition rejects any section or key outside its schema. `ignition debug-serve`
applies `[server] thinking_token_budget`, `scheduler_checkpoint_extra_work_fraction`,
and `per_request_metrics` as native `flare run` does. Native Flare ignores
keys it does not use, except in `[prefix_cache]`, where it accepts only `memory`,
`disk_limit`, `drain_on_shutdown`, `max_age`, and `compression`.

Expand Down
41 changes: 41 additions & 0 deletions flare-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ impl OrbitPush {
scheduler_terminal_age_price: None,
scheduler_checkpoint_extra_work_fraction: None,
bypass_performance_check: false,
enable_per_request_metrics: false,
serving: self.serving.clone(),
}
}
Expand Down Expand Up @@ -642,6 +643,11 @@ pub struct OrbitRun {
#[arg(long, value_name = "PATH", help_heading = "Serving options")]
pub api_key_file: Option<PathBuf>,

/// Add vLLM's per-request `metrics` timing object to OpenAI Chat, Completions,
/// and Responses output; rank zero's [server].per_request_metrics also enables it.
#[arg(long, help_heading = "Serving options")]
pub enable_per_request_metrics: bool,

#[command(flatten)]
pub serving: ServingOptions,
}
Expand Down Expand Up @@ -689,6 +695,9 @@ impl OrbitRun {
if let Some(path) = &self.api_key_file {
options.extend(["--api-key-file".into(), path.display().to_string()]);
}
if self.enable_per_request_metrics {
options.push("--enable-per-request-metrics".into());
}
options
}

Expand Down Expand Up @@ -717,6 +726,7 @@ impl OrbitRun {
scheduler_terminal_age_price: self.scheduler_terminal_age_price,
scheduler_checkpoint_extra_work_fraction: self.scheduler_checkpoint_extra_work_fraction,
bypass_performance_check: false,
enable_per_request_metrics: self.enable_per_request_metrics,
serving: self.serving.clone(),
}
}
Expand Down Expand Up @@ -847,6 +857,11 @@ pub struct Run {
#[arg(long, help_heading = "Serving options")]
pub bypass_performance_check: bool,

/// Add vLLM's per-request `metrics` timing object to OpenAI Chat, Completions,
/// and Responses output; [server].per_request_metrics also enables it.
#[arg(long, help_heading = "Serving options")]
pub enable_per_request_metrics: bool,

#[command(flatten)]
pub serving: ServingOptions,
}
Expand Down Expand Up @@ -1360,6 +1375,32 @@ mod tests {
}
}

#[test]
fn per_request_metrics_flag_is_off_by_default_and_reaches_rank_zero() {
assert!(!run(&["flare", "run", "model"]).enable_per_request_metrics);
assert!(run(&["flare", "run", "model", "--enable-per-request-metrics"]).enable_per_request_metrics);
for enabled in [false, true] {
let mut arguments = vec!["flare", "orbit", "run", "model"];
if enabled {
arguments.push("--enable-per-request-metrics");
}
let Command::Orbit(orbit) = Cli::try_parse_from(arguments).unwrap().command else {
panic!()
};
let OrbitCommand::Run(orbit) = orbit.command else {
panic!()
};
assert_eq!(orbit.run_args().enable_per_request_metrics, enabled);
// Rank zero parses the forwarded options as `flare run` options.
let mut forwarded = vec!["flare".to_string(), "run".into(), "model".into()];
forwarded.extend(orbit.rank_zero_options());
let Command::Run(rank_zero) = Cli::try_parse_from(forwarded).unwrap().command else {
panic!()
};
assert_eq!(rank_zero.enable_per_request_metrics, enabled);
}
}

#[test]
fn persistent_orbit_options_preserve_saved_values_and_allow_explicit_defaults() {
use clap::{CommandFactory, FromArgMatches};
Expand Down
43 changes: 43 additions & 0 deletions flare-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ impl Configuration {
if run.scheduler_checkpoint_extra_work_fraction.is_none() {
run.scheduler_checkpoint_extra_work_fraction = self.server.scheduler_checkpoint_extra_work_fraction;
}
if !run.enable_per_request_metrics {
run.enable_per_request_metrics = self.server.per_request_metrics.unwrap_or(false);
}
let serving = &mut run.serving;
if serving.memory_limit.is_none() {
serving.memory_limit = size(self.memory.reserve.as_deref(), "memory.reserve")?
Expand Down Expand Up @@ -216,6 +219,46 @@ mod tests {
}
}

#[test]
fn per_request_metrics_configuration_and_flag_precedence() {
let args = ["flare", "run", "model.safetensors"];
let flag = ["flare", "run", "model.safetensors", "--enable-per-request-metrics"];
for (text, configured_only) in [
("", false),
("[server]\nper_request_metrics=true", true),
("[server]\nper_request_metrics=false", false),
] {
assert_eq!(configured(text, &args, &[]).1.enable_per_request_metrics, configured_only, "{text}");
assert!(configured(text, &flag, &[]).1.enable_per_request_metrics, "{text}");
}
}

#[test]
fn orbit_rank_zero_reads_per_request_metrics_from_its_node_configuration() {
for (text, flag, expected) in [
("", false, false),
("[server]\nper_request_metrics=true", false, true),
("[server]\nper_request_metrics=false", true, true),
] {
let mut arguments = vec!["flare", "orbit", "run", "model"];
if flag {
arguments.push("--enable-per-request-metrics");
}
let cli::Command::Orbit(orbit) = cli::Cli::try_parse_from(arguments).unwrap().command else {
panic!()
};
let cli::OrbitCommand::Run(orbit) = orbit.command else {
panic!()
};
// The Orbit agent starts rank zero as `flare run`, which applies the
// configuration file on rank zero's node.
let mut rank_zero = vec!["flare".to_string(), "run".into(), "model".into()];
rank_zero.extend(orbit.rank_zero_options());
let rank_zero: Vec<&str> = rank_zero.iter().map(String::as_str).collect();
assert_eq!(configured(text, &rank_zero, &[]).1.enable_per_request_metrics, expected, "{text}");
}
}

#[test]
fn prefix_cache_drain_on_shutdown_defaults_and_flag_precedence() {
let args = ["flare", "run", "model.safetensors"];
Expand Down
3 changes: 3 additions & 0 deletions flare-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ fn run() -> Result<std::process::ExitCode, Box<dyn std::error::Error>> {
}
config["api_key"] = key.into();
config["thinking_token_budget"] = serde_json::json!(configuration.thinking_token_budget());
if args.enable_per_request_metrics {
config["per_request_metrics"] = true.into();
}
phase.finish(config["model_id"].as_str().unwrap_or_default());
serve(owner, config, progress, cluster, routing)?;
#[cfg(unix)]
Expand Down
1 change: 1 addition & 0 deletions flare/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct Server {
pub api_key: Option<String>,
pub thinking_token_budget: Option<std::num::NonZeroU32>,
pub scheduler_checkpoint_extra_work_fraction: Option<f64>,
pub per_request_metrics: Option<bool>,
}

#[derive(Default, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions flare/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2563,6 +2563,7 @@ impl Worker {
if let Some(fraction) = self.settings.scheduler_checkpoint_extra_work_fraction {
config["scheduler_checkpoint_extra_work_fraction"] = fraction.into();
}
config["per_request_metrics"] = self.settings.per_request_metrics.into();
let mut loaded = match LoadedSession::new(owner, config) {
Ok(loaded) => loaded,
Err(error) => {
Expand Down
15 changes: 15 additions & 0 deletions flare/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct Settings {
pub publisher_keys: Vec<PathBuf>,
pub thinking_token_budget: Option<u32>,
pub scheduler_checkpoint_extra_work_fraction: Option<f64>,
pub per_request_metrics: bool,
pub prefix_cache: PrefixCacheOffload,
pub model_concurrency: std::collections::HashMap<String, usize>,
}
Expand Down Expand Up @@ -71,6 +72,19 @@ mod tests {
assert_eq!(settings.scheduler_checkpoint_extra_work_fraction, fraction);
}
}
#[test]
fn per_request_metrics_reach_application_settings() {
for (text, expected) in [
("", false),
("[server]\nper_request_metrics=true", true),
("[server]\nper_request_metrics=false", false),
] {
let configuration = Configuration::parse(text).unwrap();
let settings = Settings::resolve(configuration, Path::new("user"), Path::new("config.toml")).unwrap();
assert_eq!(settings.per_request_metrics, expected, "{text}");
}
assert!(Configuration::parse("[server]\nper_request_metrics='true'").is_err());
}

#[test]
fn conflicting_alias_defaults_are_rejected() {
Expand Down Expand Up @@ -207,6 +221,7 @@ impl Settings {
publisher_keys: Vec::new(),
thinking_token_budget,
scheduler_checkpoint_extra_work_fraction: configuration.server.scheduler_checkpoint_extra_work_fraction,
per_request_metrics: configuration.server.per_request_metrics.unwrap_or(false),
prefix_cache,
model_concurrency,
})
Expand Down
20 changes: 14 additions & 6 deletions helios/model-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,26 @@ requests read no per-token clock and emit no observation events.

Observed terminal responses include `reused_prompt_tokens` and ordinary token
usage. Timed responses also include one top-level `performance` object with
`ingress_ns`, `enqueue_ns` and `reused_prompt_tokens`. Ingress is chat-handler
entry after HTTP JSON decoding, before waiting for frontend preparation;
enqueue is immediately before submitting the prepared request to the model
queue. Both timestamps use the token timestamp origin.
`ingress_ns`, `enqueue_ns`, `first_scheduled_ns` and `reused_prompt_tokens`.
Ingress is chat-handler entry after HTTP JSON decoding, before waiting for
frontend preparation; enqueue is immediately before submitting the prepared
request to the model queue. `first_scheduled_ns` marks the earliest model step
that included the request, when the worker reserves and packs that step before
submitting it; a preempted request keeps its original value. It is null when no
model step included the request. All three timestamps use the token timestamp
origin, so `first_scheduled_ns - enqueue_ns` is the time the request waited
for its first model step and `token_timestamps_ns[0] - first_scheduled_ns` is
its time to first token.

`stream_options.include_usage=true` emits a final usage-only SSE chunk with
`choices=[]` before `[DONE]`; preceding chunks have `usage=null`. Otherwise an
observed stream includes usage on its terminal choice chunk. Observation flags
and `include_usage` accept only booleans or null; null is equivalent to false.
The response event budget includes one observation per generated token when
requested, in addition to presentation events. Observation changes no CUDA
graph, device allocation or replay ABI.
requested, in addition to presentation events, and one model-step completion
instant per generated token for a stream that reports
[per-request metrics](../docs/api.md#per-request-metrics) with a content instant.
Observation changes no CUDA graph, device allocation or replay ABI.

`stop_token_ids` and `stop_token_sequences` accept explicit vocabulary IDs.
At most sixteen sequences of at most 64 tokens are supported. Matching tokens
Expand Down
4 changes: 4 additions & 0 deletions helios/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pub struct SchedulerCapabilities {
pub struct SchedulerStats {
pub cache_lookups: u64,
pub cache_hits: u64,
/// Prompt tokens of admitted requests offered to GPU prefix lookups.
pub cache_lookup_tokens: u64,
pub reused_tokens: u64,
pub snapshot_publications: u64,
pub snapshot_evictions: u64,
Expand Down Expand Up @@ -1596,6 +1598,7 @@ impl RequestScheduler {
let AdmissionPlan { history, lookup } = plan;
// Lookups count once per admitted request, not per attempt of a waiting one.
let (hit, reused) = (lookup.checkpoint.is_some(), lookup.consumed_tokens);
let looked_up = if spec.prompt_logprobs { 0 } else { spec.prompt.len() as u64 };
let page_tokens = self.capabilities.page_tokens as u64;
if let Some(inbound) = &inbound {
let consumed = inbound.consumed_tokens;
Expand Down Expand Up @@ -1796,6 +1799,7 @@ impl RequestScheduler {
ticket.role = ticket.role.max(role);
}
self.stats.cache_lookups += u64::from(!spec.prompt_logprobs);
self.stats.cache_lookup_tokens += looked_up;
self.stats.cache_hits += u64::from(hit);
self.stats.reused_tokens += reused;
if inbound.is_none()
Expand Down
7 changes: 7 additions & 0 deletions helios/src/scheduler/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,8 @@ fn terminal_checkpoint_full_prompt_hit_restores_and_resumes_without_prefill() {
(stats.cache_lookups, stats.cache_hits, stats.reused_tokens),
(3, 2, 128)
);
// Three admitted 64-token prompts were looked up, whether or not they hit.
assert_eq!(stats.cache_lookup_tokens, 192);
assert_eq!(
(
stats.active_requests,
Expand Down Expand Up @@ -3425,11 +3427,16 @@ fn invalid_inbound_requests_reserve_nothing_and_planned_admission_matches_admit(
assert_eq!(plan.resident_tokens(), 0);
// Lookups count once per admitted request; the failed attempts above count none.
assert_eq!(scheduler.stats().cache_lookups, 0);
assert_eq!(scheduler.stats().cache_lookup_tokens, 0);
let admitted = scheduler
.admit_planned(request.clone(), plan, None)
.unwrap();
assert!(admitted.ticket.is_none());
assert_eq!(scheduler.stats().cache_lookups, 1);
assert_eq!(
scheduler.stats().cache_lookup_tokens,
request.prompt.len() as u64
);
let live = scheduler.request(admitted.handle).unwrap();
assert_eq!(live.phase, RequestPhase::Initialize);
assert_eq!(live.consumed_tokens, 0);
Expand Down
9 changes: 8 additions & 1 deletion helios/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use session::{LoadedSession, ServingSession};
pub(crate) mod token_spans;
pub use config::Bootstrap;
pub use dashboard::view;
pub use metrics::Snapshot;
pub use metrics::{RequestTimes, Snapshot};
pub use runtime::{Generation, GenerationEvent, ModelRuntime, Prompt};
pub use crate::execution::{PersistentWorkerSnapshot, WorkerState};

Expand Down Expand Up @@ -124,6 +124,9 @@ pub struct ServerConfig {
pub served_names: Vec<String>,
/// Default reasoning-token cap for conversational requests without a budget.
pub thinking_token_budget: Option<u32>,
/// Report vLLM's per-request `metrics` object on OpenAI Chat, Completions, and
/// Responses output.
pub per_request_metrics: bool,
/// Setting that raises the per-request context, appended to context rejections.
pub context_hint: String,
/// Setting that raises request or page capacity, appended to capacity rejections.
Expand All @@ -142,6 +145,7 @@ impl Default for ServerConfig {
api_key: None,
served_names: Vec::new(),
thinking_token_budget: None,
per_request_metrics: false,
context_hint: String::new(),
capacity_hint: String::new(),
scheduling_policy: crate::scheduler::PolicyConfig::default(),
Expand All @@ -167,6 +171,7 @@ struct HttpState {
ids: AtomicU64,
api_key: Option<String>,
thinking_token_budget: Option<u32>,
per_request_metrics: bool,
context_hint: String,
capacity_hint: String,
response_model: String,
Expand Down Expand Up @@ -325,6 +330,7 @@ impl Server {
ids: AtomicU64::new(1),
api_key: config.api_key.clone(),
thinking_token_budget: config.thinking_token_budget,
per_request_metrics: config.per_request_metrics,
context_hint: config.context_hint.clone(),
capacity_hint: config.capacity_hint.clone(),
response_model: models::response_name(model.config(), &config.served_names).to_owned(),
Expand Down Expand Up @@ -812,6 +818,7 @@ async fn admit_http(
Err(IngressRejection::Paused) => return http::error(protocol, StatusCode::SERVICE_UNAVAILABLE, "HTTP admission is paused"),
Ok(permit) => Arc::new(permit),
Err(IngressRejection::Full) => {
state.model.metrics().admission_rejected(metrics::AdmissionLimit::HttpSlots);
let mut message = format!(
"native HTTP admission is full: {} requests are active or queued",
state.ingress_capacity
Expand Down
Loading