Quick Start with Nano-vLLM
mainNano-vLLM provides an API that mirrors vLLM's interface. You can perform offline inference by initializing the LLM class and using the generate method. Note that the LLM.generate method signature may have minor differences compared to the original vLLM.
from nanovllm import LLM, SamplingParams
# Initialize the LLM engine
# enforce_eager: boolean to control eager mode
# tensor_parallel_size: number of GPUs for tensor parallelism
llm = LLM("/YOUR/MODEL/PATH", enforce_eager=True, tensor_parallel_size=1)
# Configure sampling parameters
sampling_params = SamplingParams(temperature=0.6, max_tokens=256)
# Define prompts and generate outputs
prompts = ["Hello, Nano-vLLM."]
outputs = llm.generate(prompts, sampling_params)
# Access the generated text
print(outputs[0]["text"])