c869a153创建于 2025年7月24日历史提交
文件最后提交记录最后更新时间
!82 整改CMake工程,支持bisheng编译器;解决安全编译问题 Merge pull request !82 from yuantao/cmake 10 个月前
!177 更新Docs指南 Merge pull request !177 from 徐天昊/docs 10 个月前
!126 全量测试脚本 11 个月前
!54 mla优化:只有尾轮做fd * bugfix * mla fd for tail task 1 年前
!82 整改CMake工程,支持bisheng编译器;解决安全编译问题 Merge pull request !82 from yuantao/cmake 10 个月前
!96 change name to catlass * feat: rename directory and files * feat: rename repo to catlass * change name to catlass * change name to catlass 1 年前
!96 change name to catlass * feat: rename directory and files * feat: rename repo to catlass * change name to catlass * change name to catlass 1 年前
!96 change name to catlass * feat: rename directory and files * feat: rename repo to catlass * change name to catlass * change name to catlass 1 年前
!82 整改CMake工程,支持bisheng编译器;解决安全编译问题 Merge pull request !82 from yuantao/cmake 10 个月前
!82 整改CMake工程,支持bisheng编译器;解决安全编译问题 Merge pull request !82 from yuantao/cmake 10 个月前
README.md

MLA Example Readme

代码组织

├── 19_mla
│   ├── CMakeLists.txt # CMake编译文件
│   ├── gen_data.py
│   ├── kernel_common.hpp #两个不同的kernel实现中的共同变量与宏
│   ├── main.cpp
│   ├── mla_kernel.cpp # MLA TP 2/4/8 模板
│   ├── mla_kernel_tp1_spec.cpp # MLA TP 1 模板
│   └── README.md

使用示例

  • 获取代码之后编译相应的算子可执行文件,可参考quickstart
  • 第一步,首先执行gen_data.py,生成测试样例,测试用例需要从命令行输入。
python gen_data.py 1 1 128 16 16 128 half
# 输入参数分别对应 batchSize,qSeqlen,kvSeqlen, qheadNum,numBlock, blockSize
# qSeqlen表示需要推理的token个数,支持范围为1~4,即常规decode与mtp场景
# kvSeqlen表示输入的序列长度
# blockSize参数当前只支持128
# 最后一个参数需要指明数据类型为“half”或“bf16”

执行该命令后会在当前路径下生成data目录,包含算子的输入数据和用于精度验证的golden数据

├── data
│   ├── block_table.bin
│   ├── golden.bin
│   ├── k.bin
│   ├── k_rope.bin
│   ├── kv_seqlen.bin
│   ├── q.bin
│   ├── q_ntokens.bin
│   ├── q_rope.bin
│   └── q_seqlen.bin

第二步,执行算子,这里要注意的是执行算子的输入shape和上面第一步生成数据的shape一致。

# cd [代码仓路径]/output/bin
./19_mla 1 1 128 16 16 128
# 此处的参数和生成数据的参数保持一致
# 完整参数为 batchSize, qSeqlen, kvSeqlen, qheadNum, numBlock, blockSize [--dtype DTYPE --datapath DATA_PATH --device DEVICE_ID],dtype默认为half, datapath默认为../../examples/19_mla/data, device默认为0。

执行结果如下,说明精度比对成功。

Compare success.