Skip to content

Commit 37f3c78

Browse files
committed
Using functools.cache approach
Signed-off-by: lianyibo <[email protected]>
1 parent 108b4e3 commit 37f3c78

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

vllm_ascend/core/scheduler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def __init__(
5353
include_finished_set, log_stats)
5454
self.scheduled_req_ids: set[str] = set()
5555
self.running: list[Request] = []
56-
self.lock_version = vllm_version_is("0.9.2")
5756

5857
def schedule(self) -> SchedulerOutput:
5958
if self.scheduler_config.chunked_prefill_enabled:
@@ -284,13 +283,13 @@ def skip_cur_request():
284283
# allow the lower-priority requests to be scheduled.
285284
req_index += 1
286285
continue
287-
if self.lock_version:
286+
if vllm_version_is("0.9.2"):
288287
num_draft_tokens = max(
289288
num_new_tokens + request.num_computed_tokens -
290289
request.num_tokens, 0)
291290

292291
while True:
293-
if self.lock_version:
292+
if vllm_version_is("0.9.2"):
294293
new_blocks = self.kv_cache_manager.allocate_slots(
295294
request,
296295
num_new_tokens,

vllm_ascend/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import math
2323
import os
2424
import shutil
25+
import functools
2526
from contextlib import contextmanager, nullcontext
2627
from enum import Enum
2728
from threading import Lock
@@ -280,6 +281,7 @@ def adapt_patch(is_global_patch: bool = False):
280281
from vllm_ascend.patch import worker # noqa: F401
281282

282283

284+
@functools.cache
283285
def vllm_version_is(target_vllm_version: str):
284286
if envs.VLLM_VERSION is not None:
285287
vllm_version = envs.VLLM_VERSION

0 commit comments

Comments
 (0)