Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
cc7f22a8
Commit
cc7f22a8
authored
Jun 11, 2025
by
zhuwenwen
Browse files
Merge tag 'v0.9.1' into v0.9.1-ori
parents
b9ea0c09
b6553be1
Changes
1000
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
239 additions
and
1 deletion
+239
-1
tests/multimodal/test_utils.py
tests/multimodal/test_utils.py
+111
-1
tests/multimodal/test_video.py
tests/multimodal/test_video.py
+1
-0
tests/multimodal/utils.py
tests/multimodal/utils.py
+1
-0
tests/neuron/1_core/test_activation.py
tests/neuron/1_core/test_activation.py
+1
-0
tests/neuron/1_core/test_block_table.py
tests/neuron/1_core/test_block_table.py
+1
-0
tests/neuron/1_core/test_cache.py
tests/neuron/1_core/test_cache.py
+1
-0
tests/neuron/1_core/test_layernorm.py
tests/neuron/1_core/test_layernorm.py
+1
-0
tests/neuron/1_core/test_logits_processor.py
tests/neuron/1_core/test_logits_processor.py
+1
-0
tests/neuron/1_core/test_neuron_model_runner.py
tests/neuron/1_core/test_neuron_model_runner.py
+1
-0
tests/neuron/1_core/test_neuron_quant.py
tests/neuron/1_core/test_neuron_quant.py
+12
-0
tests/neuron/1_core/test_prefix_prefill.py
tests/neuron/1_core/test_prefix_prefill.py
+1
-0
tests/neuron/1_core/test_rotary_embedding.py
tests/neuron/1_core/test_rotary_embedding.py
+1
-0
tests/neuron/2_core/test_comm_ops.py
tests/neuron/2_core/test_comm_ops.py
+1
-0
tests/neuron/2_core/test_eagle.py
tests/neuron/2_core/test_eagle.py
+1
-0
tests/neuron/2_core/test_mistral.py
tests/neuron/2_core/test_mistral.py
+1
-0
tests/neuron/2_core/test_multi_lora.py
tests/neuron/2_core/test_multi_lora.py
+99
-0
tests/plugins/lora_resolvers/test_filesystem_resolver.py
tests/plugins/lora_resolvers/test_filesystem_resolver.py
+1
-0
tests/plugins/vllm_add_dummy_model/setup.py
tests/plugins/vllm_add_dummy_model/setup.py
+1
-0
tests/plugins/vllm_add_dummy_model/vllm_add_dummy_model/__init__.py
...ins/vllm_add_dummy_model/vllm_add_dummy_model/__init__.py
+1
-0
tests/plugins/vllm_add_dummy_model/vllm_add_dummy_model/my_gemma_embedding.py
...dd_dummy_model/vllm_add_dummy_model/my_gemma_embedding.py
+1
-0
No files found.
Too many changes to show.
To preserve performance only
1000 of 1000+
files are displayed.
Plain diff
Email patch
tests/multimodal/test_utils.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
base64
import
mimetypes
...
...
@@ -8,12 +9,21 @@ from typing import TYPE_CHECKING, NamedTuple, Optional
import
numpy
as
np
import
pytest
import
torch
import
torch.multiprocessing
as
mp
from
PIL
import
Image
,
ImageChops
from
tests.utils
import
multi_gpu_test
from
vllm.distributed
import
get_tensor_model_parallel_world_size
from
vllm.distributed.parallel_state
import
(
init_distributed_environment
,
initialize_model_parallel
)
from
vllm.multimodal.image
import
convert_image_mode
from
vllm.multimodal.inputs
import
PlaceholderRange
from
vllm.multimodal.utils
import
(
MediaConnector
,
merge_and_sort_multimodal_metadata
)
merge_and_sort_multimodal_metadata
,
run_dp_sharded_vision_model
)
from
vllm.platforms
import
current_platform
from
vllm.utils
import
get_open_port
,
update_environment_variables
if
TYPE_CHECKING
:
from
vllm.multimodal.hasher
import
MultiModalHashDict
...
...
@@ -140,6 +150,19 @@ async def test_fetch_image_local_files(image_url: str):
f
"file://
{
temp_dir
}
/../
{
os
.
path
.
basename
(
image_url
)
}
"
)
@
pytest
.
mark
.
asyncio
async
def
test_fetch_image_error_conversion
():
connector
=
MediaConnector
()
broken_img
=
"data:image/png;base64,aGVsbG9fdmxsbV9jb21tdW5pdHkK"
# PIL.UnidentifiedImageError should be converted to ValueError
with
pytest
.
raises
(
ValueError
):
await
connector
.
fetch_image_async
(
broken_img
)
with
pytest
.
raises
(
ValueError
):
connector
.
fetch_image
(
broken_img
)
@
pytest
.
mark
.
asyncio
@
pytest
.
mark
.
parametrize
(
"video_url"
,
TEST_VIDEO_URLS
)
@
pytest
.
mark
.
parametrize
(
"num_frames"
,
[
-
1
,
32
,
1800
])
...
...
@@ -399,3 +422,90 @@ def test_merge_and_sort_multimodal_metadata_with_interleaving():
assert
modalities
==
expected_modalities
assert
ranges
==
expected_ranges
assert
hashes
==
expected_hashes
class
SimpleLinearModel
(
torch
.
nn
.
Module
):
"""A simple linear vision model for testing."""
def
__init__
(
self
,
input_dim
:
int
=
3
*
224
*
224
,
output_dim
:
int
=
32
):
super
().
__init__
()
self
.
flatten
=
torch
.
nn
.
Flatten
()
self
.
linear
=
torch
.
nn
.
Linear
(
input_dim
,
output_dim
)
def
forward
(
self
,
x
:
torch
.
Tensor
):
# Flatten the input and apply linear transformation
x
=
self
.
flatten
(
x
)
return
self
.
linear
(
x
)
@
multi_gpu_test
(
num_gpus
=
2
)
@
pytest
.
mark
.
parametrize
(
"batch_size"
,
[
1
,
# Single image
4
,
# Small batch
5
,
# Odd batch size (for testing padding)
],
)
def
test_run_dp_sharded_vision_model
(
batch_size
:
int
):
world_size
=
2
# Launch processes
mp
.
spawn
(
run_dp_sharded_vision_model_vs_direct
,
args
=
(
world_size
,
batch_size
,
get_open_port
(),
),
nprocs
=
world_size
,
)
def
run_dp_sharded_vision_model_vs_direct
(
local_rank
:
int
,
world_size
:
int
,
batch_size
:
int
,
master_port
:
int
):
"""
Test that run_dp_sharded_vision_model produces the same results as
calling the model directly.
"""
# Set random seed for reproducibility
current_platform
.
seed_everything
(
0
)
device
=
torch
.
device
(
f
"cuda:
{
local_rank
}
"
)
torch
.
cuda
.
set_device
(
device
)
torch
.
set_default_device
(
device
)
update_environment_variables
({
'RANK'
:
str
(
local_rank
),
'LOCAL_RANK'
:
str
(
local_rank
),
'WORLD_SIZE'
:
str
(
world_size
),
'MASTER_ADDR'
:
'localhost'
,
'MASTER_PORT'
:
str
(
master_port
),
})
# initialize distributed
init_distributed_environment
()
initialize_model_parallel
(
tensor_model_parallel_size
=
world_size
)
# Create a test input tensor
image_input
=
torch
.
randn
(
batch_size
,
3
,
224
,
224
)
# Create a simple linear model
vision_model
=
SimpleLinearModel
()
# Run the model directly on the full input
with
torch
.
inference_mode
():
direct_output
=
vision_model
(
image_input
)
# Run the model through the sharded function
with
torch
.
inference_mode
():
sharded_output
=
run_dp_sharded_vision_model
(
image_input
,
vision_model
)
# Check that the world size is setup correctly
assert
get_tensor_model_parallel_world_size
()
==
world_size
# Check that the outputs have the same shape
assert
direct_output
.
shape
==
sharded_output
.
shape
# Check that the outputs are close (they should be identical)
assert
torch
.
allclose
(
direct_output
,
sharded_output
,
rtol
=
1e-5
,
atol
=
1e-5
)
tests/multimodal/test_video.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
numpy
as
np
import
numpy.typing
as
npt
import
pytest
...
...
tests/multimodal/utils.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
numpy
as
np
from
PIL
import
Image
...
...
tests/neuron/1_core/test_activation.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
pytest
import
torch
...
...
tests/neuron/1_core/test_block_table.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
neuronxcc.nki.language
as
nl
import
pytest
...
...
tests/neuron/1_core/test_cache.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
pytest
import
torch
...
...
tests/neuron/1_core/test_layernorm.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
pytest
import
torch
...
...
tests/neuron/1_core/test_logits_processor.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
random
from
unittest.mock
import
patch
...
...
tests/neuron/1_core/test_neuron_model_runner.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
os
from
unittest.mock
import
MagicMock
...
...
tests/neuron/1_core/test_neuron_quant.py
0 → 100644
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
vllm.model_executor.layers.quantization.neuron_quant
import
(
NeuronQuantConfig
)
def
test_get_supported_act_dtypes
():
neuron_quant_config
=
NeuronQuantConfig
()
supported_act_dtypes
=
neuron_quant_config
.
get_supported_act_dtypes
()
target_list
=
[
"any_dtype1"
,
"any_dtype2"
]
for
dtype
in
target_list
:
assert
dtype
in
supported_act_dtypes
tests/neuron/1_core/test_prefix_prefill.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
typing
import
Optional
...
...
tests/neuron/1_core/test_rotary_embedding.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Tests for miscellaneous utilities
"""
...
...
tests/neuron/2_core/test_comm_ops.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
functools
from
typing
import
Callable
from
unittest.mock
import
patch
...
...
tests/neuron/2_core/test_eagle.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
json
import
os
...
...
tests/neuron/2_core/test_mistral.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
vllm
import
LLM
,
SamplingParams
...
...
tests/neuron/2_core/test_multi_lora.py
0 → 100644
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
huggingface_hub
import
snapshot_download
from
vllm
import
LLM
,
SamplingParams
from
vllm.lora.request
import
LoRARequest
def
test_llama_single_lora
():
sql_lora_files
=
snapshot_download
(
repo_id
=
"yard1/llama-2-7b-sql-lora-test"
)
llm
=
LLM
(
model
=
"meta-llama/Llama-2-7b-hf"
,
tensor_parallel_size
=
2
,
max_num_seqs
=
4
,
max_model_len
=
512
,
use_v2_block_manager
=
True
,
override_neuron_config
=
{
"sequence_parallel_enabled"
:
False
,
"skip_warmup"
:
True
,
"lora_modules"
:
[{
"name"
:
"lora_id_1"
,
"path"
:
sql_lora_files
}]
},
enable_lora
=
True
,
max_loras
=
1
,
max_lora_rank
=
256
,
device
=
"neuron"
)
"""For multi-lora requests using NxDI as the backend, only the lora_name
needs to be specified. The lora_id and lora_path are supplied at the LLM
class/server initialization, after which the paths are handled by NxDI"""
lora_req_1
=
LoRARequest
(
"lora_id_1"
,
0
,
" "
)
prompts
=
[
"The president of the United States is"
,
"The capital of France is"
,
]
outputs
=
llm
.
generate
(
prompts
,
SamplingParams
(
top_k
=
1
),
lora_request
=
[
lora_req_1
,
lora_req_1
])
expected_outputs
=
[
" the head of state and head of government of the United States. "
"The president direct"
,
" a city of contrasts. The city is home to the Eiffel Tower"
]
for
expected_output
,
output
in
zip
(
expected_outputs
,
outputs
):
generated_text
=
output
.
outputs
[
0
].
text
assert
(
expected_output
==
generated_text
)
def
test_llama_multiple_lora
():
sql_lora_files
=
snapshot_download
(
repo_id
=
"yard1/llama-2-7b-sql-lora-test"
)
llm
=
LLM
(
model
=
"meta-llama/Llama-2-7b-hf"
,
tensor_parallel_size
=
2
,
max_num_seqs
=
4
,
max_model_len
=
512
,
use_v2_block_manager
=
True
,
override_neuron_config
=
{
"sequence_parallel_enabled"
:
False
,
"skip_warmup"
:
True
,
"lora_modules"
:
[{
"name"
:
"lora_id_1"
,
"path"
:
sql_lora_files
},
{
"name"
:
"lora_id_2"
,
"path"
:
sql_lora_files
}]
},
enable_lora
=
True
,
max_loras
=
2
,
max_lora_rank
=
256
,
device
=
"neuron"
)
"""For multi-lora requests using NxDI as the backend, only the lora_name
needs to be specified. The lora_id and lora_path are supplied at the LLM
class/server initialization, after which the paths are handled by NxDI"""
lora_req_1
=
LoRARequest
(
"lora_id_1"
,
0
,
" "
)
lora_req_2
=
LoRARequest
(
"lora_id_2"
,
1
,
" "
)
prompts
=
[
"The president of the United States is"
,
"The capital of France is"
,
]
outputs
=
llm
.
generate
(
prompts
,
SamplingParams
(
top_k
=
1
),
lora_request
=
[
lora_req_1
,
lora_req_2
])
expected_outputs
=
[
" the head of state and head of government of the United States. "
"The president direct"
,
" a city of contrasts. The city is home to the Eiffel Tower"
]
for
expected_output
,
output
in
zip
(
expected_outputs
,
outputs
):
generated_text
=
output
.
outputs
[
0
].
text
assert
(
expected_output
==
generated_text
)
tests/plugins/lora_resolvers/test_filesystem_resolver.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
os
import
shutil
...
...
tests/plugins/vllm_add_dummy_model/setup.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
setuptools
import
setup
...
...
tests/plugins/vllm_add_dummy_model/vllm_add_dummy_model/__init__.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
vllm
import
ModelRegistry
...
...
tests/plugins/vllm_add_dummy_model/vllm_add_dummy_model/my_gemma_embedding.py
View file @
cc7f22a8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
collections.abc
import
Iterable
from
typing
import
Optional
,
Union
...
...
Prev
1
…
26
27
28
29
30
31
32
33
34
…
50
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment