vllm.v1.worker.gpu.spec_decode.utils
¶
Classes:
Functions:
-
get_drafter_hidden_states–Hidden states fed to the drafter.
-
get_parallel_drafting_token_id–Resolve the mask token id used for parallel drafting slots.
-
get_pp_safe_draft_load_config–Avoid collectives that include PP ranks without a draft model.
-
max_num_tokens_after_draft_slots–Return the input-token budget after reserving each request's draft slots.
DraftTokensHandler
¶
Methods:
-
get_draft_tokens–Return the latest drafts needed for the current step's grammar bitmask.
Source code in vllm/v1/worker/gpu/spec_decode/utils.py
get_draft_tokens()
¶
Return the latest drafts needed for the current step's grammar bitmask. Requests without retained drafts are omitted.
Source code in vllm/v1/worker/gpu/spec_decode/utils.py
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".
Source code in vllm/v1/worker/gpu/spec_decode/utils.py
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.
Source code in vllm/v1/worker/gpu/spec_decode/utils.py
get_pp_safe_draft_load_config(load_config)
¶
Avoid collectives that include PP ranks without a draft model.
Source code in vllm/v1/worker/gpu/spec_decode/utils.py
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.