diff --git a/基于AI Agent开发范式的国产GPU大模型推理算子库优化/Fused MoE Baseline入门:快速跑通最小闭环教程.md b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/Fused MoE Baseline入门:快速跑通最小闭环教程.md index 8c1be30..ce6b91a 100644 --- a/基于AI Agent开发范式的国产GPU大模型推理算子库优化/Fused MoE Baseline入门:快速跑通最小闭环教程.md +++ b/基于AI Agent开发范式的国产GPU大模型推理算子库优化/Fused MoE Baseline入门:快速跑通最小闭环教程.md @@ -83,9 +83,9 @@ ### 步骤 1:检查运行环境 -**目标:** 确认当前环境满足本模块运行要求,包括编译器、MXMACA 工具链及 Python 依赖库。 +**目标:**确认当前环境满足本模块运行要求,包括编译器、MXMACA 工具链及 Python 依赖库。 -**操作:** 检查 Python、编译工具、MXMACA 编译器及关键 Python 包(numpy、torch、triton)是否存在。 +**操作:**检查 Python、编译工具、MXMACA 编译器及关键 Python 包(numpy、torch、triton)是否存在。 **命令示例:** @@ -135,9 +135,9 @@ EOF ### 步骤 2:进入项目目录 -**目标:** 进入本模块所需的源码目录。 +**目标:**进入本模块所需的源码目录。 -**操作:** 切换到指定项目路径。 +**操作:**切换到指定项目路径。 **命令示例:** @@ -154,9 +154,9 @@ cd /root/Project/fused_moe # 这里需要替换成自己的项目路径 ### 步骤 3:pybind 编译 -**目标:** 将用 C++ 编写的 fused\_moe 算子编译为 Python 可调用的 pybind 模块。 +**目标:**将用 C++ 编写的 fused\_moe 算子编译为 Python 可调用的 pybind 模块。 -**操作:** 运行 `fused_moe/scripts/build_fused_moe_i8_tn_pybind.sh` 脚本 +**操作:**运行 `fused_moe/scripts/build_fused_moe_i8_tn_pybind.sh` 脚本 **命令示例:** @@ -178,6 +178,7 @@ PYTHON_BIN=/path/to/python bash scripts/build_fused_moe_i8_tn_pybind.sh 且成功生成 `fused_moe/standalone/fused_moe_i8_tn/build/fused_moe_i8_tn_pybind.cpython-310-x86_64-linux-gnu.so` 文件 + **常见问题:** | 报错 | 原因 | 解决办法 | @@ -190,9 +191,9 @@ PYTHON_BIN=/path/to/python bash scripts/build_fused_moe_i8_tn_pybind.sh ### 步骤 4:正确性测试 -**目标:** 验证 reference 计算、pybind 计算、Triton 计算这三种方式计算结果的数值是否完全一致。 +**目标:**验证 reference 计算、pybind 计算、Triton 计算这三种方式计算结果的数值是否完全一致。 -**操作:** 运行 `fused_moe/scripts/run_fused_moe_i8_tn_pybind_test.sh` 脚本 +**操作:**运行 `fused_moe/scripts/run_fused_moe_i8_tn_pybind_test.sh` 脚本 **命令示例:** @@ -224,6 +225,7 @@ bash scripts/run_fused_moe_i8_tn_pybind_test.sh --backend reference > triton:fused\_moe\_i8\_tn\_topk2 passed: rows=512, cols=128, sample C\[0\]=-0.57678, C\[last\]=-0.49749 > triton:fused\_moe\_i8\_tn\_topk3 passed: rows=384, cols=128, sample C\[0\]=-1.08748, C\[last\]=-0.33618 + **结果解释:** * “pybind/reference/Triton”:三种计算方式; @@ -247,9 +249,9 @@ bash scripts/run_fused_moe_i8_tn_pybind_test.sh --backend reference ### 步骤5:性能测试 -**目标:** 输出 benchmark 结果对比表 +**目标:**输出 benchmark 结果对比表 -**操作:** 运行 `fused_moe/scripts/run_fused_moe_i8_tn_benchmark.sh` 脚本 +**操作:**运行 `fused_moe/scripts/run_fused_moe_i8_tn_benchmark.sh` 脚本 **命令示例:** @@ -276,6 +278,7 @@ bash scripts/run_fused_moe_i8_tn_benchmark.sh --backend all --warmup 5 --iters 2 > triton:fused\_moe\_i8\_tn\_topk2 benchmark: avg\_ms=16.745914, TOPS=0.001002, warmup=5, iters=20 > triton:fused\_moe\_i8\_tn\_topk3 benchmark: avg\_ms=19.630328, TOPS=0.000641, warmup=5, iters=20 + **结果解释:** * “pybind/reference/Triton”:三种计算方式;