Files
maths-cs-ai-compendium-zh/images/paged_attention.svg
T
flykhan 2536c937e3 feat: 完整中文翻译 maths-cs-ai-compendium(数学·计算机科学·AI 知识大全)
翻译自英文原版 maths-cs-ai-compendium,共 20 章全部完成。

第01章 向量 | 第02章 矩阵 | 第03章 微积分
第04章 统计学 | 第05章 概率论 | 第06章 机器学习
第07章 计算语言学 | 第08章 计算机视觉 | 第09章 音频与语音
第10章 多模态学习 | 第11章 自主系统 | 第12章 图神经网络
第13章 计算与操作系统 | 第14章 数据结构与算法
第15章 生产级软件工程 | 第16章 SIMD与GPU编程
第17章 AI推理 | 第18章 ML系统设计
第19章 应用人工智能 | 第20章 前沿人工智能

翻译说明:
- 所有数学公式 $...$ / $$...$$、代码块、图片引用完整保留
- mkdocs.yml 配置中文导航 + language: zh
- README.md 已翻译为中文(兼 docs/index.md)
- docs/ 目录包含指向各章文件的 symlink
- 约 29,000 行中文内容,排除 .cache/ 构建缓存
2026-05-03 10:23:20 +08:00

92 lines
7.7 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 280" width="750" height="280">
<defs>
<marker id="pa-arr" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<path d="M0,0 L8,3 L0,6 Z" fill="#666"/>
</marker>
</defs>
<text x="375" y="22" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#333">PagedAttention: Virtual Memory for KV-Cache</text>
<!-- Virtual page tables (left) -->
<text x="140" y="50" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" font-weight="bold" fill="#3498db">Virtual KV-Cache (per request)</text>
<!-- Request A -->
<text x="30" y="78" text-anchor="start" font-family="Arial, sans-serif" font-size="9" font-weight="bold" fill="#3498db">Req A:</text>
<rect x="80" y="65" width="40" height="22" rx="3" fill="#3498db" fill-opacity="0.3" stroke="#3498db" stroke-width="1"/>
<text x="100" y="80" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#3498db">pg 0</text>
<rect x="122" y="65" width="40" height="22" rx="3" fill="#3498db" fill-opacity="0.3" stroke="#3498db" stroke-width="1"/>
<text x="142" y="80" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#3498db">pg 1</text>
<rect x="164" y="65" width="40" height="22" rx="3" fill="#3498db" fill-opacity="0.3" stroke="#3498db" stroke-width="1"/>
<text x="184" y="80" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#3498db">pg 2</text>
<rect x="206" y="65" width="40" height="22" rx="3" fill="#3498db" fill-opacity="0.15" stroke="#3498db" stroke-width="1" stroke-dasharray="3,2"/>
<text x="226" y="80" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#999">...</text>
<!-- Request B -->
<text x="30" y="115" text-anchor="start" font-family="Arial, sans-serif" font-size="9" font-weight="bold" fill="#e74c3c">Req B:</text>
<rect x="80" y="102" width="40" height="22" rx="3" fill="#e74c3c" fill-opacity="0.3" stroke="#e74c3c" stroke-width="1"/>
<text x="100" y="117" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#e74c3c">pg 0</text>
<rect x="122" y="102" width="40" height="22" rx="3" fill="#e74c3c" fill-opacity="0.3" stroke="#e74c3c" stroke-width="1"/>
<text x="142" y="117" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#e74c3c">pg 1</text>
<!-- Request C -->
<text x="30" y="152" text-anchor="start" font-family="Arial, sans-serif" font-size="9" font-weight="bold" fill="#27ae60">Req C:</text>
<rect x="80" y="139" width="40" height="22" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1"/>
<text x="100" y="154" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">pg 0</text>
<rect x="122" y="139" width="40" height="22" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1"/>
<text x="142" y="154" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">pg 1</text>
<rect x="164" y="139" width="40" height="22" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1"/>
<text x="184" y="154" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">pg 2</text>
<rect x="206" y="139" width="40" height="22" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1"/>
<text x="226" y="154" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">pg 3</text>
<!-- Arrow: mapping -->
<text x="310" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="20" fill="#666"></text>
<text x="310" y="135" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#666">page table</text>
<text x="310" y="147" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#666">maps to</text>
<!-- Physical GPU memory (right) -->
<text x="555" y="50" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" font-weight="bold" fill="#333">Physical GPU Memory</text>
<!-- Memory blocks (non-contiguous) -->
<rect x="380" y="65" width="45" height="28" rx="3" fill="#3498db" fill-opacity="0.3" stroke="#3498db" stroke-width="1.5"/>
<text x="402" y="83" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#3498db">A:0</text>
<rect x="430" y="65" width="45" height="28" rx="3" fill="#e74c3c" fill-opacity="0.3" stroke="#e74c3c" stroke-width="1.5"/>
<text x="452" y="83" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#e74c3c">B:0</text>
<rect x="480" y="65" width="45" height="28" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1.5"/>
<text x="502" y="83" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">C:0</text>
<rect x="530" y="65" width="45" height="28" rx="3" fill="#3498db" fill-opacity="0.3" stroke="#3498db" stroke-width="1.5"/>
<text x="552" y="83" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#3498db">A:1</text>
<rect x="580" y="65" width="45" height="28" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1.5"/>
<text x="602" y="83" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">C:1</text>
<rect x="630" y="65" width="45" height="28" rx="3" fill="#e74c3c" fill-opacity="0.3" stroke="#e74c3c" stroke-width="1.5"/>
<text x="652" y="83" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#e74c3c">B:1</text>
<rect x="680" y="65" width="45" height="28" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1.5"/>
<text x="702" y="83" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">C:2</text>
<rect x="380" y="98" width="45" height="28" rx="3" fill="#3498db" fill-opacity="0.3" stroke="#3498db" stroke-width="1.5"/>
<text x="402" y="116" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#3498db">A:2</text>
<rect x="430" y="98" width="45" height="28" rx="3" fill="#ccc" fill-opacity="0.3" stroke="#ccc" stroke-width="1"/>
<text x="452" y="116" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#999">free</text>
<rect x="480" y="98" width="45" height="28" rx="3" fill="#27ae60" fill-opacity="0.3" stroke="#27ae60" stroke-width="1.5"/>
<text x="502" y="116" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#27ae60">C:3</text>
<rect x="530" y="98" width="45" height="28" rx="3" fill="#ccc" fill-opacity="0.3" stroke="#ccc" stroke-width="1"/>
<text x="552" y="116" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#999">free</text>
<rect x="580" y="98" width="45" height="28" rx="3" fill="#ccc" fill-opacity="0.3" stroke="#ccc" stroke-width="1"/>
<text x="602" y="116" text-anchor="middle" font-family="Arial, sans-serif" font-size="7" fill="#999">free</text>
<!-- Key points -->
<rect x="50" y="185" width="650" height="80" rx="8" fill="#f5f5f5" stroke="#ddd" stroke-width="1"/>
<text x="375" y="206" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" font-weight="bold" fill="#333">Key insights:</text>
<text x="375" y="222" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#666">Pages are non-contiguous in physical memory (like OS virtual memory, chapter 13)</text>
<text x="375" y="236" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#666">Pages allocated on demand (no pre-allocation for max sequence length)</text>
<text x="375" y="250" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#666">Free pages are reused instantly when requests finish → no fragmentation</text>
</svg>