docs: fill the Phase 19 gap, refresh README/roadmap to actual state

- docs/19-gpt-oss-moe.md: the numbered series jumped 18->20; write up
  gpt-oss arch deltas, harmony pitfalls, and the two CUDA debugging
  postmortems (fully-masked-tile NaN in flash-attention sinks;
  pre-__syncthreads early return reading uninitialized smem in the
  decode GEMV) — the highest-value learning content of that phase.
- README: models/perf/capabilities were frozen at the Qwen3-only era;
  now lists gpt-oss MoE, TP/PP, FP8/MXFP4, sparse MoE, and the
  llama.cpp standing.
- Roadmap: record where reality diverged from the plan at Phase 18+,
  add milestone entries and the ranked next-phase candidates
  (21 CUDA-graph MoE decode, 22 non-expert quant, 23 sparse prefill).
- sparse-moe benchmark doc: post-review-fix numbers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 17:02:59 +08:00
parent 5343391dbd
commit 2a92f268a9
4 changed files with 168 additions and 13 deletions

View File

@@ -3,18 +3,23 @@
> 从零用 **Rust + CUDA** 构建的 LLM 推理引擎,目标是吃透 LLM Serving 全栈技术。
xserv 不依赖 PyTorch / vLLM / TensorRT 等现成框架自己实现了张量抽象、CUDA kernel、
分词器、模型前向、KV cache、调度器和 OpenAI 兼容的 HTTP 服务。当前在单张 RTX 5090 上可以
跑通 **Qwen3-8B**BF16并提供一套与 **llama.cpp** 对比正确性和性能的标准 benchmark。
分词器、模型前向、KV cache、调度器和 OpenAI 兼容的 HTTP 服务。支持 **Qwen3-8B**BF16
**gpt-oss-20b**MoEBF16/FP8/MXFP4 量化),多卡 TP/PP并提供一套与 **llama.cpp**
对比正确性和性能的标准 benchmark。
## 现状一览
- **模型**GPT-2124M、Qwen3-8BBF16
- **性能**RTX 5090Qwen3-8B BF16贪心解码单流**56 tok/s**,约为 HF transformers 的 1.4×、llama.cpp 的 ~0.6×
- **精度**:在 AIME 2025 / GSM8K 上与 llama.cpp 同权重对比基本持平(数值保真度验证通过
- **服务**OpenAI 兼容 `/v1/chat/completions`,支持 SSE 流式输出
- **关键能力**:自写 GEMM / Flash-Attention 2(SM120) / Paged-Attention kernel、
分页 KV cache**CPU 换出/换入** 弹性显存、连续批处理continuous batching
CUDA Graph 解码、按显存自适应的 KV 池
- **模型**GPT-2124M、Qwen3-8BBF16、gpt-oss-20b32 专家 top-4 MoEharmony 格式)
- **性能**RTX 5090贪心,单流):
- Qwen3-8B BF16 单卡:约 56 tok/sHF transformers 的 1.4×
- gpt-oss-20b FP8 稀疏 MoE TP=2**132 tok/sTPOT 7.2msdecode 快于
llama.cpp 同配置**7.5-8.4msllama 单卡模式2.9ms)仍领先,是下一阶段目标
- **精度**GSM8K 全量与 llama.cpp 同权重持平94.5% vs 94.4%FP8/MXFP4 量化无回归
- **服务**OpenAI 兼容 `/v1/chat/completions`SSE 流式gpt-oss 量化后可**单卡 32GB 服务**
- **关键能力**:自写 GEMM / Flash-Attention 2(SM120含 attention sinks + sliding window) /
Paged-Attention kernel、分页 KV cache**CPU 换出/换入**)、连续批处理、
CUDA Graph 解码Qwen3 单卡路径)、**Tensor/Pipeline 并行**NCCLTP=1/2/4、PP=2/4
**FP8 W8A8 / MXFP4 W4A16 量化**、**稀疏 top-k MoE decode**(只算被路由的专家)
> 这是一个以学习为主的项目,逐 Phase 推进,每步都做数值/端到端验证。
@@ -26,16 +31,19 @@ xserv/
│ ├── gemm/ # GEMM (naive / tiled / gemv)
│ ├── attention/ # Flash-Attention 2 (SM120)、Paged-Attention、causal mask
│ ├── normalization/ # LayerNorm / RMSNorm
│ ├── activation/ # GELU / SiLU
│ ├── activation/ # GELU / SiLU / gpt-oss GLU
│ ├── embedding/ # embedding lookup / RoPE / transpose
│ ├── moe/ # MoE top-k 路由、稀疏专家 GEMV、加权求和
│ ├── quantization/ # FP8 量化/反量化、cuBLASLt FP8 GEMM、MXFP4 GEMV
│ └── reduce/ # softmax
├── crates/
│ ├── xserv-cuda/ # CUDA FFI、Stream、显存分配器、Pinned 内存、CUDA Graph
│ ├── xserv-tensor/ # Tensor 类型strided 布局、BF16/F16/F32、CPU↔GPU
│ ├── xserv-kernels/ # kernel registry自写 kernel + cuBLAS 可切换)
│ ├── xserv-tokenizer/ # BPE 分词器
│ ├── xserv-model/ # 模型定义GPT-2 / Qwen3、权重加载、KV cache、采样
── xserv-server/ # tokio + axum HTTP 服务、调度器
│ ├── xserv-distributed/ # NCCL FFI、TP 上下文AllReduce
── xserv-model/ # 模型定义GPT-2 / Qwen3 / gpt-oss MoE、权重加载、KV cache、采样
│ └── xserv-server/ # tokio + axum HTTP 服务、调度器、TP/PP 引擎
├── tools/ # 辅助脚本 + benchmark 套件(见下)
└── docs/ # 每个 Phase 的设计文档 + benchmark 报告
```