Skip to content

feat(ptodsl): expose explicit L1 to L0 loads - #1140

Open
and0d0 wants to merge 7 commits into
hw-native-sys:mainfrom
and0d0:mte_l1_l0
Open

feat(ptodsl): expose explicit L1 to L0 loads#1140
and0d0 wants to merge 7 commits into
hw-native-sys:mainfrom
and0d0:mte_l1_l0

Conversation

@and0d0

@and0d0 and0d0 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

解决了原有 mte_l1_l0a/b 只能表达结构化 m/k/n + start_row/start_col 传输、无法直接指定分形块起点、步长和源/目的物理 stride 的问题。

现在同一 API 同时支持旧的结构化形式(保持现有调用和 IR 不变)与新的 8 参数显式控制形式(降为现有 LoadCbufToCa/CbOp);补充了文档、公开 API 约束和回归测试。

Comment thread ptodsl/ptodsl/_ops.py Outdated
Comment thread ptodsl/docs/user_guide/07-data-movement-ops.md Outdated

@mouliangyu mouliangyu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这版已保留旧 API 兼容并补充基础 verifier,但仍有两个会影响生成代码正确性的边界需要处理:FP4 显式路径的 intrinsic 分流,以及硬件控制字段的静态范围校验。CI 当前全绿,但现有测试没有覆盖这两类情况。

Comment thread ptodsl/ptodsl/_ops.py
"mte_l1_l0a explicit controls require m_start, k_start, "
"m_step, k_step, src_stride, and dst_stride"
)
_pto.LoadCbufToCaOp(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] 这里无条件构造普通 LoadCbufToCaOp(下面的 L0B 分支同理),因此 FP4 指针也会进入普通 lowering。当前 emitter 会把 f4E1M2x2/f4E2M1x2 映射到 LOAD.L1.TO.L0*.2Dv2.s8;但已安装 A5 TExtract.hpp 对 FP4 明确调用 load_cbuf_to_*_s4,旧结构化 wrapper 也会分流到 LoadCbufToCaS4Op/LoadCbufToCbS4Op。这样合法的 FP4 显式调用会静默生成错误指令。请按源元素类型分流到 *_s4(并明确 K 控制字段的单位),或显式拒绝 FP4;同时增加 FP4 L0A/L0B lowering 测试,检查最终 intrinsic 为 .s4

Comment thread lib/PTO/IR/VPTO.cpp Outdated
return success();
};

if (failed(checkNonNegativeConst(op.getMStart(), "m_start")) ||

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 这里仅检查正负,未检查控制字段的硬件位宽。A5 契约中 m_start/k_start/src_stride/dst_stride 为 16 位,m_step/k_step 为 8 位;lowering 又直接移位 OR、没有掩码,所以例如 m_step = 256 会侵入 k_step 字段,m_start = 65536 会侵入 k_start,但 verifier 仍接受。请对静态常量增加上界检查(start/stride ≤ 65535,step ≤ 255),并在该 negative lit 测试中加入越界用例。

@github-actions github-actions Bot added the ci-slow this pr make ci too slow, makesure your pr doesn't cause this label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Warning: @and0d0, ci-sim exceeded its soft runtime budget.

  • vpto-sim-validation runtime: 1h 38m 21s
  • Soft budget: 1h 30m
  • Job conclusion: success
  • Workflow run

This warning is advisory only and does not affect required checks. Please inspect the step timings for an unexpected regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-slow this pr make ci too slow, makesure your pr doesn't cause this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants