[Core][Misc] Clean up ProfileExecuteDuration (#6461)
### What this PR does / why we need it?
This PR removes the custom `ProfileExecuteDuration` utility and its
usages across the codebase. This utility was used for profiling
execution duration of different stages in the inference process. It is
replaced by the standard `vllm.v1.utils.record_function_or_nullcontext`,
which integrates with PyTorch's profiler.
This change simplifies the code by removing a custom implementation in
favor of an upstream utility, improving maintainability. Associated
documentation and tests for `ProfileExecuteDuration` are also removed.
### Does this PR introduce _any_ user-facing change?
`VLLM_ASCEND_MODEL_EXECUTE_TIME_OBSERVE` env is removed now.
### How was this patch tested?
CI passed. The changes are a cleanup and replacement with a standard
utility. Existing tests cover the functionality. The removed feature had
its own tests which are also removed.
Related RFC: #5304
- vLLM version: v0.14.1
- vLLM main:
dc917cceb8
Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
This commit is contained in:
@@ -246,56 +246,3 @@ class TestUtils(TestBase):
|
||||
utils.register_ascend_customop()
|
||||
self.assertEqual(mock_customop.register_oot.call_count,
|
||||
len(REGISTERED_ASCEND_OPS))
|
||||
|
||||
|
||||
class TestProfileExecuteDuration(TestBase):
|
||||
|
||||
def setUp(self):
|
||||
utils.ProfileExecuteDuration._instance = None
|
||||
utils.ProfileExecuteDuration._observations = []
|
||||
utils.ProfileExecuteDuration._lock = Lock()
|
||||
|
||||
def test_singleton_creation(self):
|
||||
instance1 = utils.ProfileExecuteDuration()
|
||||
self.assertIsNotNone(instance1)
|
||||
self.assertIs(instance1, utils.ProfileExecuteDuration._instance)
|
||||
|
||||
instance2 = utils.ProfileExecuteDuration()
|
||||
self.assertIs(instance1, instance2)
|
||||
|
||||
def test_thread_safety(self):
|
||||
from threading import Thread
|
||||
|
||||
instances = []
|
||||
|
||||
def create_instance():
|
||||
instances.append(utils.ProfileExecuteDuration())
|
||||
|
||||
threads = [Thread(target=create_instance) for _ in range(10)]
|
||||
for t in threads:
|
||||
t.start()
|
||||
for t in threads:
|
||||
t.join()
|
||||
|
||||
first_instance = instances[0]
|
||||
for instance in instances[1:]:
|
||||
self.assertIs(first_instance, instance)
|
||||
|
||||
def test_atexit_registration(self):
|
||||
with mock.patch('atexit.register') as mock_register:
|
||||
instance = utils.ProfileExecuteDuration()
|
||||
mock_register.assert_called_once_with(instance.destroy)
|
||||
|
||||
def test_lock_usage(self):
|
||||
original_lock = utils.ProfileExecuteDuration._lock
|
||||
|
||||
with mock.patch.object(utils.ProfileExecuteDuration,
|
||||
'_lock',
|
||||
wraps=original_lock) as mock_lock:
|
||||
utils.ProfileExecuteDuration()
|
||||
mock_lock.__enter__.assert_called()
|
||||
mock_lock.__exit__.assert_called()
|
||||
|
||||
def test_observations_initialization(self):
|
||||
instance = utils.ProfileExecuteDuration()
|
||||
self.assertEqual(instance._observations, [])
|
||||
|
||||
Reference in New Issue
Block a user