3
3
import pytest
4
4
import torch
5
5
6
- from vllm .multimodal .inputs import MultiModalKwargs
6
+ from vllm .multimodal .inputs import MultiModalKwargs , PlaceholderRange
7
7
from vllm .sampling_params import SamplingParams
8
8
from vllm .utils import sha256
9
9
# disable yapf here as it formats differently than isort such that both fail
@@ -158,13 +158,10 @@ def test_generate_block_hash_extra_keys():
158
158
request = make_request (
159
159
request_id = 0 ,
160
160
prompt_token_ids = [_ for _ in range (20 )],
161
- mm_positions = [{
162
- "offset" : 0 ,
163
- "length" : 5
164
- }, {
165
- "offset" : 10 ,
166
- "length" : 5
167
- }],
161
+ mm_positions = [
162
+ PlaceholderRange (offset = 0 , length = 5 ),
163
+ PlaceholderRange (offset = 10 , length = 5 ),
164
+ ],
168
165
mm_hashes = ["hash1" , "hash2" ],
169
166
)
170
167
@@ -222,13 +219,10 @@ def test_hash_request_tokens(hash_fn):
222
219
request = make_request (
223
220
request_id = 0 ,
224
221
prompt_token_ids = [_ for _ in range (6 )],
225
- mm_positions = [{
226
- "offset" : 0 ,
227
- "length" : 3
228
- }, {
229
- "offset" : 3 ,
230
- "length" : 3
231
- }],
222
+ mm_positions = [
223
+ PlaceholderRange (offset = 0 , length = 3 ),
224
+ PlaceholderRange (offset = 3 , length = 3 ),
225
+ ],
232
226
mm_hashes = ["hash1" , "hash2" ],
233
227
)
234
228
@@ -253,25 +247,19 @@ def test_hash_tokens_different_mm_input(hash_fn):
253
247
request1 = make_request (
254
248
request_id = 0 ,
255
249
prompt_token_ids = [_ for _ in range (6 )],
256
- mm_positions = [{
257
- "offset" : 0 ,
258
- "length" : 3
259
- }, {
260
- "offset" : 3 ,
261
- "length" : 3
262
- }],
250
+ mm_positions = [
251
+ PlaceholderRange (offset = 0 , length = 3 ),
252
+ PlaceholderRange (offset = 3 , length = 3 ),
253
+ ],
263
254
mm_hashes = ["hash1" , "hash2" ],
264
255
)
265
256
request2 = make_request (
266
257
request_id = 1 ,
267
258
prompt_token_ids = [_ for _ in range (6 )],
268
- mm_positions = [{
269
- "offset" : 0 ,
270
- "length" : 3
271
- }, {
272
- "offset" : 3 ,
273
- "length" : 3
274
- }],
259
+ mm_positions = [
260
+ PlaceholderRange (offset = 0 , length = 3 ),
261
+ PlaceholderRange (offset = 3 , length = 3 ),
262
+ ],
275
263
mm_hashes = ["hash3" , "hash2" ],
276
264
)
277
265
block_size = 3
0 commit comments