Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions inference/arctic/vllm/offline_inference_arctic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import os
from vllm import LLM, SamplingParams
import logging

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Sample prompts.
prompts = [
Expand All @@ -7,20 +13,25 @@
"The capital of France is",
"The future of AI is",
]

# Create a sampling params object.
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)

# Fetch Arctic model path from environment variable or use default.
arctic_model_path = os.getenv('ARCTIC_MODEL_PATH', '/checkpoint/arctic')
logger.info(f'Using arctic model path: {arctic_model_path}')

# Create an LLM.
arctic_model_path = "/checkpoint/arctic"
llm = LLM(model=arctic_model_path,
quantization="deepspeedfp",
tensor_parallel_size=8)

# 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 in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
logger.info(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")