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
bf5eec63
Unverified
Commit
bf5eec63
authored
Mar 26, 2026
by
Wentao Ye
Committed by
GitHub
Mar 26, 2026
Browse files
[Refactor] Remove unused utils (#38153)
Signed-off-by:
yewentao256
<
zhyanwentao@126.com
>
parent
b1cb1d3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
140 deletions
+2
-140
tests/utils_/test_func_utils.py
tests/utils_/test_func_utils.py
+1
-58
vllm/utils/func_utils.py
vllm/utils/func_utils.py
+1
-77
vllm/utils/math_utils.py
vllm/utils/math_utils.py
+0
-5
No files found.
tests/utils_/test_func_utils.py
View file @
bf5eec63
...
...
@@ -4,64 +4,7 @@
import
pytest
from
vllm.utils.func_utils
import
deprecate_kwargs
,
supports_kw
from
..utils
import
error_on_warning
def
test_deprecate_kwargs_always
():
@
deprecate_kwargs
(
"old_arg"
,
is_deprecated
=
True
)
def
dummy
(
*
,
old_arg
:
object
=
None
,
new_arg
:
object
=
None
):
pass
with
pytest
.
warns
(
DeprecationWarning
,
match
=
"'old_arg'"
):
dummy
(
old_arg
=
1
)
with
error_on_warning
(
DeprecationWarning
):
dummy
(
new_arg
=
1
)
def
test_deprecate_kwargs_never
():
@
deprecate_kwargs
(
"old_arg"
,
is_deprecated
=
False
)
def
dummy
(
*
,
old_arg
:
object
=
None
,
new_arg
:
object
=
None
):
pass
with
error_on_warning
(
DeprecationWarning
):
dummy
(
old_arg
=
1
)
with
error_on_warning
(
DeprecationWarning
):
dummy
(
new_arg
=
1
)
def
test_deprecate_kwargs_dynamic
():
is_deprecated
=
True
@
deprecate_kwargs
(
"old_arg"
,
is_deprecated
=
lambda
:
is_deprecated
)
def
dummy
(
*
,
old_arg
:
object
=
None
,
new_arg
:
object
=
None
):
pass
with
pytest
.
warns
(
DeprecationWarning
,
match
=
"'old_arg'"
):
dummy
(
old_arg
=
1
)
with
error_on_warning
(
DeprecationWarning
):
dummy
(
new_arg
=
1
)
is_deprecated
=
False
with
error_on_warning
(
DeprecationWarning
):
dummy
(
old_arg
=
1
)
with
error_on_warning
(
DeprecationWarning
):
dummy
(
new_arg
=
1
)
def
test_deprecate_kwargs_additional_message
():
@
deprecate_kwargs
(
"old_arg"
,
is_deprecated
=
True
,
additional_message
=
"abcd"
)
def
dummy
(
*
,
old_arg
:
object
=
None
,
new_arg
:
object
=
None
):
pass
with
pytest
.
warns
(
DeprecationWarning
,
match
=
"abcd"
):
dummy
(
old_arg
=
1
)
from
vllm.utils.func_utils
import
supports_kw
@
pytest
.
mark
.
parametrize
(
...
...
vllm/utils/func_utils.py
View file @
bf5eec63
...
...
@@ -8,9 +8,8 @@ This is similar in concept to the `functools` module.
import
inspect
import
threading
import
warnings
from
collections.abc
import
Callable
,
Mapping
from
functools
import
lru_cache
,
partial
,
wraps
from
functools
import
lru_cache
from
typing
import
Any
,
TypeVar
from
typing_extensions
import
ParamSpec
...
...
@@ -45,81 +44,6 @@ def run_once(f: Callable[P, None]) -> Callable[P, None]:
return
wrapper
def
deprecate_args
(
start_index
:
int
,
is_deprecated
:
bool
|
Callable
[[],
bool
]
=
True
,
additional_message
:
str
|
None
=
None
,
)
->
Callable
[[
F
],
F
]:
if
not
callable
(
is_deprecated
):
is_deprecated
=
partial
(
identity
,
is_deprecated
)
def
wrapper
(
fn
:
F
)
->
F
:
params
=
inspect
.
signature
(
fn
).
parameters
pos_types
=
(
inspect
.
Parameter
.
POSITIONAL_ONLY
,
inspect
.
Parameter
.
POSITIONAL_OR_KEYWORD
,
)
pos_kws
=
[
kw
for
kw
,
param
in
params
.
items
()
if
param
.
kind
in
pos_types
]
@
wraps
(
fn
)
def
inner
(
*
args
,
**
kwargs
):
if
is_deprecated
():
deprecated_args
=
pos_kws
[
start_index
:
len
(
args
)]
if
deprecated_args
:
msg
=
(
f
"The positional arguments
{
deprecated_args
}
are "
"deprecated and will be removed in a future update."
)
if
additional_message
is
not
None
:
msg
+=
f
"
{
additional_message
}
"
warnings
.
warn
(
DeprecationWarning
(
msg
),
stacklevel
=
3
,
# The inner function takes up one level
)
return
fn
(
*
args
,
**
kwargs
)
return
inner
# type: ignore
return
wrapper
def
deprecate_kwargs
(
*
kws
:
str
,
is_deprecated
:
bool
|
Callable
[[],
bool
]
=
True
,
additional_message
:
str
|
None
=
None
,
)
->
Callable
[[
F
],
F
]:
deprecated_kws
=
set
(
kws
)
if
not
callable
(
is_deprecated
):
is_deprecated
=
partial
(
identity
,
is_deprecated
)
def
wrapper
(
fn
:
F
)
->
F
:
@
wraps
(
fn
)
def
inner
(
*
args
,
**
kwargs
):
if
is_deprecated
():
deprecated_kwargs
=
kwargs
.
keys
()
&
deprecated_kws
if
deprecated_kwargs
:
msg
=
(
f
"The keyword arguments
{
deprecated_kwargs
}
are "
"deprecated and will be removed in a future update."
)
if
additional_message
is
not
None
:
msg
+=
f
"
{
additional_message
}
"
warnings
.
warn
(
DeprecationWarning
(
msg
),
stacklevel
=
3
,
# The inner function takes up one level
)
return
fn
(
*
args
,
**
kwargs
)
return
inner
# type: ignore
return
wrapper
@
lru_cache
def
supports_kw
(
callable
:
Callable
[...,
object
],
...
...
vllm/utils/math_utils.py
View file @
bf5eec63
...
...
@@ -17,11 +17,6 @@ def next_power_of_2(n: int) -> int:
return
1
if
n
<
1
else
1
<<
(
n
-
1
).
bit_length
()
def
prev_power_of_2
(
n
:
int
)
->
int
:
"""The previous power of 2 (inclusive)"""
return
0
if
n
<=
0
else
1
<<
(
n
.
bit_length
()
-
1
)
def
round_up
(
x
:
int
,
y
:
int
)
->
int
:
"""Round up x to the nearest multiple of y."""
return
((
x
+
y
-
1
)
//
y
)
*
y
...
...
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