GeeeekExplorer/nano-vllm

GitHub: GeeeekExplorer/nano-vllm

一个仅约 1,200 行 Python 实现的轻量级 LLM 推理引擎,以极简代码复现 vLLM 的核心优化能力并保持媲美的推理性能。

Stars: 14488 | Forks: 2326

GeeeekExplorer%2Fnano-vllm | Trendshift

# Nano-vLLM 一个从零开始构建的轻量级 vLLM 实现。 ## 核心特性 * 🚀 **快速离线推理** - 推理速度可与 vLLM 媲美 * 📖 **高可读性代码** - 仅使用约 1,200 行 Python 代码实现,简洁明了 * ⚡ **优化套件** - Prefix caching、Tensor Parallelism、Torch compilation、CUDA graph 等 ## 安装 ``` pip install git+https://github.com/GeeeekExplorer/nano-vllm.git ``` ## 模型下载 要手动下载模型权重,请使用以下命令: ``` huggingface-cli download --resume-download Qwen/Qwen3-0.6B \ --local-dir ~/huggingface/Qwen3-0.6B/ \ --local-dir-use-symlinks False ``` ## 快速开始 有关用法,请参阅 `example.py`。该 API 与 vLLM 的接口类似,但在 `LLM.generate` 方法上存在微小差异: ``` 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"] ``` ## 基准测试 有关基准测试,请参阅 `bench.py`。 **测试配置:** - 硬件:RTX 4070 Laptop (8GB) - 模型:Qwen3-0.6B - 总请求数:256 个序列 - 输入长度:在 100–1024 个 token 之间随机采样 - 输出长度:在 100–1024 个 token 之间随机采样 **性能结果:** | 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 历史 [![Star History Chart](https://api.star-history.com/svg?repos=GeeeekExplorer/nano-vllm&type=Date)](https://www.star-history.com/#GeeeekExplorer/nano-vllm&Date)
标签:AI, DLL 劫持, Python, Vectored Exception Handling, 凭据扫描, 大语言模型, 推理优化, 无后门, 模型推理, 自动化代码审查, 逆向工具