From 1bef6609609479f7407f27c015bb2d7e71c114ef Mon Sep 17 00:00:00 2001 From: MaseChen <93691652+MaseChen@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:12:50 +0800 Subject: [PATCH] =?UTF-8?q?(flashinfer):=20=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E9=99=84=E5=BD=95=E5=92=8C=E7=9B=B8=E5=BA=94=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=20=E7=BB=9F=E4=B8=80=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=A0=BC=E5=BC=8F=E7=AC=A6=E5=90=88gitlink?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...:从性能基线到XPU-OJ冒烟提交.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer Benchmark实战:从性能基线到XPU-OJ冒烟提交.md b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer Benchmark实战:从性能基线到XPU-OJ冒烟提交.md index 82802ab..c993911 100644 --- a/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer Benchmark实战:从性能基线到XPU-OJ冒烟提交.md +++ b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer Benchmark实战:从性能基线到XPU-OJ冒烟提交.md @@ -193,7 +193,7 @@ curl -fsSL https://opencode.ai/install | bash - 已获取测试脚本和 Benchmark 脚本。 -> 具体操作可见章节 [*6.1 在赛事镜像中运行 FlashInfer Benchmark*](#run-flashinfer-bench) +> 具体操作可见章节 [*6.1 在赛事镜像中运行 FlashInfer Benchmark*](#61%20在赛事镜像中运行%20flashinfer%20benchmark) ### 4.4 账号准备 @@ -222,7 +222,6 @@ XPU-OJ 账号由组委会统一发放,参赛者无需自行注册。 - **Prefill = 并行处理用户输入,Decode = 逐个生成回答 token** - ### 5.2 benchmark / 性能基线 `benchmark/` 目录中的脚本用于运行原库或迁移库的性能测试,帮助选手理解目标 API、输入输出 shape、性能指标和瓶颈位置。benchmark 输出的 CSV、日志或结果为 “性能基线结果”。 @@ -246,7 +245,6 @@ XPU-OJ 账号由组委会统一发放,参赛者无需自行注册。 **目标:** 以一个具体算子题目 **20001 FlashInfer Ragged Prefill** 为例,跑通 benchmark 脚本,建立性能基线,理解对应 XPU-OJ 题目包,并完成一次 OJ 冒烟提交,为后续 Agent 辅助优化建立起点。 - ### 6.1 在赛事镜像中运行 FlashInfer Benchmark #### Step 1:检查运行环境 @@ -366,7 +364,7 @@ python -c "from bench_common import setup_workspace, get_csv_path; print('脚本 **操作:** 运行基准测试脚本 (以 Ragged Prefill Benchmark 为例),读取生成的 CSV 结果文件。 -> 每个算子优化题目都对应一个 Benchmark(见 [*5.2 查看性能基线*](#benchmark-baseline)) +> 每个算子优化题目都对应一个 Benchmark(见 [*5.2 查看性能基线*](#52%20benchmark%20%20性能基线)) **运行算子 Benchmark(以 Ragged Prefill 为例):** @@ -661,6 +659,8 @@ FlashInfer 方向包含 **4 个可选算子题目**,每个对应独立的 benc ![smoke code](https://origin.picgo.net/2026/06/25/-2026-06-25-095143e59315c41ab0319a.png) + **针对题目 Ragged Prefill 的参考 Prompt 和冒烟代码**位于[*附录*](#附录): + - [*点击查看参考 Prompt*](#参考%20prompt) - [*点击查看参考冒烟代码*](#20001%20flashinfer%20ragged%20prefill%20参考冒烟代码) @@ -1082,6 +1082,8 @@ mv *.csv results/ ### 参考 prompt +[回退到 Step 8](#step%208提交%20oj%20冒烟代码) + ```plaintext # FlashInfer Ragged Prefill CUDA Kernel — Problem 20001 @@ -1267,8 +1269,13 @@ Before output, confirm ALL items. Any failure = 0 points. **Common errors**: (1) `-INFINITY` for m → NaN; use `-1.0e20f`. (2) Missing alpha guard → exp(1e20) overflow. (3) K/V ptr uses 32 instead of 4 → wrong stride (4096 vs 512). (4) Output ptr uses kv_head instead of qo_head → 8 heads write to same location. (5) `sum/t` divides by zero at t=0; use `sum/(t+1)`. (6) Signed `0xffffffff` mask → UB; use `0xffffffffu`. ``` + +[回退到 Step 8](#step%208提交%20oj%20冒烟代码) + ### 20001 FlashInfer Ragged Prefill 参考冒烟代码 +[回退到 Step 8](#step%208提交%20oj%20冒烟代码) + ```cpp #include @@ -1451,4 +1458,6 @@ extern "C" void run_kernel( q, k, v, output, qo_indptr, kv_indptr, batch_size, seq_len, num_qo_heads, num_kv_heads, head_dim_qk, head_dim_vo, causal, exact_len); } -``` \ No newline at end of file +``` + +[回退到 Step 8](#step%208提交%20oj%20冒烟代码) \ No newline at end of file