Skip to content

Commit

Permalink
[Bugfix] More type hint fixes for py 3.8 (vllm-project#4039)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanwhawk authored Apr 13, 2024
1 parent 546e721 commit 5c2e66e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion vllm/executor/executor_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def determine_num_available_blocks(self) -> Tuple[int, int]:
ExecutorBase may require modification of the result, e.g. to ensure the
selected cache sizes are compatible with all workers.
Returns a tuple[num_gpu_blocks, num_cpu_blocks], where num_gpu_blocks
Returns a Tuple[num_gpu_blocks, num_cpu_blocks], where num_gpu_blocks
are blocks that are "active" on the device and can be appended to.
num_cpu_blocks refers to "swapped" blocks in CPU memory and cannot be
appended to.
Expand Down
4 changes: 2 additions & 2 deletions vllm/worker/cpu_worker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""A CPU worker class."""
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Tuple

import torch
import torch.distributed
Expand Down Expand Up @@ -157,7 +157,7 @@ def init_device(self) -> None:
def load_model(self):
self.model_runner.load_model()

def determine_num_available_blocks(self) -> tuple[int, int]:
def determine_num_available_blocks(self) -> Tuple[int, int]:
"""Determine the number of blocks available for the KV cache.
This determines how many KV blocks can fit into the configured CPU
Expand Down
4 changes: 2 additions & 2 deletions vllm/worker/neuron_worker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""A Neuron worker class."""
from typing import List, Optional
from typing import List, Optional, Tuple

import torch
import torch.distributed
Expand Down Expand Up @@ -40,7 +40,7 @@ def init_device(self) -> None:
def load_model(self):
self.model_runner.load_model()

def determine_num_available_blocks(self) -> tuple[int, int]:
def determine_num_available_blocks(self) -> Tuple[int, int]:
"""Determine the number of available KV blocks.
Swapping is not yet supported, so always return num_cpu_blocks=0.
Expand Down
6 changes: 3 additions & 3 deletions vllm/worker/worker_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import Dict, List
from typing import Dict, List, Tuple

from vllm.lora.request import LoRARequest
from vllm.sequence import SamplerOutput, SequenceGroupMetadata
Expand All @@ -18,14 +18,14 @@ def init_device(self) -> None:
raise NotImplementedError

@abstractmethod
def determine_num_available_blocks(self) -> tuple[int, int]:
def determine_num_available_blocks(self) -> Tuple[int, int]:
"""Determine the number of available blocks for the GPU KV cache and
swappable CPU KV cache.
The implementation may run profiling or other heuristics to determine
the size of caches.
Returns a tuple[num_gpu_blocks, num_cpu_blocks], where num_gpu_blocks
Returns a Tuple[num_gpu_blocks, num_cpu_blocks], where num_gpu_blocks
are blocks that are "active" on the device and can be appended to.
num_cpu_blocks refers to "swapped" blocks in CPU memory and cannot be
appended to.
Expand Down

0 comments on commit 5c2e66e

Please sign in to comment.