diff --git a/docs/contributing/profiling.md b/docs/contributing/profiling.md index 91757c40e4f8..ce46445a983c 100644 --- a/docs/contributing/profiling.md +++ b/docs/contributing/profiling.md @@ -201,43 +201,45 @@ The profiling traces generated by the continuous profiling workflow are publicly The Python standard library includes [cProfile](https://docs.python.org/3/library/profile.html) for profiling Python -code. vLLM includes a couple of helpers that make it easy to apply it to a section of vLLM. -Both the `vllm.utils.profiling.cprofile` and `vllm.utils.profiling.cprofile_context` functions can be -used to profile a section of code. +code. -!!! note - The `vllm.utils.profiling` helpers are deprecated and will be removed in - `v0.21`. Please use Python's `cProfile` module directly instead. - -### Example usage - decorator +### Example usage - function call -The first helper is a Python decorator that can be used to profile a function. -If a filename is specified, the profile will be saved to that file. If no filename is -specified, profile data will be printed to stdout. +If a filename is specified, the profile will be saved to that file. If no +filename is specified, profile data can be printed to stdout. ```python -from vllm.utils.profiling import cprofile +import cProfile + -@cprofile("expensive_function.prof") def expensive_function(): # some expensive code pass -``` -### Example Usage - context manager -The second helper is a context manager that can be used to profile a block of -code. Similar to the decorator, the filename is optional. +profiler = cProfile.Profile() +profiler.runcall(expensive_function) +profiler.dump_stats("expensive_function.prof") +``` + +### Example usage - context manager style ```python -from vllm.utils.profiling import cprofile_context +import cProfile + def another_function(): # more expensive code pass -with cprofile_context("another_function.prof"): + +profiler = cProfile.Profile() +profiler.enable() +try: another_function() +finally: + profiler.disable() + profiler.dump_stats("another_function.prof") ``` ### Analyzing Profile Results diff --git a/docs/models/pooling_models/classify.md b/docs/models/pooling_models/classify.md index 6f361e3fd3ae..6860b09c31ea 100644 --- a/docs/models/pooling_models/classify.md +++ b/docs/models/pooling_models/classify.md @@ -299,7 +299,3 @@ Example configuration: ### Remove softmax from PoolingParams We have already removed `softmax` and `activation` from PoolingParams. Instead, use `use_activation`, since we allow `classify` and `token_classify` to use any activation function. - -### Remove `logit_bias` and `logit_scale` - -`logit_bias` and `logit_scale` are deprecated aliases for `logit_mean` and `logit_sigma` respectively. When using `logit_scale`, it is automatically converted to `logit_sigma = 1/logit_scale`. These deprecated parameters will be removed in v0.21. diff --git a/vllm/config/pooler.py b/vllm/config/pooler.py index f8eefb7c2ba4..b52b0abd1d21 100644 --- a/vllm/config/pooler.py +++ b/vllm/config/pooler.py @@ -92,18 +92,6 @@ class PoolerConfig: activation((logit - logit_mean) / logit_sigma). Defaults to None. """ - # Deprecated aliases — will be removed in v0.21 - logit_bias: float | None = None - """ - Deprecated: Use logit_mean instead. Will be removed in v0.21. - """ - - logit_scale: float | None = None - """ - Deprecated: Use logit_sigma instead (note: logit_sigma = 1/logit_scale). - Will be removed in v0.21. - """ - ## for reward models step_tag_id: int | None = None """ @@ -119,36 +107,6 @@ class PoolerConfig: """ def __post_init__(self) -> None: - # Handle deprecated logit_bias → logit_mean - if self.logit_bias is not None: - if self.logit_mean is not None: - raise ValueError( - "Cannot set both `logit_bias` and `logit_mean`. " - "`logit_bias` is deprecated, use `logit_mean` instead." - ) - logger.warning( - "`logit_bias` is deprecated and will be removed in v0.21. " - "Use `logit_mean` instead." - ) - self.logit_mean = self.logit_bias - self.logit_bias = None - - # Handle deprecated logit_scale → logit_sigma - if self.logit_scale is not None: - if self.logit_sigma is not None: - raise ValueError( - "Cannot set both `logit_scale` and `logit_sigma`. " - "`logit_scale` is deprecated, use `logit_sigma` instead." - ) - logger.warning( - "`logit_scale` is deprecated and will be removed in v0.21. " - "Use `logit_sigma` instead (logit_sigma = 1/logit_scale)." - ) - if self.logit_scale == 0: - raise ValueError("logit_scale cannot be 0 (division by zero)") - self.logit_sigma = 1.0 / self.logit_scale - self.logit_scale = None - if self.logit_sigma is not None and self.logit_sigma == 0: raise ValueError("logit_sigma cannot be 0 (division by zero)") diff --git a/vllm/utils/profiling.py b/vllm/utils/profiling.py deleted file mode 100644 index ce2a5ba3993a..000000000000 --- a/vllm/utils/profiling.py +++ /dev/null @@ -1,66 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# SPDX-FileCopyrightText: Copyright contributors to the vLLM project - -from __future__ import annotations - -import contextlib -from collections.abc import Callable -from functools import wraps -from typing import Any - -from typing_extensions import deprecated - - -@deprecated( - "vllm.utils.profiling.cprofile_context() is deprecated and will be removed " - "in v0.21. Use Python's cProfile module directly instead." -) -@contextlib.contextmanager -def cprofile_context(save_file: str | None = None): - """Run a cprofile - - Args: - save_file: path to save the profile result. "1" or - None will result in printing to stdout. - """ - import cProfile - - prof = cProfile.Profile() - prof.enable() - - try: - yield - finally: - prof.disable() - if save_file and save_file != "1": - prof.dump_stats(save_file) - else: - prof.print_stats(sort="cumtime") - - -@deprecated( - "vllm.utils.profiling.cprofile() is deprecated and will be removed in " - "v0.21. Use Python's cProfile module directly instead." -) -def cprofile(save_file: str | None = None, enabled: bool = True): - """Decorator to profile a Python method using cProfile. - - Args: - save_file: Path to save the profile result. - If "1", None, or "", results will be printed to stdout. - enabled: Set to false to turn this into a no-op - """ - - def decorator(func: Callable): - @wraps(func) - def wrapper(*args: Any, **kwargs: Any): - if not enabled: - # If profiling is disabled, just call the function directly. - return func(*args, **kwargs) - - with cprofile_context(save_file): - return func(*args, **kwargs) - - return wrapper - - return decorator