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
a836524d
Unverified
Commit
a836524d
authored
Mar 17, 2026
by
Isotr0py
Committed by
GitHub
Mar 17, 2026
Browse files
[Chore] Replace all base64 usages with faster pybase64 package (#37290)
Signed-off-by:
Isotr0py
<
mozf@mail2.sysu.edu.cn
>
parent
3717a4dd
Changes
37
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
26 additions
and
19 deletions
+26
-19
tests/models/multimodal/generation/vlm_utils/model_utils.py
tests/models/multimodal/generation/vlm_utils/model_utils.py
+1
-1
tests/models/multimodal/pooling/test_colpali.py
tests/models/multimodal/pooling/test_colpali.py
+1
-1
tests/models/multimodal/pooling/test_colqwen3.py
tests/models/multimodal/pooling/test_colqwen3.py
+1
-1
tests/models/multimodal/pooling/test_llama_nemotron_vl.py
tests/models/multimodal/pooling/test_llama_nemotron_vl.py
+1
-1
tests/multimodal/media/test_audio.py
tests/multimodal/media/test_audio.py
+1
-1
tests/multimodal/media/test_connector.py
tests/multimodal/media/test_connector.py
+1
-1
tests/plugins/prithvi_io_processor_plugin/prithvi_io_processor/prithvi_processor.py
...rocessor_plugin/prithvi_io_processor/prithvi_processor.py
+1
-1
tests/plugins_tests/test_terratorch_io_processor_plugins.py
tests/plugins_tests/test_terratorch_io_processor_plugins.py
+1
-1
tests/renderers/test_sparse_tensor_validation.py
tests/renderers/test_sparse_tensor_validation.py
+1
-1
tools/pre_commit/check_forbidden_imports.py
tools/pre_commit/check_forbidden_imports.py
+8
-0
vllm/benchmarks/datasets.py
vllm/benchmarks/datasets.py
+1
-1
vllm/distributed/weight_transfer/ipc_engine.py
vllm/distributed/weight_transfer/ipc_engine.py
+1
-1
vllm/entrypoints/openai/realtime/connection.py
vllm/entrypoints/openai/realtime/connection.py
+1
-1
vllm/entrypoints/openai/run_batch.py
vllm/entrypoints/openai/run_batch.py
+1
-1
vllm/entrypoints/pooling/embed/protocol.py
vllm/entrypoints/pooling/embed/protocol.py
+1
-1
vllm/multimodal/media/audio.py
vllm/multimodal/media/audio.py
+2
-3
vllm/multimodal/media/video.py
vllm/multimodal/media/video.py
+2
-2
No files found.
tests/models/multimodal/generation/vlm_utils/model_utils.py
View file @
a836524d
...
@@ -1235,9 +1235,9 @@ def voxtral_patch_hf_runner(hf_model: "HfRunner") -> "HfRunner":
...
@@ -1235,9 +1235,9 @@ def voxtral_patch_hf_runner(hf_model: "HfRunner") -> "HfRunner":
generated).
generated).
"""
"""
import
base64
import
io
import
io
import
pybase64
as
base64
import
soundfile
as
sf
import
soundfile
as
sf
processor
=
hf_model
.
processor
processor
=
hf_model
.
processor
...
...
tests/models/multimodal/pooling/test_colpali.py
View file @
a836524d
...
@@ -7,9 +7,9 @@ ColPali is a multi-vector retrieval model based on PaliGemma backbone
...
@@ -7,9 +7,9 @@ ColPali is a multi-vector retrieval model based on PaliGemma backbone
It produces per-token embeddings for both text and image inputs.
It produces per-token embeddings for both text and image inputs.
"""
"""
import
base64
from
io
import
BytesIO
from
io
import
BytesIO
import
pybase64
as
base64
import
pytest
import
pytest
import
torch
import
torch
from
PIL
import
Image
from
PIL
import
Image
...
...
tests/models/multimodal/pooling/test_colqwen3.py
View file @
a836524d
...
@@ -7,9 +7,9 @@ ColBERT-style late interaction scoring (MaxSim). It produces per-token
...
@@ -7,9 +7,9 @@ ColBERT-style late interaction scoring (MaxSim). It produces per-token
embeddings for both text and image inputs.
embeddings for both text and image inputs.
"""
"""
import
base64
from
io
import
BytesIO
from
io
import
BytesIO
import
pybase64
as
base64
import
pytest
import
pytest
import
torch
import
torch
from
PIL
import
Image
from
PIL
import
Image
...
...
tests/models/multimodal/pooling/test_llama_nemotron_vl.py
View file @
a836524d
...
@@ -9,10 +9,10 @@ Tests for the LlamaNemotronVL model family:
...
@@ -9,10 +9,10 @@ Tests for the LlamaNemotronVL model family:
Both variants share a SigLIP vision encoder with a bidirectional LLaMA backbone.
Both variants share a SigLIP vision encoder with a bidirectional LLaMA backbone.
"""
"""
import
base64
from
io
import
BytesIO
from
io
import
BytesIO
from
pathlib
import
Path
from
pathlib
import
Path
import
pybase64
as
base64
import
pytest
import
pytest
import
torch
import
torch
from
transformers
import
AutoModel
,
AutoModelForSequenceClassification
,
AutoProcessor
from
transformers
import
AutoModel
,
AutoModelForSequenceClassification
,
AutoProcessor
...
...
tests/multimodal/media/test_audio.py
View file @
a836524d
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
base64
from
pathlib
import
Path
from
pathlib
import
Path
from
unittest.mock
import
patch
from
unittest.mock
import
patch
import
librosa
import
librosa
import
numpy
as
np
import
numpy
as
np
import
pybase64
as
base64
import
pytest
import
pytest
from
vllm.multimodal.media
import
AudioMediaIO
from
vllm.multimodal.media
import
AudioMediaIO
...
...
tests/multimodal/media/test_connector.py
View file @
a836524d
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
asyncio
import
asyncio
import
base64
import
mimetypes
import
mimetypes
import
os
import
os
from
tempfile
import
NamedTemporaryFile
,
TemporaryDirectory
from
tempfile
import
NamedTemporaryFile
,
TemporaryDirectory
import
aiohttp
import
aiohttp
import
numpy
as
np
import
numpy
as
np
import
pybase64
as
base64
import
pytest
import
pytest
import
requests
import
requests
import
torch
import
torch
...
...
tests/plugins/prithvi_io_processor_plugin/prithvi_io_processor/prithvi_processor.py
View file @
a836524d
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
base64
import
datetime
import
datetime
import
os
import
os
import
tempfile
import
tempfile
...
@@ -11,6 +10,7 @@ from typing import Any
...
@@ -11,6 +10,7 @@ from typing import Any
import
albumentations
import
albumentations
import
numpy
as
np
import
numpy
as
np
import
pybase64
as
base64
import
rasterio
import
rasterio
import
regex
as
re
import
regex
as
re
import
torch
import
torch
...
...
tests/plugins_tests/test_terratorch_io_processor_plugins.py
View file @
a836524d
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
base64
import
io
import
io
import
imagehash
import
imagehash
import
pybase64
as
base64
import
pytest
import
pytest
import
requests
import
requests
from
PIL
import
Image
from
PIL
import
Image
...
...
tests/renderers/test_sparse_tensor_validation.py
View file @
a836524d
...
@@ -5,9 +5,9 @@ Tests verify that malicious sparse tensors are rejected before they can trigger
...
@@ -5,9 +5,9 @@ Tests verify that malicious sparse tensors are rejected before they can trigger
out-of-bounds memory writes during to_dense() operations.
out-of-bounds memory writes during to_dense() operations.
"""
"""
import
base64
import
io
import
io
import
pybase64
as
base64
import
pytest
import
pytest
import
torch
import
torch
...
...
tools/pre_commit/check_forbidden_imports.py
View file @
a836524d
...
@@ -59,6 +59,14 @@ CHECK_IMPORTS = {
...
@@ -59,6 +59,14 @@ CHECK_IMPORTS = {
"vllm/v1/serial_utils.py"
,
"vllm/v1/serial_utils.py"
,
},
},
),
),
"base64"
:
ForbiddenImport
(
pattern
=
r
"^\s*(?:import\s+base64(?:$|\s|,)|from\s+base64\s+import)"
,
tip
=
(
"Replace 'import base64' with 'import pybase64' "
"or 'import pybase64 as base64'."
),
allowed_pattern
=
re
.
compile
(
r
"^\s*import\s+pybase64(\s*|\s+as\s+base64\s*)$"
),
),
"re"
:
ForbiddenImport
(
"re"
:
ForbiddenImport
(
pattern
=
r
"^\s*(?:import\s+re(?:$|\s|,)|from\s+re\s+import)"
,
pattern
=
r
"^\s*(?:import\s+re(?:$|\s|,)|from\s+re\s+import)"
,
tip
=
"Replace 'import re' with 'import regex as re' or 'import regex'."
,
tip
=
"Replace 'import re' with 'import regex as re' or 'import regex'."
,
...
...
vllm/benchmarks/datasets.py
View file @
a836524d
...
@@ -14,7 +14,6 @@ generation. Supported dataset types include:
...
@@ -14,7 +14,6 @@ generation. Supported dataset types include:
import
argparse
import
argparse
import
ast
import
ast
import
base64
import
io
import
io
import
json
import
json
import
logging
import
logging
...
@@ -31,6 +30,7 @@ from tempfile import NamedTemporaryFile
...
@@ -31,6 +30,7 @@ from tempfile import NamedTemporaryFile
from
typing
import
Any
,
cast
from
typing
import
Any
,
cast
import
numpy
as
np
import
numpy
as
np
import
pybase64
as
base64
from
huggingface_hub
import
snapshot_download
from
huggingface_hub
import
snapshot_download
from
PIL
import
Image
from
PIL
import
Image
from
typing_extensions
import
deprecated
from
typing_extensions
import
deprecated
...
...
vllm/distributed/weight_transfer/ipc_engine.py
View file @
a836524d
...
@@ -2,12 +2,12 @@
...
@@ -2,12 +2,12 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""IPC-based weight transfer engine using CUDA IPC for communication."""
"""IPC-based weight transfer engine using CUDA IPC for communication."""
import
base64
import
pickle
import
pickle
from
collections.abc
import
Callable
,
Iterator
from
collections.abc
import
Callable
,
Iterator
from
dataclasses
import
asdict
,
dataclass
from
dataclasses
import
asdict
,
dataclass
from
typing
import
Any
from
typing
import
Any
import
pybase64
as
base64
import
requests
import
requests
import
torch
import
torch
from
torch.multiprocessing.reductions
import
reduce_tensor
from
torch.multiprocessing.reductions
import
reduce_tensor
...
...
vllm/entrypoints/openai/realtime/connection.py
View file @
a836524d
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
asyncio
import
asyncio
import
base64
import
json
import
json
from
collections.abc
import
AsyncGenerator
from
collections.abc
import
AsyncGenerator
from
http
import
HTTPStatus
from
http
import
HTTPStatus
from
uuid
import
uuid4
from
uuid
import
uuid4
import
numpy
as
np
import
numpy
as
np
import
pybase64
as
base64
from
fastapi
import
WebSocket
from
fastapi
import
WebSocket
from
starlette.websockets
import
WebSocketDisconnect
from
starlette.websockets
import
WebSocketDisconnect
...
...
vllm/entrypoints/openai/run_batch.py
View file @
a836524d
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
asyncio
import
asyncio
import
base64
import
sys
import
sys
import
tempfile
import
tempfile
from
argparse
import
Namespace
from
argparse
import
Namespace
...
@@ -13,6 +12,7 @@ from typing import Any, TypeAlias
...
@@ -13,6 +12,7 @@ from typing import Any, TypeAlias
from
urllib.parse
import
urlparse
from
urllib.parse
import
urlparse
import
aiohttp
import
aiohttp
import
pybase64
as
base64
import
torch
import
torch
from
fastapi
import
UploadFile
from
fastapi
import
UploadFile
from
prometheus_client
import
start_http_server
from
prometheus_client
import
start_http_server
...
...
vllm/entrypoints/pooling/embed/protocol.py
View file @
a836524d
...
@@ -6,13 +6,13 @@ OpenAI: https://platform.openai.com/docs/api-reference/embeddings
...
@@ -6,13 +6,13 @@ OpenAI: https://platform.openai.com/docs/api-reference/embeddings
Cohere: https://docs.cohere.com/reference/embed
Cohere: https://docs.cohere.com/reference/embed
"""
"""
import
base64
import
builtins
import
builtins
import
struct
import
struct
import
time
import
time
from
collections.abc
import
Sequence
from
collections.abc
import
Sequence
from
typing
import
Literal
,
TypeAlias
from
typing
import
Literal
,
TypeAlias
import
pybase64
as
base64
from
pydantic
import
BaseModel
,
Field
from
pydantic
import
BaseModel
,
Field
from
vllm
import
PoolingParams
from
vllm
import
PoolingParams
...
...
vllm/multimodal/media/audio.py
View file @
a836524d
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
base64
from
io
import
BytesIO
from
io
import
BytesIO
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -138,7 +137,7 @@ class AudioMediaIO(MediaIO[tuple[npt.NDArray, float]]):
...
@@ -138,7 +137,7 @@ class AudioMediaIO(MediaIO[tuple[npt.NDArray, float]]):
media_type
:
str
,
media_type
:
str
,
data
:
str
,
data
:
str
,
)
->
tuple
[
npt
.
NDArray
,
float
]:
)
->
tuple
[
npt
.
NDArray
,
float
]:
return
self
.
load_bytes
(
base64
.
b64decode
(
data
))
return
self
.
load_bytes
(
py
base64
.
b64decode
(
data
))
def
load_file
(
self
,
filepath
:
Path
)
->
tuple
[
npt
.
NDArray
,
float
]:
def
load_file
(
self
,
filepath
:
Path
)
->
tuple
[
npt
.
NDArray
,
float
]:
return
librosa
.
load
(
filepath
,
sr
=
None
)
return
librosa
.
load
(
filepath
,
sr
=
None
)
...
@@ -155,7 +154,7 @@ class AudioMediaIO(MediaIO[tuple[npt.NDArray, float]]):
...
@@ -155,7 +154,7 @@ class AudioMediaIO(MediaIO[tuple[npt.NDArray, float]]):
soundfile
.
write
(
buffer
,
audio
,
sr
,
format
=
audio_format
)
soundfile
.
write
(
buffer
,
audio
,
sr
,
format
=
audio_format
)
data
=
buffer
.
getvalue
()
data
=
buffer
.
getvalue
()
return
base64
.
b64encode
(
data
).
decode
(
"utf-8"
)
return
py
base64
.
b64encode
(
data
).
decode
(
"utf-8"
)
class
AudioEmbeddingMediaIO
(
MediaIO
[
torch
.
Tensor
]):
class
AudioEmbeddingMediaIO
(
MediaIO
[
torch
.
Tensor
]):
...
...
vllm/multimodal/media/video.py
View file @
a836524d
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
base64
from
functools
import
partial
from
functools
import
partial
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Any
from
typing
import
Any
import
numpy
as
np
import
numpy
as
np
import
numpy.typing
as
npt
import
numpy.typing
as
npt
import
pybase64
from
PIL
import
Image
from
PIL
import
Image
from
vllm
import
envs
from
vllm
import
envs
...
@@ -84,7 +84,7 @@ class VideoMediaIO(MediaIO[tuple[npt.NDArray, dict[str, Any]]]):
...
@@ -84,7 +84,7 @@ class VideoMediaIO(MediaIO[tuple[npt.NDArray, dict[str, Any]]]):
[
np
.
asarray
(
load_frame
(
frame_data
))
for
frame_data
in
data
.
split
(
","
)]
[
np
.
asarray
(
load_frame
(
frame_data
))
for
frame_data
in
data
.
split
(
","
)]
),
{}
),
{}
return
self
.
load_bytes
(
base64
.
b64decode
(
data
))
return
self
.
load_bytes
(
py
base64
.
b64decode
(
data
))
def
load_file
(
self
,
filepath
:
Path
)
->
tuple
[
npt
.
NDArray
,
dict
[
str
,
Any
]]:
def
load_file
(
self
,
filepath
:
Path
)
->
tuple
[
npt
.
NDArray
,
dict
[
str
,
Any
]]:
with
filepath
.
open
(
"rb"
)
as
f
:
with
filepath
.
open
(
"rb"
)
as
f
:
...
...
Prev
1
2
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