English | 中文版
11. 把安全卫士延伸到 ingested linalg 内核
摘要:第 10 章把安全卫士跑在
.acl.pto文件上——由本仓库自己的mlir_to_pto后端产出的 PTO-MLIR。本章把同一个卫士延伸到 ascend-rs 管线之外 进来的内核:第三方前端(例如torch-mlir)产出的上游linalgdialect MLIR。本章给出两条路径。Path A 是一段约 300 行的 projector,直接从ascend_tileMLIR 合成一个 stage-2Plan,在上面跑第 10 章六遍 check 中的一个子集;Path C 则把每一个 ingested 内核都通过真实的mlir_to_pto → ptoas --print-after-all → parse_stage2链路,把六遍 check 完整跑在PlanMemoryPass之后的 plan 上。两条路径都通过同一个环境变量ACLRS_LINALG_SAFETY接入 ingress 驱动,并且都能在adablue上纯主机运行(使用 x86 版ptoas,无需 NPU)。两条路径互为补充:Path A 快、能抓整块 tile 级别的问题;Path C 精度更高,在 blocked matmul 场景下尤其关键,因为在那里 Path A 会对容量做保守的 over-approximation。
11.1 / 11.2 详见英文版
本章的完整内容目前只维护了英文版:
- 11.1 Path A: A Projector for Ingested
ascend_tile - 11.2 Path C: The Full Oracle on Post-PlanMem Plans
简要概括:上游 linalg MLIR(torch-mlir 等前端产出)经 linalg → ascend_tile → mlir_to_pto → ptoas → parse_stage2 → check_all 走完整条路径,在 adablue 上用 ~/ptoas-x86/bin/ptoas 即可纯主机运行,无需 910c。matmul_row_overflow 这个对抗性示例演示了:Path A 会把 blocked matmul 的容量 over-approximate 成 8 MiB 误报;而 Path C 读取的是 PlanMemoryPass 之后的真实 plan,因此给出 clean 结论。驱动入口 ACLRS_LINALG_SAFETY=path-a|path-c、报错模式 ACLRS_LINALG_SAFETY_ABORT=1、以及 ptoas 路径覆写 ACLRS_PTOAS_BIN 的细节见英文版。