Skip to content

PTOAS 降级至 LLVM 19 与 VPTO 分支适配 - #1156

Draft
mouliangyu wants to merge 1 commit into
mainfrom
codex/downgrade-llvm19
Draft

PTOAS 降级至 LLVM 19 与 VPTO 分支适配#1156
mouliangyu wants to merge 1 commit into
mainfrom
codex/downgrade-llvm19

Conversation

@mouliangyu

@mouliangyu mouliangyu commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

概要

将 PTOAS 的唯一 LLVM/MLIR 依赖基线从 21.1.8 降级到 19.1.7,并切换到 vpto-dev/llvm-project:feature-vpto(验证提交 fa2fd1f75d742fec91ecf40d98c9c7961647ec42)。

这不是单纯修改依赖引用:PR 同步完成当前 PTOAS 源码对 LLVM 19 MLIR API、VMI one-to-N 转换、EmitC、Python bindings 和 VPTO LLVM emitter 的适配,并更新构建、CI、Docker、测试及开发文档。迁移后的源码只支持 LLVM 19,不维护 LLVM 19/21 双版本条件分支。

主要变更

  • 将 CMake 版本门禁、README、中英文构建说明、Docker、CI、simulator CI、wheel workflow 和缓存标识统一切换到 LLVM 19 feature-vpto
  • 将 Python bindings 从 LLVM 21 nanobind 接口适配到 LLVM 19 pybind11 AddMLIRPython 接口,同时保留 ptoas.mlir 命名空间和统一 libPTOASCompiler.so runtime 边界。
  • VMIToVPTO 移植到 LLVM 19 独立的 OneToNTypeConversion 框架,覆盖函数签名、控制流、vreg/mask 展开、load/store、group-slot、iota、量化、归约和 tail lowering。
  • 将 reduction tree 优化移出 one-to-N conversion:VMI lowering 先生成保守物理树,再由 vpto-combine-reductions 在 mask simplify、LICM 和 CSE 后统一恢复 LLVM 21 的 vc*/vcg* add、max、min 合并效果,并保留动态或不等价 mask 的保守路径。
  • 适配 LLVM 19 的 bufferization、greedy rewrite、SCF-to-CF、memref stride/offset、Func argument、LLVM InlineAsm 和 calling-convention API。
  • 为 LLVM 19 补充 PTOAS Func inliner interface,继续尊重 SIMT entry 的 no_inline 语义。
  • 重构 PTO-to-EmitC adaptor 使用方式,并用保守 expression pass 避免 LLVM 19 FormExpressions 在合法 EmitC 上崩溃;相应测试验证展开后的临时值、地址计算和数据流。
  • 修正 LLVM 19 EmitC materialization 边界:仅对 pipe op 的 GlobalTensor adaptor 保留具体 stride specialization,避免生成无法编译的跨模板 C-style cast;普通 TileBuf 和函数签名继续使用正式转换类型。
  • 修复低精度 LLVM payload 与 GEP index vector 的类型边界:FP8 payload 保持 LLVM fixed vector,地址步长使用 LLVM 19 GEP 接受的 builtin integer vector。
  • 修复 CMake 4 严格配置 smoke 的独立 Python 环境缺失 NumPy 依赖。
  • 将依赖多错误累积顺序的 verifier 测试拆成单错误模块,避免 LLVM 19 首错即停导致覆盖不稳定。
  • 审计全部 LLVM 19 测试适配:只允许必要的表示和调度差异;CFG、region、yield 和 terminator 保持有序检查,独立操作才使用 CHECK-DAG
  • 新增完整迁移说明 docs/designs/ptoas-llvm19-downgrade.md

验证

  • PTOASCompilerPTOASPythonPackagepto-test-optptobcpto-vfsimt-size-patcher-test 构建通过。
  • 完整 lit:1,689 passed,1 unsupported,0 failed。
  • CTest:50/50 passed。
  • 原 LLVM 21 测试文本在当前 LLVM 19 编译器上的对照运行:97 个旧测试确定需要适配;唯一无须修改即可通过的已改测试已恢复原断言。
  • Python import、PTO dialect 注册及 MLIR module 构造通过。
  • ptobc encode/decode roundtrip 后由 PTOAS 重新解析通过。
  • GitHub workflow YAML 解析通过。
  • .codex/skills/build-ptoas-wsl quick validation 通过。
  • git diff --check 通过。
  • 使用 --cann-output-version=9.0.0 --pto-arch=a5 --pto-backend=vpto --emit-vpto-llvm-ir 导出 aicore_ld_st_dev 文本 LLVM IR,并由 CANN 9.0 Bisheng 成功编译为 dav-c310-vec ELF relocatable device object。

范围说明

本地已完成源码、完整 lit、Python、bytecode 和 device object smoke validation。Linux/macOS wheel 的实际 build/repair/install、static-PIC LLVM SDK profile,以及 simulator/NPU、PTO-Gym 和更广泛 TileLang runtime 验证仍由对应平台门禁执行。

@mouliangyu
mouliangyu force-pushed the codex/downgrade-llvm19 branch 10 times, most recently from 9e7f691 to 3e48282 Compare August 9, 2026 15:24
@mouliangyu
mouliangyu marked this pull request as ready for review August 9, 2026 15:33
@mouliangyu
mouliangyu marked this pull request as draft August 9, 2026 15:33
@mouliangyu
mouliangyu force-pushed the codex/downgrade-llvm19 branch 18 times, most recently from e071911 to 052a546 Compare August 12, 2026 06:57
@mouliangyu
mouliangyu force-pushed the codex/downgrade-llvm19 branch 2 times, most recently from a8ce2c4 to 96cd7c2 Compare August 12, 2026 08:26
@mouliangyu
mouliangyu force-pushed the codex/downgrade-llvm19 branch from 96cd7c2 to 9b99b11 Compare August 12, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant