Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0a4be6e
feat(vmi): add VMI loop fusion pass and load/store elision
Aug 19, 2026
6e05b00
feat(vmi): add VMI tilelib candidates and ptodsl lowering support
TaoTao-real Aug 19, 2026
33b5175
feat(vpto): add vecscope memory barrier pass
TelGome Aug 19, 2026
016dce7
fix(vpto): fix VPTO lowering and emit issues exposed by VMI fusion
Aug 19, 2026
f108b16
infra: add VMI pass registration, CLI options, and shared utilities
Aug 19, 2026
1d877b9
fix(vecscope-membar): key WAR reachability visited set on Value, not Op
TelGome Aug 20, 2026
bd90529
Extend VecScope inference to VMI IR
mouliangyu Aug 19, 2026
d7bec9d
Make legacy fusion passes VecScope-aware
mouliangyu Aug 21, 2026
a8d3e51
Fix VecScope inference lit regressions
mouliangyu Aug 21, 2026
c13a892
fix(vpto-vecscope): rematerialize mask escaping across a DMA-bearing …
Aug 22, 2026
31bb884
Fix vecscope membar footprint and scope analysis
Aug 25, 2026
92a66a7
fix(daemon): run PTODSL TileLib daemon without -S so editable install…
Aug 22, 2026
41739c8
fix(tilelib): add s_fractal_size/compact_mode to TileSpec (#10, group 1)
Aug 25, 2026
dcb7803
test(ptodsl): rewrite ptoas_runtime cache-reuse test (#10, group 2)
Aug 25, 2026
88eb537
fix(vmi): VMI API fixes — vci, vinterpret_cast, vec-scalar, bf16x2, c…
Aug 25, 2026
abf8c48
fix(vmi): accept bidirectional group_size/phys_vl divisibility in vci…
Aug 25, 2026
42297e0
fix(fold-tile-buf): unwrap bridging casts when recognizing runtime ti…
Aug 25, 2026
d42cb42
fix(fusion-predicate-elision): prevent double-erase and tighten plt e…
Aug 25, 2026
1aa963e
fix(tilelib): default TileSpec.compact_mode to None, drop spurious pa…
Aug 25, 2026
88354a6
fix(lit): resolve llvm-workspace build-shared bin dir for FileCheck
Aug 25, 2026
2d6ff69
test: fix stale CHECK/RUN lines for 4 pre-existing lit failures
Aug 25, 2026
30fbfac
fix(ptoas): honor --emit-pto-ir for VPTO modules without unexpanded t…
Aug 25, 2026
a3349c6
test(unroll): guard --emit-pto-ir text output for tile-less VPTO modules
Aug 25, 2026
5febd45
fix(vmi): resolve remaining tilelib/VMI semantic gaps for CI-green
Aug 26, 2026
bec83c1
fix(ptoas): emit compact_mode exactly and cover pipe-entry ops in Pla…
Aug 26, 2026
07e44ae
test(ptodsl): align VMI/catalog/frontend assertions with corrected se…
Aug 26, 2026
0e2db6a
fix(tilelib): preserve s_fractal_size on the daemon wire path
Aug 26, 2026
3103a8f
fix(ptoas): satisfy G.FMT.11-CPP on changed control flow
Aug 26, 2026
269c120
fix(vecscope-membar): model BRC broadcast load footprint by dist byte…
Aug 26, 2026
d11ac4d
fix(vmi): align repeat_stride removal and post_update vstore indent p…
Aug 27, 2026
dac13d2
test(vmi): re-apply post-rebase assertions for updated_base and weak-…
Aug 27, 2026
c68ea98
fix(tilelib): drop repeat_stride from tmov vstore and re-align tmov_n…
Aug 27, 2026
cad6752
test(ptodsl): assert vstore block_stride instead of removed repeat_st…
Aug 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ test/samples/**/npu_validation/*
.planning/
.work/
.local/
dsv4-vmi-lowering-lab/
99 changes: 99 additions & 0 deletions docs/designs/adr/0001-vmi-vf-fusion-rfc-minimal-pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# ADR-0001: VMI VF Fusion 采用唯一 canonical 实现与融后 mem2reg

- 日期: 2026-07-15
- 状态: Proposed

## Context

PTOAS 已能通过 `--tile-lib-backend=ptodsl-vmi` 将 `PIPE_V` TileOp 展开为
独立可执行的 VMI 模板。每个模板包含一个主 `scf.for` 和完整的 VMI
load/compute/store,但不显式生成 `pto.vecscope`,因此多个连续 TileOp 展开后仍会
产生多个循环和中间 UB 往返。

该 backend 是组合式路由:`PIPE_V` 使用唯一 canonical VMI provider,其他 Pipe
继续使用现有 PTODSL TileLib daemon。它不会将非向量 TileOp 回退到 TileLang。

旧的 `FusionPlan` / `FusionRegionGen` 分析 Tile-native PTO IR,
`PTOLowLevelLoopFusion` 分析已经物理化的 VPTO/MI IR。二者都不能直接承担新的
VMI loop fusion。此前讨论过为同一 TileOp 提供多个 VMI schedule candidate,再由
region-aware cost model 选择并锁定实现;该方案会把实现版本选择提前引入本期,扩大
设计和验证范围。

## Decision

1. RFC 首期对每个 `(target, TileOp)` 只允许一个 canonical VMI 实现。
该实现必须脱离融合独立正确执行;不存在 candidate 竞争、锁定或回退选择。
2. 用户切分的 dense vector Tile 必须满足 physical inner 等于 candidate 的一个
logical VL。每行只有一个 block,canonical candidate 只生成 row 主循环;不支持
将多 VL inner Tile 平坦化为更多 blocks。Reduce compact result 和沿用源 iteration
contract 的 Convert 结果不按目标 dtype 重新划分。
3. VMI Fusion 消费 Tile 层 `FusionPlan` / `OpScheduling` /
`PTOFusionRegionGen` 已生成的 `pto.fusion_region`。完整流水线为:
Tile-native PTO IR → `InsertTemplateAttributes` → `FusionPlan` →
`OpScheduling` → `PTOFusionRegionGen` → View/Memory planning →
`ExpandTileOp` → `PTOInlineLibCall` → VMI region-local 合法性分析 →
VMI Loop Fusion → VMI Mem2Reg → VMI layout assignment → `VMIToVPTO`。
`ExpandTileOp` / `PTOInlineLibCall` 在 Tile 层已生成的 `pto.fusion_region`
内原地展开并保留外层 region;VMI Fusion 不重新划分或扩大 region 边界,
只在每个 region 内做 loop fusion 与 mem2reg。
4. 仅处理带 TileLib provenance 的 canonical VMI fusion unit。任意用户手写 VMI、
非 canonical 模板或无法证明来源的循环默认不参与融合。
5. 融合采用保守、部分融合策略:只合并边界、循环域、依赖、alias、访问模式和 mask
均可证明兼容的相邻循环;其余循环保持原样。
6. VMI mem2reg 必须在 loop fusion 之后运行。它只提升可证明同 location、同形状的
VMI store-load,使融合后暴露的中间 UB 往返变为 SSA 直传。
7. 融合和 mem2reg 位于 VMI layout assignment 之前。物理 vreg layout、interleave、
pack、post-update 和指令选择仍由现有 VMI semantic/layout pipeline 负责。

## Alternatives

### A. 在 Tile 层先选择并锁定多个 VMI candidate

暂不采用。它需要 schedule family、region-aware selection、代价模型和稳定的 fallback
协议,属于后续性能迭代,不是验证 VMI 融合基本闭环的前置条件。

### B. 直接复用 `FusionPlan` / `FusionRegionGen`

**采纳**(本 ADR 第 3 条已据此修订)。VMI 不自建 region 划分,而是复用 Tile 层
`FusionPlan`(`strategy="vmi-ub-disjoint"` 的 `VMIUBDisjointStrategyEngine`)/
`OpScheduling` / `PTOFusionRegionGen` 产出的 `pto.fusion_region`。Tile 层 region 是
VMI 优化的最大合法范围;VMI Loop Fusion 与 Mem2Reg 只在 region 内执行,不跨 region
合并、不扩大边界。`VMIUBDisjointStrategyEngine` 在 compute-node 层只按 F3 邻接分组
(非白名单 op 夹在 compute 节点之间即切断),不做 UB-overlap 判定 —— UB 重叠
(reduce-final stuck)由 `PTOVmiLoopFusion` 在 `scf.for` 层用 SSA/UB def-use 处理。

### C. 复用 `PTOLowLevelLoopFusion`

不采用。该 pass 面向 VPTO/MI 物理循环,运行位置过晚,会重新引入物理 layout、
predicate 和地址模式对融合分析的干扰。

## Consequences

### Pros

- 首期输入唯一、结果确定,便于建立 IR contract 和正确性测试。
- Elementwise、Reduce 输入和 Broadcast dense 输出共享 row iteration domain,减少
loop mapping、alias offset 和 mask compatibility 的状态空间。
- 单个 TileOp 在融合失败时仍能独立 lower,天然具备保守 fallback。
- loop fusion 与 UB store-load elimination 顺序正确。
- VMI 层保留逻辑 lane、mask 和 SSA 数据流,避免在 MI 层恢复高层语义。

### Cons / Risks

- canonical 实现不一定是每个固定 Shape 的最优实现。
- 不满足 1VL inner contract 的 dense Tile 不能进入 canonical VMI provider;这是前端
切 Tile 的契约违规,不由 Fusion pass 自动重切。
- BR 小于 VL 时,`[rows,1]` compact state reshape 后需要显式 compact-domain
candidate 或 pad/mask 方案,不能复用通用 dense candidate。
- 当前 VMI load/store 使用线性 offset,alias 分析必须保守规范化 storage root 和
index expression;无法证明时必须拒绝融合或提升。
- `PTOInlineLibCall` 需要保留 TileLib provenance,否则无法可靠区分模板代码与用户
手写 VMI。

## Follow-ups

- 实现 VMI fusion-unit provenance、识别、规划、loop fusion 和 mem2reg passes;复用
现有 late `PTOInferVPTOVecScope` 统一生成物理 VPTO vecscope。
- 完成 elementwise 链的正向和负向 lit tests。
- 在基本闭环稳定后,再独立评审多 candidate、Reduce schedule、cost model、outer-row unroll
和算法专项深融合。
Loading
Loading