vllm.models.deepseek_v41.decoder_replay_layers
¶
Decoder-side SWA bounded replay: running the replay layers on their batch.
Once the last KV-source layer has written every row's KV, it and the layers past
it (which own only SWA KV) run on each request's last window rows only.
DeepseekV41ModelState prepares those rows as a sub-batch with attention
metadata and a forward context of its own, like a microbatch;
DecoderReplayLayers gathers the layer inputs by its rows, runs the layers
under that context and scatters the outputs back to batch rows. FULL graphs and
small PIECEWISE ones keep the layers on the whole batch; larger PIECEWISE graphs
break out to the replay batch, which may run in a graph of its own
(decoder_replay_cudagraph.py).
Classes:
-
DecoderReplayLayers–Runs the replay layers on the step's replay batch.
-
ReplayBatch–One forward's replay batch;
run_graphis set when it runs in a graph.
DecoderReplayLayers
¶
Runs the replay layers on the step's replay batch.
run_layers takes a batch's layer inputs and returns its per-row outputs;
write_batch_kv takes them too and writes the first replay layer's KV for
every row. metadata_prefixes are the attention metadata keys the layers
read, so the replay batch builds only those. first_swa_prefix keys the
first replay layer's SWA metadata, built with the batch's window starts.
Methods:
-
graph_uses_replay_batch–Whether a PIECEWISE graph of
num_tokensbreaks out to the replay -
uses_replay_batch–Whether this forward uses the replay batch: in a PIECEWISE graph by its
Source code in vllm/models/deepseek_v41/decoder_replay_layers.py
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 | |
_run_in_graph_break(hidden_states, *states)
¶
A graph break: the outputs land in fixed buffers the next segment reads.
Source code in vllm/models/deepseek_v41/decoder_replay_layers.py
graph_uses_replay_batch(num_tokens)
¶
Whether a PIECEWISE graph of num_tokens breaks out to the replay
batch; capture and the model state's runtime replay batch share it.
Source code in vllm/models/deepseek_v41/decoder_replay_layers.py
uses_replay_batch()
¶
Whether this forward uses the replay batch: in a PIECEWISE graph by its size, fixed at capture (no replay batch is set then); else if one is set.
Source code in vllm/models/deepseek_v41/decoder_replay_layers.py
ReplayBatch
dataclass
¶
One forward's replay batch; run_graph is set when it runs in a graph.