Skip to content

Commit

Permalink
Change device in DeviceConfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaksymczuk committed Sep 5, 2024
1 parent 13dc1f5 commit 2a01a4b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpu-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
VLLM_TARGET_DEVICE=hpu python setup.py develop
- name: cpu-test
run: |
VLLM_SKIP_WARMUP=true VLLM_PROMPT_SEQ_BUCKET_MAX=128 python examples/offline_inference_fakehpu.py --fake_hpu
VLLM_SKIP_WARMUP=true VLLM_PROMPT_SEQ_BUCKET_MAX=128 VLLM_USE_FAKE_HPU=1 python examples/offline_inference_fakehpu.py --fake_hpu
4 changes: 3 additions & 1 deletion vllm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from vllm.tracing import is_otel_installed
from vllm.transformers_utils.config import get_config, get_hf_text_config
from vllm.utils import (cuda_device_count_stateless, get_cpu_memory, is_cpu,
is_hip, is_hpu, is_neuron, is_openvino, is_tpu, is_xpu,
is_hip, is_hpu, is_fake_hpu, is_neuron, is_openvino, is_tpu, is_xpu,
print_warning_once)

if TYPE_CHECKING:
Expand Down Expand Up @@ -858,6 +858,8 @@ def __init__(self, device: str = "auto") -> None:
# Automated device type detection
if is_neuron():
self.device_type = "neuron"
elif is_fake_hpu():
self.device_type = "cpu"
elif is_hpu():
self.device_type = "hpu"
elif is_openvino():
Expand Down
6 changes: 4 additions & 2 deletions vllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def is_fake_hpu() -> bool:

@lru_cache(maxsize=None)
def _is_habana_frameworks_installed() -> bool:
if os.environ.get('VLLM_USE_FAKE_HPU', '0') != '0' : return False
from importlib import util
return util.find_spec('habana_frameworks') is not None

Expand Down Expand Up @@ -997,7 +998,9 @@ def cuda_device_count_stateless() -> int:


def get_device() -> str:
if is_hpu():
if is_fake_hpu():
return "cpu"
elif is_hpu():
return "hpu"
return "cuda"

Expand Down Expand Up @@ -1143,7 +1146,6 @@ def _return_false():

def _migrate_to_cpu():
import habana_frameworks.torch as htorch

htorch.core.mark_step = _do_nothing
htorch.utils.internal.is_lazy = _return_false
torch.hpu.synchronize = _do_nothing
Expand Down

0 comments on commit 2a01a4b

Please sign in to comment.