Skip to content

vllm.v1.metrics.iteration_workload

Workload snapshots that accompany iteration records.

All lengths are logical token counts, not physical KV cache occupancy.

Classes:

  • QueuedWorkload –

    Requests in the waiting queues when the scheduler stats were made,

  • QueuedWorkloadTally –

    The QueuedWorkload of the waiting queues, kept as requests enter and

  • ScheduledWorkload –

    KV context lengths of the requests scheduled in one iteration.

Functions:

QueuedWorkload dataclass

Requests in the waiting queues when the scheduler stats were made, deferred ones included. Stats are made on engine steps, so an idle engine does not update it.

Preempted requests and requests waiting for remote KV count as queued decode work with their computed tokens, which a preemption resets to zero and an admitted remote load sets before the KV arrives. The other requests, streaming sessions that wait for more input included, count as queued prefill work with all their tokens. This is a queue category, not an execution phase: a resumed request may have to recompute its prefill.

QueuedWorkloadTally

The QueuedWorkload of the waiting queues, kept as requests enter and leave them.

A request is remembered as it was counted, so that leaving subtracts exactly that. One whose status or token counts change while it waits must be passed to refresh.

Methods:

  • add –

    Count a request that entered queue, as it is now.

  • discard –

    Stop counting a request that left queue, if it was in it.

  • refresh –

    Recount a waiting request that changed in place.

add(queue, request)

Count a request that entered queue, as it is now.

discard(queue, request)

Stop counting a request that left queue, if it was in it.

refresh(request)

Recount a waiting request that changed in place.

ScheduledWorkload dataclass

KV context lengths of the requests scheduled in one iteration.

A request's context is what it has computed before the iteration. Its prefill length is that context plus half of the tokens scheduled for it, about the mean context of those tokens. The variances are population variances. The request and token counts are in the iteration's record, where prefill is num_ctx_* and decode is num_generation_*. With async scheduling and speculative decoding, a decode context can exceed the true one by the draft tokens that the previous, still running iteration rejects.

_variance(count, total, total_squares)

Population variance, exact up to the final division.

make_scheduled_workload(new_requests, running_requests, num_scheduled_tokens)

Summarize the scheduled requests before their computed tokens advance.

Prefill and decode requests are told apart as in IterationDetails.