vllm.spec_decode.metrics
AsyncMetricsCollector
¶
Class which copies rejection/typical-acceptance sampler metrics from the device to CPU on a non-default Torch stream.
Source code in vllm/spec_decode/metrics.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
_aggregate_num_accepted_tokens
instance-attribute
¶
_aggregate_num_accepted_tokens = tensor(
0, dtype=long, device="cpu", pin_memory=pin_memory
)
_aggregate_num_emitted_tokens
instance-attribute
¶
_aggregate_num_emitted_tokens = tensor(
0, dtype=long, device="cpu", pin_memory=pin_memory
)
_rejsample_metrics_collect_interval_s
instance-attribute
¶
__init__
¶
__init__(
spec_decode_sampler: SpecDecodeBaseSampler,
timer: Optional[Timer] = None,
collect_interval_s: float = 5.0,
)
Source code in vllm/spec_decode/metrics.py
_collect_rejsample_metrics
¶
_collect_rejsample_metrics(
k: int, ready_event: Event
) -> SpecDecodeWorkerMetrics
Create metrics object from statistics copied asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
k
|
int
|
int. The number of speculative tokens; used to determine system efficiency. |
required |
ready_event
|
Event
|
torch.cuda.Event. The CUDA event recording when the async GPU->CPU copy is complete. |
required |
Source code in vllm/spec_decode/metrics.py
_copy_rejsample_metrics_async
¶
_copy_rejsample_metrics_async() -> Event
Copy rejection/typical-acceptance sampling metrics (number of accepted tokens, etc) to CPU asynchronously.
Returns a device event recording when the copy is complete.
Source code in vllm/spec_decode/metrics.py
_should_collect_rejsample_metrics
¶
Return whether or not this iteration should print sampling metrics.
Source code in vllm/spec_decode/metrics.py
get_max_num_emitted_tokens
staticmethod
¶
Calculate the number of emitted tokens, assuming all tokens are accepted.
This is equal to the number of sequences that have been speculated on, times (speculation len + 1). The +1 comes from the bonus token.
Source code in vllm/spec_decode/metrics.py
init_tensors
¶
Source code in vllm/spec_decode/metrics.py
maybe_collect_rejsample_metrics
¶
maybe_collect_rejsample_metrics(
k: int,
) -> Optional[SpecDecodeWorkerMetrics]
Source code in vllm/spec_decode/metrics.py
SpecDecodeWorkerMetrics
¶
Bases: Struct
Dataclass holding metrics emitted from the spec decode worker.