Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ without the `flare_` prefix, such as `input_decoded_images_total`.
| `draft_rounds` | Request rounds that offered at least one draft | `flare_draft_request_rounds_total` |
| `active` | Model slots with a live request | `flare_active_requests` |
| `pending` | Requests waiting in the model scheduler | `flare_pending_requests` |
| `completed` | Requests whose generation completed successfully | `flare_requests_completed_total` |
| `completed` | Served HTTP and Decisions requests whose generation and output validation completed successfully; direct in-process `ModelRuntime::generate*` callers count model-generation completion | `flare_requests_completed_total` |
| `reasoning_budget_cuts` | Requests whose reasoning was closed by their hard token budget | `flare_reasoning_budget_cuts_total` |
| `failed` | Requests failed by admission, execution, grammar, or output processing | `flare_requests_failed_total` |
| `failed` | Requests failed by admission, execution, grammar, or output processing, including output-decoding rejections and terminal event-budget overflow | `flare_requests_failed_total` |
| `replay_gpu_ns` | Sum of maximum rank-local CUDA durations of completed graphs, including readiness waits | `flare_replay_gpu_nanoseconds_total` |
| `replay_readiness_wait_ns` | Exposed embedding readiness delay measured across ranks, for both RAM and disk delivery | `flare_replay_readiness_wait_nanoseconds_total` |
| `replay_readiness_samples` | Completed graphs with prepared readiness timing outputs; zero for cores without them | `flare_replay_readiness_samples_total` |
Expand All @@ -349,6 +349,13 @@ without the `flare_` prefix, such as `input_decoded_images_total`.
| `host_bytes_in` | Bytes copied from the host store into GPU pages and rows | `flare_host_cache_bytes_in_total` |
| `learned_drafter` | Boolean: the model has a learned drafter | none |

Prometheus also exports `flare_requests_cancelled_total`, which counts queued,
active, or unread served HTTP and Decisions requests cancelled or disconnected
before output validation completes, and direct in-process
`ModelRuntime::generate*` requests cancelled before model generation completes.
Each request increments at most one of `flare_requests_completed_total`,
`flare_requests_cancelled_total`, or `flare_requests_failed_total`.

GPU checkpoint retention exports `flare_checkpoint_captures_total{role}` with
`anchor`, `message`, and `endpoint` roles, and
`flare_checkpoint_skips_total{reason}` with `unknown_cost`, `work_budget`, and
Expand Down
29 changes: 20 additions & 9 deletions helios/src/server/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,10 @@ pub(super) async fn generate(
);
let submitted = if prompts.is_empty() {
Ok(vec![])
} else if continuous_usage {
state.model.generate_many_observed(prompts, observation.timestamps)
} else if observation.token_ids && size == 1 {
state
.model
.generate_observed(prompts.remove(0), observation.timestamps)
.map(|g| vec![g])
} else {
state.model.generate_many(prompts)
let observation = (continuous_usage || (observation.token_ids && size == 1))
.then_some(observation.timestamps);
state.model.generate_for_output(prompts, observation)
};
let mut generation = match submitted {
Ok(g) => g,
Expand Down Expand Up @@ -421,6 +416,8 @@ pub(super) async fn generate(
if let Some(generation) = generations[0].as_mut()
&& let Err(error) = generation.wait_for_first_token().await
{
decoders[0].abort(crate::output::Termination::ExecutionError);
generation.fail_output();
let frame = encoder.failure(&error);
yield Delivery::Failed(error, frame);
return;
Expand All @@ -441,6 +438,10 @@ pub(super) async fn generate(
}
}
Err(e) => {
decoders[i].abort(crate::output::Termination::ExecutionError);
if let Some(generation) = &generations[i] {
generation.fail_output();
}
let frame = encoder.failure(&e);
yield Delivery::Failed(e, frame);
return;
Expand All @@ -456,6 +457,7 @@ pub(super) async fn generate(
}
}
Err(e) => {
decoders[i].abort(crate::output::Termination::ExecutionError);
let frame = encoder.failure(&e);
yield Delivery::Failed(e, frame);
return;
Expand Down Expand Up @@ -570,7 +572,12 @@ pub(super) async fn generate(
frames.extend(final_frames);
Ok(frames)
});
generations[index] = None;
if let Some(generation) = generations[index].take() {
match &result {
Ok(_) => generation.complete_output(),
Err(_) => generation.fail_output(),
}
}
result
}
GenerationEvent::AdmissionRejected(e) | GenerationEvent::Error(e) => Err(e),
Expand All @@ -587,6 +594,10 @@ pub(super) async fn generate(
}
}
Err(e) => {
decoders[index].abort(crate::output::Termination::ExecutionError);
if let Some(generation) = &generations[index] {
generation.fail_output();
}
let frame = encoder.failure(&e);
yield Delivery::Failed(e, frame);
return;
Expand Down
6 changes: 3 additions & 3 deletions helios/src/server/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub struct Snapshot {
pub active: u64,
/// Requests waiting inside the model scheduler, excluding its ingress channel.
pub pending: u64,
/// Requests whose generation completed successfully.
/// Served HTTP and Decisions requests whose generation and output validation completed successfully, plus direct `ModelRuntime::generate*` requests whose model generation completed successfully.
pub completed: u64,
/// Requests whose reasoning was closed by their hard token budget.
pub reasoning_budget_cuts: u64,
Expand Down Expand Up @@ -1096,7 +1096,7 @@ impl Metrics {
),
(
"requests_completed_total",
"Requests whose model generation completed successfully, including explicit token stops.",
"Served HTTP and Decisions requests whose generation and output validation completed successfully (including explicit token stops), plus direct in-process ModelRuntime::generate* requests whose model generation completed successfully.",
&self.completed,
),
(
Expand All @@ -1106,7 +1106,7 @@ impl Metrics {
),
(
"requests_cancelled_total",
"Queued or active model requests cancelled before completion.",
"Queued, active, or unread served HTTP and Decisions requests cancelled or disconnected before output validation completes (or before model generation completes for direct in-process ModelRuntime::generate* callers).",
&self.cancelled,
),
(
Expand Down
28 changes: 20 additions & 8 deletions helios/src/server/protocol/decisions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,17 +835,25 @@ async fn score(
let mut usage = [0; 3];
for prompt in prompts {
let ids = prompt.logprob_token_ids.clone();
let mut generation = state.model.generate(prompt)?;
let mut generation = state
.model
.generate_for_output(vec![prompt], None)?
.remove(0);
let mut scores = None;
loop {
match generation
.events
.recv()
.await
.ok_or_else(|| generation.failure())?
{
let Some(event) = generation.events.recv().await else {
generation.fail_output();
return Err(generation.failure());
};
match event {
GenerationEvent::LogprobToken(value) if scores.is_none() => {
scores = Some(probabilities(&ids, &value)?);
match probabilities(&ids, &value) {
Ok(score) => scores = Some(score),
Err(error) => {
generation.fail_output();
return Err(error);
}
}
}
GenerationEvent::Finished {
prompt_tokens,
Expand All @@ -854,21 +862,25 @@ async fn score(
..
} => {
if generated_tokens != 1 || scores.is_none() {
generation.fail_output();
return Err(Error::execution(
ExecutionError::Completion,
"decision read must return exactly one scored token",
));
}
generation.complete_output();
usage[0] += prompt_tokens as u64;
usage[1] += reused_prompt_tokens;
usage[2] += u64::from(generated_tokens);
answers.push(scores.unwrap());
break;
}
GenerationEvent::AdmissionRejected(error) | GenerationEvent::Error(error) => {
generation.fail_output();
return Err(error);
}
_ => {
generation.fail_output();
return Err(Error::execution(
ExecutionError::Completion,
"unexpected decision scoring event",
Expand Down
Loading