docs: Phase 18 pipeline parallelism — design + benchmark results
docs/18-pipeline-parallelism.md: PP design (layer split, NCCL P2P, per-stage KV, engine/threading model). docs/benchmarks/pp-sweep.md: measured on dash5 (8x RTX 5090, Qwen3-8B BF16) — single-stream latency + per-GPU VRAM (~1/N), byte-exact correctness (single x2 vs pp4 x2 control), and the full AIME-30 + GSM8K-30 quality matrix (xserv & llama.cpp PP=1/2/4): GSM8K 29/30 in every cell, TPOT flat across PP. README: multi-card (TP/PP) section + roadmap to Phase 18. gitignore: /.claude/ runtime state. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
47
README.md
47
README.md
@@ -144,16 +144,53 @@ HF_ENDPOINT=https://hf-mirror.com python3 -m tools.bench.fetch_datasets
|
||||
- `docs/00-roadmap.md`:总体路线图与各 Phase 设计
|
||||
- `docs/01..15-*.md`:CUDA FFI / Tensor / GEMM / Attention / KV cache / 性能优化等每个 Phase 的设计文档
|
||||
- `docs/16-llama-cpp-comparison.md`:llama.cpp 对比基准的设计
|
||||
- `docs/benchmarks/`:各阶段的 benchmark 报告
|
||||
- `docs/17-tensor-parallelism.md`:张量并行(TP)设计
|
||||
- `docs/18-pipeline-parallelism.md`:流水线并行(PP)设计
|
||||
- `docs/benchmarks/`:各阶段的 benchmark 报告(含 `pp-sweep.md`)
|
||||
|
||||
## 多卡并行(TP / PP)
|
||||
|
||||
单机多卡,复用 NCCL(crate `xserv-distributed`)。两种切法正交、二选一:
|
||||
|
||||
- **张量并行 `--tp N`**:按 head / 中间维切每一层,层内用 AllReduce 聚合(每 token `2·层数` 次)。
|
||||
- **流水线并行 `--pp N`**:按层切成 N 段,相邻段间用 NCCL **P2P** 传 hidden state(每 token 仅 `N-1` 次),
|
||||
通信量远小于 AllReduce,对无 NVLink 的 PCIe 更友好。
|
||||
|
||||
```bash
|
||||
# 组内 GPU 0-3:4 卡张量并行 / 4 卡流水线并行
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 ./target/release/xserv-server /path/to/qwen3-8b --tp 4
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 ./target/release/xserv-server /path/to/qwen3-8b --pp 4
|
||||
```
|
||||
|
||||
**PP 实测**(dash5,Qwen3-8B BF16,单流贪心;每卡显存为权重+最小 KV 池):
|
||||
|
||||
| 配置 | TTFT | TPOT | tok/s | 每卡显存 |
|
||||
|------|------|------|-------|----------|
|
||||
| 单卡 | 33ms | 17.4ms | 57.5 | 24.0 GB |
|
||||
| PP=2 | 36ms | 18.1ms | 55.3 | 11.6 / 13.6 GB |
|
||||
| PP=4 | 36ms | 17.9ms | 55.8 | 7.3 / 5.3 / 5.3 / 9.4 GB |
|
||||
|
||||
**质量对比**(AIME 2025 30 题 + GSM8K 30 题,贪心,xserv 在 GPU 0-3、llama.cpp 在 GPU 4-7 并行):
|
||||
|
||||
| 引擎 | PP | AIME | GSM8K |
|
||||
|------|----|------|-------|
|
||||
| xserv | 1/2/4 | 8 / 7 / 7 (/30) | 29/30 (96.7%) 全部一致 |
|
||||
| llama | 1/2/4 | 7 / 7 / 7 (/30) | 29/30 (96.7%) 全部一致 |
|
||||
|
||||
正确性:hidden state 跨段是 **bit-exact BF16 P2P 拷贝**,PP=4 输出与单卡逐字节一致(用「单卡×2 vs
|
||||
PP=4×2」对照确认——单卡自身因 cuBLAS 非确定性 run-to-run 会变,而 PP=4 可复现且落在某次单卡轨迹上)。
|
||||
GSM8K 12 个格子全是 29/30,xserv 与 llama.cpp 完全一致;AIME 的 ±1 是长生成下贪心对 GEMM 抖动的敏感,
|
||||
非 PP 或引擎效应。**收益在显存**(每卡权重+KV ≈ 1/N);v1 为串行流水线,单流 TPOT 基本持平、不优于单卡,
|
||||
真正的吞吐提升需后续做 microbatch / 1F1B 重叠。完整数据见 `docs/benchmarks/pp-sweep.md`。
|
||||
|
||||
## 路线图(节选)
|
||||
|
||||
已完成 Phase 0–15:CUDA 基础设施 → Tensor → GEMM → Transformer kernels → Attention →
|
||||
已完成 Phase 0–18:CUDA 基础设施 → Tensor → GEMM → Transformer kernels → Attention →
|
||||
模型加载 → 分词器 → GPT-2 → KV cache → Qwen3-8B → Paged Attention → 连续批处理 →
|
||||
HTTP API → Flash Attention 2 → 性能优化;并在此基础上加入了 **llama.cpp 对比基准**
|
||||
与 **KV CPU 换出** 等基础设施。
|
||||
HTTP API → Flash Attention 2 → 性能优化 → **张量并行(TP)** → **流水线并行(PP)**;
|
||||
并加入了 **llama.cpp 对比基准** 与 **KV CPU 换出** 等基础设施。
|
||||
|
||||
后续方向:投机解码(speculative decoding)、张量并行(TP,多卡)、量化(FP8 / INT8)、多模态。
|
||||
后续方向:PP microbatch/1F1B 流水线重叠(吞吐收益)、2D TP×PP、投机解码、量化(FP8 / INT8)、多模态。
|
||||
|
||||
## 许可
|
||||
|
||||
|
||||
Reference in New Issue
Block a user