Skip to content

[Bug] PTODSL-vmi, vcadd/vcamx/vcmin/vbrc 在VL=1/2/4/8时触发 VMI-PASS-INVARIANT/VMI-LAYOUT-CONTRACT #1412

Description

@chenben09

Component

PTO Dialect / ODS (include/PTO/IR)

Description

在 vcadd/vcmax/vcmin/vbrc 的 grouped layout / contiguous layout 场景下,VPTO lowering 无法正确生成目标布局。该问题不是数值误差,而是 layout/lowering 阶段失败。

Reproduction (minimal)

@jit_kernel(name, params)

def kernel(in_ptr: pto.ptr(dtype, "gm"), out_ptr: pto.ptr(dtype, "gm")):

    vl = 8

    group = 1

    nbytes = dtypes.size(params["dtype"])

    in_nbytes = int(params["input_elems"]) * dtypes.size(params["dtype"])



    in_ub = pto.castptr(pto.i64(0), pto.ptr(dtype, "ub"))

    out_ub = pto.castptr(pto.i64(in_nbytes), pto.ptr(dtype, "ub"))

    pto.mte_gm_ub(in_ptr, in_ub, 0, in_nbytes, nburst=(1, 0, 0))

    pto.set_flag("MTE2", "V", event_id=0)

    pto.wait_flag("MTE2", "V", event_id=0)



    source = pto.vmi.vload(in_ub, pto.const(0, dtype=pto.index), size=vl)

    mask = pto.vmi.create_mask(vl, size=vl)

    reduced = pto.vmi.vcadd(source, mask, group=group, reassoc=True, pmode=None)

    out_vec = pto.vmi.vbrc(reduced, size=vl)

    pto.vmi.vstore(out_vec, out_ub, pto.const(0, dtype=pto.index))

    pto.set_flag("V", "MTE3", event_id=0)

    pto.wait_flag("V", "MTE3", event_id=0)

    pto.mte_ub_gm(out_ub, out_ptr, nbytes * vl, nburst=(1, 0, 0))

Expected behavior

编译通过,运行通过,若不支持则给出约束

Actual behavior / error logs

1、run 阶段失败,报 `VMI-LAYOUT-CONTRACT`,无法 materialize grouped layout
涉及用例:
  - vcadd/i8_vl8_empty
  - vcadd/i8_vl8_tail
  - vcadd/i8_vl8_all_active
  - vbrc/i8_vl8_group4_grouped_tail
  - vbrc/i8_vl4_group4_grouped_tail

报错日志:


[FAIL] i8_vl64_group4_grouped_tail backend=run | RuntimeError: command failed (1): /home/luyijing/llvm-workspace/.venv/bin/ptoas --pto-arch=a5 --pto-level=level3 --enable-tile-op-expand

/home/luyijing/workspace-pto/pto_test/build/pto-test/20260825-vmi-all-interfaces-ac/sim/msprof-private/vbrc_launch.gAfSwu/ptodsl-cache/kernel_5c9a4b7ba23fd456/kernel.mlir -o /home/luyijing/workspace-pto/pto_test/build/pto-test/20260825-vmi-all-interfaces-ac/sim/msprof-private/vbrc_launch.gAfSwu/ptodsl-cache/kernel_5c9a4b7ba23fd456/kernel.o

[LOG_WARNING] can not open file, file: /home/luyijing/ascend/log/run/plog/plog-48018_20260827103858691.log, possible reason: Read-only file system.Warning: PTO_ISA_PATH/PTO_ISA_ROOT is not set; C++ device object emission may fail to include pto/pto-inst.hpp.

loc("/home/luyijing/workspace-pto/pto_test/build/pto-test/20260825-vmi-all-interfaces-ac/sim/msprof-private/vbrc_launch.gAfSwu/ptodsl-cache/kernel_5c9a4b7ba23fd456/kernel.mlir":20:7): error: VMI-LAYOUT-CONTRACT: cannot materialize requested VMI operand layout #pto.vmi.layout<contiguous, lane_stride = 4>

Error: VPTO emission pipeline failed.

Git commit

10883a8

Host platform

Linux (aarch64)

Target Ascend arch (if relevant)

a5

PTOAS build level (if relevant)

None

Metadata

Metadata

Labels

QAIssues from the QA teambugSomething isn't workingvmi

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions