Appearance
Part 6: GPU 加速
CPU 是正确性的参照,GPU 是性能的主力。本主题覆盖 Metal(macOS)和 CUDA(NVIDIA)两个 GPU 后端,以及 Flash Attention 等关键优化。
涵盖内容
| 章节 | 核心主题 |
|---|---|
| 1. GPU 后端 + 总结 | ObjC 互操作、Metal kernel、CUDA 后端、Flash Attention、总结回顾 |
核心概念
- kv-cache — GPU 端的 KV 缓存管理(CUDA Managed Memory)
- softmax — Flash Attention 中的 online softmax
- quantization — GPU 反量化 kernel
- rope — GPU 端的 RoPE 计算
前置知识
学习路径
读完本主题后,你将理解:
- Metal/CUDA 如何将 CPU 参考实现映射为 GPU kernel
- Flash Attention 的 online softmax 和分块计算策略
- ds4.c 整体架构的总结和回顾
→ 完成!回到 知识地图 查看全局视图。