vllm.spec_decode.medusa_worker
MedusaWorker
¶
Bases: NonLLMProposerWorkerBase
, DelegateWorkerBase
Worker for Medusa.
Source code in vllm/spec_decode/medusa_worker.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
__init__
¶
_prepare_input_tensors
¶
_prepare_input_tensors(
seq_group_metadata_list: Optional[
List[SequenceGroupMetadata]
],
) -> Tuple[List[int], List[int]]
Source code in vllm/spec_decode/medusa_worker.py
_raise_if_unsupported
¶
_raise_if_unsupported(
execute_model_req: ExecuteModelRequest,
) -> None
MedusaWorker does not yet implement support for cache swap operations or beam search.
Source code in vllm/spec_decode/medusa_worker.py
get_spec_proposals
¶
get_spec_proposals(
execute_model_req: ExecuteModelRequest,
seq_ids_with_bonus_token_in_last_step: Set[int],
) -> SpeculativeProposals
Produce speculations given an input batch of sequences. The number of speculative tokens per sequence is determined by max_proposal_len.
Source code in vllm/spec_decode/medusa_worker.py
init_device
¶
sampler_output
¶
sampler_output(
execute_model_req: ExecuteModelRequest,
sample_len: int,
seq_ids_with_bonus_token_in_last_step: Set[int],
) -> Tuple[List[SamplerOutput], bool]
Run the model forward pass to generate sample_len future tokens. Returns the list of sampler output, one per layer, along with indicator of whether torch tensor in sampler output need to be transposed in latter sampler_output_to_torch logic.
For medusa worker, this indicator shall be False.