feat(tilelib): materialize PTODSL in process - #1103
Draft
mouliangyu wants to merge 8 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
TileOp 展开此前通过独立 Python daemon 完成 PTODSL 模板选择和 MLIR 生成,需要维护子进程、Unix socket、JSON 协议、临时文件以及 MLIR 文本打印/解析。主线移除 legacy TileLang backend 后,这些设施只服务于 PTODSL,已经没有保留双后端抽象的必要。
主要变更
TileLibServiceC++ 接口,供InsertTemplateAttributes查询候选元数据、供ExpandTileOp请求模板实例化。Context;nativePTOASContext在_core.main调用期间借用同一个底层MLIRContext。ExpandTileOp按显式 entry symbol 导入实例化 module 中的入口和 helper functions,处理符号冲突与 symbol ref 重写,然后复用现有 call/erase 流程。InsertTemplateAttributes和ExpandTileOp收口为 compiler-session passes:只允许通过TileLibServicefactory 构造,不再提供无参 factory 或全局 textual pass 注册。SpecializedTileTemplate.materialize(context)暴露 ownership 敏感接口。_selection.py,同步更新 CLI、wheel smoke、ST 脚本和设计文档;ST runner 不再执行遗留 daemon socket cleanup。生命周期与安全边界
Context是底层MLIRContext的唯一 owner;C++ 只在 compilation session 动态范围内借用。MlirModule只作为 non-owning handle 使用;source module owner 保持存活直到 clone 完成。TileLibService的 pass 不进入全局 pass registry,避免脱离 compiler session 后构造出不可运行的 pass。验证
ninja -C .work/tileop-embedded-python-study/build PTOASPythonCore PTOASPythonPackage -j4ctest --test-dir .work/tileop-embedded-python-study/build --output-on-failure -R '^ptodsl_(ptoas_cli|tilelib_(catalog|constraints|elementwise|render|select))$':6/6 通过llvm-lit -v expand_tile_op_ptodsl_tsub.pto expand_tile_op_ptodsl_view_stride_cache.pto:2/2 通过llvm-lit -v expand_tile_op_trelu_tilelang.pto:1/1 通过cmake --build .work/tileop-embedded-python-study/build --target PTOPassesIncGen PTOTransforms PTOASPythonCore -j4test_tilelib_render.pyfocused tests:5/5 通过ptoas --help确认两个 session-only pass 不再出现在 standalone textual pass 列表python3 -m py_compile、bash -n docker/test_wheel_imports.sh、git diff --check通过构建和测试使用 LLVM/MLIR 21.1.8。