只读探索完成;未修改文件。工作树本来是 dirty 的,我没有清理或覆盖。
1. 现有命令
服务入口以当前脚本为准:bash eval/start_eagle.sh,生产参数包括 --chunked-prefill-size 8192、--dense-as-sparse、minicpm_flashinfer、EAGLE3,见 eval/start_eagle.sh。
Prefill/long-context:
bash
BENCH_API=http://127.0.0.1:30000 \
python3 bench/kernels/prefill/prefill_bench_smax64.py --trials 3 --concurrency 64 --tag baseline
这个脚本用 bench/data/speed_bench_cunlimited.jsonl 64 条、max_tokens=1,输出 total/p50/p99/max,基本隔离 prefill,见 prefill_bench_smax64.py。注意 docstring 里的旧路径不准,真实路径是 bench/kernels/prefill/...。
bash
bash bench/mini_bench.sh http://127.0.0.1:30000 12 36 96
当前 dirty 脚本实际默认是 S1=0 S8=36 Smax=96,且读 bench/data_full,不是注释里的旧默认;建议显式传参,见 bench/mini_bench.sh。
快速拆 prefill/decode:
bash
bash bench/quick_validate.sh http://127.0.0.1:30000 baseline outputs/quick_validate
它会写 outputs/quick_validate,但设计上很有用:prefill 是 5 个约 8K prompt、max_tokens=1;decode 是短 prompt、ignore_eos + max_tokens=128,见 bench/quick_validate.sh。
InfLLM/stage microbench:
bash
python3 bench/infllmv2/bench_stage1_seqlen_k.py
STAGE2_KV_DTYPE=bf16 python3 bench/infllmv2/bench_stage2_backends.py
python3 bench/infllmv2/bench_stage2_triton_topk_bf16.py
python3 bench/infllmv2/bench_stage2_blocksparse_merge.py
python3 bench/infllmv2/bench_fuse_topk_consistency.py --strict
Public eval:
bash
python3 eval/run_public_eval_full.py \
--api-base http://127.0.0.1:30000 \
--model-path /user_4813494d/models/openbmb/MiniCPM-SALA-gptq46-calib90-90k-NVFP4 \
--model-name /user_4813494d/models/openbmb/MiniCPM-SALA-gptq46-calib90-90k-NVFP4 \
--concurrency 32
它记录 ori_accuracy、duration、total_input_tokens、total_tokens,见 eval/run_public_eval_full.py。也可直接 bash eval/run_public_eval_full.sh。
2. 区分 TTFT/prefill vs decode 的指标
Prefill/TTFT 看:max_tokens=1 的 wall、p50/p99/max、prompt_tokens / wall_s、15chunk line39 wall。docs/prefill/current.md 明确当前线上快速样本是 speed_bench_cunlimited.jsonl line 39、约 15 chunks、max_tokens=1,见 docs/prefill/current.md。
Decode 看:固定输出 token 的 duration_s、completion_tokens / duration_s、TPOT/ITL、p50/p99 TPOT、accept length。decode_quick_bench.py 的 duration_s 比 tok/s 更适合作 gate,见 docs/decode/current.md。
Profile 看:prefill 用 SGLANG_MINICPM_PROFILE=1 SGLANG_MINICPM_PROFILE_INTERVAL=16 的 chunk/module ms;decode profile 必须 --cuda-graph-trace=node,否则 CUDA graph 内 kernel 会被隐藏,见 docs/decode/current.md。
Public eval 主要是正确性和综合耗时,不适合单独归因 prefill/decode;它能防止“速度涨了但 ori_accuracy 掉了”。
3. 最小可信实验矩阵
每个候选至少跑 baseline/candidate 两组,同一模型、同一服务参数,profile 和 wall 分开跑:
-
离线对拍 + microbench
stage1 改动跑 bench_stage1_seqlen_k.py 和 topk 一致性;stage2 改动跑 bench_stage2_backends.py/Triton/BlockSparse 对拍;MLP/GLA 改动跑对应 bench/kernels/minicpm/*。要求 shape 覆盖 full chunk 和 tail/mixed。
-
单样本长上下文 prefill
用 line39、max_tokens=1、mars=0,PROFILE=0 跑 5 次取 median;PROFILE=1 跑 1 次确认热点下降。文档要求 15chunk bench 不再调用 /flush_cache,见 docs/prefill/current.md。
-
Smax/并发长尾
跑 prefill_bench_smax64.py,再跑显式参数的 bench/mini_bench.sh http://127.0.0.1:30000 12 36 96,看 S1/S8/Smax duration 和长尾 p99。
-
Decode 防回归
跑:
bash
python3 bench/decode_quick_bench.py --scenario s8_stable_decode --ignore-eos --output outputs/decode_quick_s8.json
python3 bench/decode_quick_bench.py --scenario b32_drain_decode --ignore-eos --output outputs/decode_quick_b32.json
python3 bench/decode_quick_bench.py --scenario longctx_s8_decode --ignore-eos --output outputs/decode_quick_longctx_s8.json
-
Public eval
最后跑 full public eval,看 ori_accuracy、duration、坏例。Spec/量化/prefill 改动都不能只看 tok/s。
4. 已暴露瓶颈和反例
当前 prefill 热点:line39 15chunk 稳态约 7.0-7.4s;MLP 133ms/chunk、GLA 120ms/chunk、extend_sparse_fa 约 84ms/chunk、stage1_score 尾段 74ms/chunk,见 docs/prefill/current.md。
stage2 是核心剩余问题之一:生产形态其实是 decode-style virtual batch,16 req × 512 q_tok × 2 head_group = 16384 rows,每 row 96×64 sparse tokens,page_size=1;indices 可到约 400MB,见 bench_stage2_backends.py。旧 fp8 7.6ms 口径不能当 baseline,当前 bf16 约 9.8-10.0ms/layer。
不要重踩的反例:chunked-prefill-size 16384 更慢;TrtLLM stage2/prefill 的收益来自 all-masked 行语义变化;--fuse-topk/TileLang k1-only topk 不一致;FlashInfer backend/split-KV 旋钮基本枯竭;page64/BlockSparse 离线收益没有穿透到 15chunk wall;Triton direct stage2 慢于 FlashInfer;MLP cuDNN、dense-as-MoE、先 FP4 化 gate/up 再 SwiGLU 都不值得或不正确,见 docs/prefill/current.md。
bench/results 现有两份主要是 spec decode/GLA 结果,不是纯 prefill 结果;其中 fused GLA EAGLE-3 有 4-7% mini_bench 改善,也暴露过 CUDA graph strided view 写错导致输出垃圾的问题,见 bench/results/fused_gla_eagle3.md。