33import pytest
44import torch
55
6- from vllm .multimodal .inputs import MultiModalKwargs
6+ from vllm .multimodal .inputs import MultiModalKwargs , PlaceholderRange
77from vllm .sampling_params import SamplingParams
88from vllm .utils import sha256
99# disable yapf here as it formats differently than isort such that both fail
@@ -158,13 +158,10 @@ def test_generate_block_hash_extra_keys():
158158 request = make_request (
159159 request_id = 0 ,
160160 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+ ],
168165 mm_hashes = ["hash1" , "hash2" ],
169166 )
170167
@@ -222,13 +219,10 @@ def test_hash_request_tokens(hash_fn):
222219 request = make_request (
223220 request_id = 0 ,
224221 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+ ],
232226 mm_hashes = ["hash1" , "hash2" ],
233227 )
234228
@@ -253,25 +247,19 @@ def test_hash_tokens_different_mm_input(hash_fn):
253247 request1 = make_request (
254248 request_id = 0 ,
255249 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+ ],
263254 mm_hashes = ["hash1" , "hash2" ],
264255 )
265256 request2 = make_request (
266257 request_id = 1 ,
267258 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+ ],
275263 mm_hashes = ["hash3" , "hash2" ],
276264 )
277265 block_size = 3
0 commit comments