Files
nexus/wiki/concepts/vLLM.md

52 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "vLLM"
type: concept
tags: [llm, inference, gpu, optimization, kv-cache]
sources: [大模型相关术语和框架总结llm-mcp-prompt-rag-vllm-token-数据蒸馏]
last_updated: 2026-04-25
---
# vLLM
## Aliases
- vLLM
- Virtual Large Language Model
- 虚拟大语言模型
## Definition
vLLM 是由 **vLLM 社区**维护的开源 LLM 推理框架,旨在通过更好地利用 GPU 内存来加快生成式 AI 应用的输出速度,实现高吞吐、低成本的推理服务。
## Core Mechanisms
### PagedAttention分块注意力
传统方法按序列分配一大块连续内存存储 KV Cache导致显存碎片化和 OOM内存溢出
vLLM 的 PagedAttention 将 KV Cache 切分为固定大小的**块block**,用类操作系统的**页表式映射**管理:
- 避免按序列分配连续内存导致的碎片化
- 支持动态并发与显存复用
- 在多分支beam search和重复前缀场景下复用相同前缀产生的 KV 块极大减少预填充prefill时间
### Continuous Batching连续批处理
传统批处理:攒满一批再跑,短任务被长任务阻塞(头阻塞)。
连续批处理:
- 在每个解码步骤(按 token 迭代)都把活跃请求组装成一个批
- 序列长度不同也能高效合批
- GPU 基本满负载运转
- 基于 PagedAttention 的块式内存 + 步进级调度器,无需等待整批结束即可把新请求插入下一步的批次
## Related Concepts
- [[KV Cache]]vLLM 优化的核心对象PagedAttention 将 KV Cache 分块管理
- [[Large Language Model]]vLLM 服务的对象
- [[PagedAttention]]vLLM 提出的注意力机制
- [[Continuous Batching]]vLLM 使用的调度策略
## Sources
- [[大模型相关术语和框架总结llm-mcp-prompt-rag-vllm-token-数据蒸馏]]