Skip to content

feat: expose slot progress/status for #451 - #55

Merged
ddvnguyen merged 5 commits into
hydra-forkfrom
feat/451-slot-progress-fork
Jul 18, 2026
Merged

ddvnguyen merged 5 commits into
hydra-forkfrom
feat/451-slot-progress-fork

Conversation

@ddvnguyen

Copy link
Copy Markdown
Owner

Summary

Extends /slots/:id/state/meta endpoint with per-slot progress fields so that
Hydra Core can distinguish legitimately busy slots from stuck ones.

Changes

  • server-task.h: Add operation, progress, tokens_processed, tokens_total, elapsed_ms to server_task_result_hydra_state
  • server-context.cpp: Populate progress fields from slot state in HYDRA_STATE_META handler
  • server-task.cpp: Include progress fields in to_json() META response

Refs

  • hydra_vortex#451

- Extend server_task_result_hydra_state with progress fields (operation, progress, tokens_processed, tokens_total, elapsed_ms)
- Populate progress fields based on slot state in HYDRA_STATE_META handler
- Update to_json() to include progress fields in META response
- Map slot states to operation strings (prefill, decode, idle, etc.)
prompt.tokens.size() grows during prefill — it's the current count, not
the total. task->n_tokens() is the fixed total (e.g., 100K).

Before: tokens_total = slot->prompt.tokens.size() (wrong, grows)
After:  tokens_total = slot->task->n_tokens()    (correct, fixed)

This matches llama.cpp's own progress calculation at line 501:
  f_progress = prompt.n_tokens() / task->n_tokens()

So for a 100K token prefill at 48980 tokens processed:
  tokens_processed = 48980
  tokens_total = 100000
  progress = 0.4898
Add timing and throughput metrics to PREFILL RPC response:
- prefill_ms: actual prefill time in milliseconds
- model_load_ms: model load time if swap happened (ms)
- prompt_tokens: total tokens processed
- tokens_per_second: throughput during prefill
- cache_tokens: tokens from cache
- kv_size: KV state size in bytes
- logits_size: logits size in bytes

These metrics enable Hydra Core to:
- Track prefill performance over time
- Identify load bottlenecks (model load vs prefill)
- Understand throughput patterns
- Detect anomalies in prefill operations
@ddvnguyen
ddvnguyen changed the base branch from master to hydra-fork July 18, 2026 04:42
n_remaining defaults to -1 (unlimited generation) when no finite n_predict
is set. Computing tokens_total = n_decoded + (-1) overflows, producing
progress > 1.0. Guard: only compute decode progress when n_remaining > 0.
When hydra_transferring flips operation to 'save', the previous state's
progress/tokens_processed/tokens_total/elapsed_ms are stale and contradictory
(e.g. operation='save' alongside progress=1.0 from idle). Zero all four
fields so the response is self-consistent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant