Skip to content

vllm.v1.worker.gpu.spec_decode.utils

Classes:

Functions:

DraftTokensHandler

Methods:

  • get_draft_tokens –

    Return the latest drafts needed for the current step's grammar bitmask.

get_draft_tokens()

Return the latest drafts needed for the current step's grammar bitmask. Requests without retained drafts are omitted.

get_drafter_hidden_states(model, hidden_states)

Hidden states fed to the drafter.

Targets such as DeepSeek V4 expose the pre-hc_head residual through get_mtp_target_hidden_states(). The buffer is sized at max_num_batched_tokens and only allocated for drafters that consume target hidden states, so None means "use the regular hidden states".

get_parallel_drafting_token_id(hf_config)

Resolve the mask token id used for parallel drafting slots.

Checks (in order): dflash_config.mask_token_id, top-level mask_token_id, dspark_noise_token_id, pard_token, ptd_token_id. Raises ValueError if none are present.

max_num_tokens_after_draft_slots(max_num_tokens, num_reqs, max_num_new_slots_per_req)

Return the input-token budget after reserving each request's draft slots.