vllm.v1.worker.gpu.mm.rope
¶
Classes:
-
RopeState–State for multi-dimensional (M-RoPE) positions.
Functions:
-
get_rope_state–Create a RopeState if the model uses multi-dimensional RoPE.
RopeState
¶
State for multi-dimensional (M-RoPE) positions.
num_dims is the number of position channels the model consumes, which
the model config derives from its M-RoPE sections.
NOTE: positions is implemented with one additional dummy position on
purpose to make it non-contiguous so that it can work with torch compile.
See detailed explanation in
https://github.com/vllm-project/vllm/pull/12128#discussion_r1926431923
NOTE: For text-only inputs, each dimension has identical position IDs, making M-RoPE functionally equivalent to 1D-RoPE. See page 5 of https://arxiv.org/abs/2409.12191
Methods:
-
init_prefill_positions–Stage the request's prefill positions and decode delta.
-
prepare_positions–Prepare M-RoPE positions from global token indices in batch order.
-
read_prefill_positions–Return staged per-request prefill positions as [num_dims, length].
-
update_prefill_positions–Overwrite a request's staged prefill positions with recomputed values.
Source code in vllm/v1/worker/gpu/mm/rope.py
14 15 16 17 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_prefill_positions(req_idx, model, prefill_token_ids, mm_features, position_delta=None)
¶
Stage the request's prefill positions and decode delta.
position_delta is the delta a P/D prefill instance reported for a
prompt whose multimodal inputs never reached this instance. It is only
applied when mm_features is empty.
Source code in vllm/v1/worker/gpu/mm/rope.py
prepare_positions(idx_mapping, query_start_loc, prefill_lens, input_positions)
¶
Prepare M-RoPE positions from global token indices in batch order.
Source code in vllm/v1/worker/gpu/mm/rope.py
read_prefill_positions(req_idx, length)
¶
Return staged per-request prefill positions as [num_dims, length].
Source code in vllm/v1/worker/gpu/mm/rope.py
update_prefill_positions(req_idx, positions, delta)
¶
Overwrite a request's staged prefill positions with recomputed values.
Source code in vllm/v1/worker/gpu/mm/rope.py
get_rope_state(model_config, model, max_num_reqs, max_num_tokens, max_model_len, device)
¶
Create a RopeState if the model uses multi-dimensional RoPE.