Skip to content

vllm.v1.worker.gpu.spec_decode.draft_logits

Classes:

  • DraftLogitsCache –

    Pre-temperature draft logits, cached by a draft step for the next

Functions:

  • draft_logits_row –

    Row of a request in this rank's draft logits cache, or -1 if no row.

DraftLogitsCache

Pre-temperature draft logits, cached by a draft step for the next verification.

A replicated cache holds every request on every TP rank, at row req_state_idx.

A sharded cache (batch-sharded sampling) holds on each TP rank only the requests that rank verifies. Every draft step gives the request at batch position i to rank i % tp, at row i // tp of its cache, so no rank caches more than cdiv(num_reqs, tp) requests however the request slots are spread.

Rows are reused every step. A request that the scheduler skips for a step keeps its drafts, but its row may since have been given to another request. inverse_row_mapping detects this, and stale_drafts marks those drafts invalid, so verification rejects them and samples from the target.

Methods:

  • assign –

    Give a sharded cache's rows out by batch position. Call after

  • owners_of –

    The TP rank that verifies each of a batch's requests: the rank that

  • stale_drafts –

    Mark the drafts whose draft logits were overwritten since drafting.

assign(idx_mapping, idx_mapping_np)

Give a sharded cache's rows out by batch position. Call after verification and before the draft step writes the draft logits.

owners_of(idx_mapping_np)

The TP rank that verifies each of a batch's requests: the rank that cached its draft logits, or for a replicated cache, round-robin over batch positions.

Returns:

  • ndarray –

    [num_reqs] each request's owner, and the [max_num_reqs] device owner

  • Tensor | None –

    table, or None for a replicated cache.

stale_drafts(input_batch)

Mark the drafts whose draft logits were overwritten since drafting. Only valid for requests this rank owns.

Returns:

  • Tensor | None –

    [num_logits] True for each stale draft, or None for a replicated

  • Tensor | None –

    cache, whose rows are never reused.

draft_logits_row(req_state_idx, row_mapping_ptr)

Row of a request in this rank's draft logits cache, or -1 if no row.

row_mapping_ptr is None for a replicated cache, which is indexed by request state. Otherwise it is DraftLogitsCache.row_mapping.