nano-vllm README

The project's README from github.com/GeeeekExplorer/nano-vllm. As one markdown file: README.md.

GeeeekExplorer%2Fnano-vllm | Trendshift

Nano-vLLM

A lightweight vLLM implementation built from scratch.

Key Features

Installation

pip install git+https://github.com/GeeeekExplorer/nano-vllm.git

Model Download

To download the model weights manually, use the following command:

huggingface-cli download --resume-download Qwen/Qwen3-0.6B \
  --local-dir ~/huggingface/Qwen3-0.6B/ \
  --local-dir-use-symlinks False

Quick Start

See example.py for usage. The API mirrors vLLM's interface with minor differences in the LLM.generate method:

from nanovllm import LLM, SamplingParams
llm = LLM("/YOUR/MODEL/PATH", enforce_eager=True, tensor_parallel_size=1)
sampling_params = SamplingParams(temperature=0.6, max_tokens=256)
prompts = ["Hello, Nano-vLLM."]
outputs = llm.generate(prompts, sampling_params)
outputs[0]["text"]

Benchmark

See bench.py for benchmark.

Test Configuration:

Performance Results:

Inference Engine Output Tokens Time (s) Throughput (tokens/s)
vLLM 133,966 98.37 1361.84
Nano-vLLM 133,966 93.41 1434.13

Star History

Star History Chart

nano-vllm (GeeeekExplorer/nano-vllm)

Searching Database…

15.9K ·GitHub
这是什么?Nano-vLLM 是对 vLLM 推理引擎的一个轻量级、从零重写的实现,用于运行大语言模型,全部代码约 1200 行,可读性很强。
这是独立的服务器,还是我可以在自己代码里调用的库?它是一个 Python 库:你创建一个 LLM 对象,然后在自己的脚本中调用 generate(),接口与 vLLM 几乎完全一致。
怎么让它跑起来?先按照 README 的 Installation 部分安装软件包,再用 Model Download 下给出的命令手动下载模型权重,最后运行 example.py,就能看到一个可用的 generate() 调用示例。
运行它需要 CUDA GPU 吗?需要。它依靠张量并行(Tensor Parallelism)和 CUDA 图捕获来提速,项目自带的基准测试是在 NVIDIA RTX 4070 Laptop GPU 上完成的。
它和完整的 vLLM 相比究竟怎么样?在项目自己的基准测试中,使用 Qwen3-0.6B 模型、256 个请求,Nano-vLLM 达到每秒 1434 个 token,vLLM 为每秒 1362 个 token,因此它与 vLLM 持平,甚至略胜一筹,而代码量只是其中很小的一部分。
Nano-vLLM 开箱即用包含哪些优化?它实现了前缀缓存(prefix caching)、张量并行、torch 编译以及 CUDA 图捕获,以加快推理速度。
为什么有人会选择 Nano-vLLM 而不是常规的 vLLM?它的吞吐量与 vLLM 相当或略高,同时只有约 1200 行 Python 代码,易于阅读和修改,而 vLLM 的代码库要大得多。
它的基准测试用了什么模型和配置?README 中的基准测试使用 Qwen3-0.6B 模型,在 RTX 4070 Laptop GPU(8GB)上运行,共 256 个请求,输入和输出长度在 100 到 1024 个 token 之间随机取样。
Size
0.5 MB
Stars
15.9K
Updated
CommitApr 26
Age
1y
Commits · 90 Days