forked from HabanaAI/vllm-fork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fake HPU mode to Habana components with dummy habana_frameworks m…
…odule. (HabanaAI#250) Co-authored-by: Konrad Zawora <kzawora@habana.ai>
- Loading branch information
Showing
11 changed files
with
177 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: cpu-test | ||
|
||
on: | ||
# Trigger the workflow on push or pull request, | ||
# but only for the habana_main branch | ||
push: | ||
branches: | ||
- habana_main | ||
pull_request: | ||
branches: | ||
- habana_main | ||
|
||
|
||
jobs: | ||
cputest: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install torch --extra-index-url https://download.pytorch.org/whl/cpu | ||
pip install -r requirements-hpu.txt | ||
VLLM_TARGET_DEVICE=hpu python setup.py develop | ||
- name: cpu-test | ||
run: | | ||
VLLM_SKIP_WARMUP=true VLLM_PROMPT_SEQ_BUCKET_MAX=128 VLLM_USE_FAKE_HPU=1 python examples/offline_inference_fakehpu.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
|
||
from vllm import LLM, SamplingParams | ||
|
||
if os.environ.get('VLLM_USE_FAKE_HPU', '0') != '0': | ||
from vllm.utils import migrate_to_cpu | ||
migrate_to_cpu() | ||
|
||
# Sample prompts. | ||
prompts = [ | ||
"Berlin is the capital city of ", | ||
"Louvre is located in the city of ", | ||
"Barack Obama was the 44th president of ", | ||
"Warsaw is the capital city of ", | ||
"Gniezno is a city in ", | ||
"San Francisco is located in the state of ", | ||
"Llanfairpwllgwyngyll is located in country of ", | ||
] | ||
ref_answers = [ | ||
"Germany", "Paris", "United States", "Poland", "Poland", "California", | ||
"Wales" | ||
] | ||
# Create a sampling params object. | ||
sampling_params = SamplingParams(temperature=0, n=1, use_beam_search=False) | ||
|
||
# Create an LLM. | ||
llm = LLM(model="facebook/opt-125m", max_model_len=32, max_num_seqs=4) | ||
# Generate texts from the prompts. The output is a list of RequestOutput objects | ||
# that contain the prompt, generated text, and other information. | ||
outputs = llm.generate(prompts, sampling_params) | ||
# Print the outputs. | ||
for output, answer in zip(outputs, ref_answers): | ||
prompt = output.prompt | ||
generated_text = output.outputs[0].text | ||
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}") | ||
assert answer in generated_text, ( | ||
f"The generated text does not contain the correct answer: {answer}") | ||
print('PASSED') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters