diff --git a/基于AI Agent开发范式的国产GPU大模型推理算子库优化/Agent说明.md b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/Agent说明.md new file mode 100644 index 0000000..d4a728e --- /dev/null +++ b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/Agent说明.md @@ -0,0 +1,130 @@ +# Agent 使用说明 + +## 一、FlashInfer: +在本模块中,Agent 可以帮助你完成以下任务: + +### 环境检查 + +```plaintext +请帮我检查当前环境是否满足 FlashInfer 运行要求,包括 GPU、Python、PyTorch 和 flashinfer 依赖。 +``` + +### 运行测试 + +```plaintext +请帮我运行 bench_batch_decode.py 脚本,执行 BatchDecode 的基准测试。 +``` + +### 分析结果 + +```plaintext +请帮我读取最新的 CSV 结果文件,分析各参数配置下的性能表现,找出带宽最高和 TFLOPs 最高的配置。 +``` + +### 问题排查 + +```plaintext +运行时报错 out of memory,请帮我分析原因并给出解决方案。 +``` + +### 代码理解 + +```plaintext +请帮我解释 bench_common.py 中 run_with_profiler 函数的工作原理。 +``` + +## 二、FlashAttention: +在本模块中,Agent 可用于以下场景: + +### Prompt 模板 + +**环境验证:** + +```Plain +请帮我验证当前环境是否满足 FlashAttention KV-Cache Benchmark 的运行要求,包括: +1. 沐曦 GPU 是否可见 +2. PyTorch 版本和 CUDA 支持 +3. flash-attn 和 einops 是否已安装 + +``` + +**参数配置建议:** + +```Plain +我需要测试 headdim=128 和 headdim=256 的性能差异,请帮我推荐合适的 batch_sizes 和 seq_lens_kv 扫描范围。 + +``` + +**结果分析:** + +```Plain +请帮我分析这份 benchmark 结果 CSV 文件,找出峰值带宽配置和 OOM 边界。 + +``` +--- +## 三、Fused MoE: +在本模块中,Agent可以帮助你完成以下任务: + +### 环境检查 + + ```plaintext + 我正在算力平台部署 fused_moe_baseline 源码。 + 需要的环境信息如下: + - Python 3.12 + - g++ 13.3.0 + - mxcc 已安装 + - numpy / torch / triton 已安装 + + 请帮我确认: + 1. 当前环境是否满足编译与运行要求? + 2. 是否有潜在的不兼容风险(如 Python 与 libpython 版本)? + ``` + +### 运行测试 + + ```plaintext + 请帮我运行 scripts/run_fused_moe_i8_tn_pybind_test.sh 脚本 + ``` + +### 分析结果 + + ```plaintext + 这是性能测试结果: + pybind: avg_ms=0.30, TOPS=0.027 + triton: avg_ms=19.01, TOPS=0.0004 + reference: avg_ms=1685, TOPS=0.000005 + + 请分析: + 1. 为什么 pybind 比 Triton 快这么多? + 2. TOPS 指标是否可信? + 3. 当前结果是否已经具备提交价值? + ``` + +### 报错检查 + + ```plaintext + 编译 pybind 时出现以下错误: + /usr/bin/ld: cannot find -lpython3.10 + + 已知: + - 使用的是 Conda Python 3.10 + - mxcc 编译正常 + + 请一步一步告诉我: + 1. 错误原因是什么? + 2. 如何用 find 命令定位 libpython3.10.so? + 3. 如何在 build_fused_moe_i8_tn_pybind.sh 中正确指定路径? + ``` + +### 代码理解 + + ```plaintext + 请帮我梳理释 benchmark_fused_moe_i8_tn.py 代码整体框架 + ``` + +### KernelSwift 系统搜索算子 + + +```plaintext +请帮我在算子广场检索 fused_moe 算子 +``` \ No newline at end of file diff --git a/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer 迁移 Baseline 实战.md b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer 迁移 Baseline 实战.md index 9ead2af..4a2529c 100644 --- a/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer 迁移 Baseline 实战.md +++ b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/FlashInfer 迁移 Baseline 实战.md @@ -145,7 +145,7 @@ prefill = 并行处理用户输入,decode = 逐个生成回答 token ### Step 2:进入项目目录 -**目标:** 进入本模块所需的源码目录[flashinfer_baseline](baselines/flashinfer_baseline)。 +**目标:** 进入本模块所需的源码目录[flashinfer_baseline](https://gitlink.org.cn/metax-maca/op_optimization/tree/master/%E5%9F%BA%E4%BA%8EAI%20Agent%E5%BC%80%E5%8F%91%E8%8C%83%E5%BC%8F%E7%9A%84%E5%9B%BD%E4%BA%A7GPU%E5%A4%A7%E6%A8%A1%E5%9E%8B%E6%8E%A8%E7%90%86%E7%AE%97%E5%AD%90%E5%BA%93%E4%BC%98%E5%8C%96%2Fbaselines%2Fflashinfer_baseline)。 **操作:** 切换到 FlashInfer Baseline 项目目录。