Skip to content

fix(vmi): VMI legality checks, vsstb op, and PTODSL VMI surface enforcement - #1087

Merged
zhangstevenunity merged 9 commits into
hw-native-sys:mainfrom
Zhendong404:improve-vmi-legality-check
Aug 5, 2026
Merged

fix(vmi): VMI legality checks, vsstb op, and PTODSL VMI surface enforcement#1087
zhangstevenunity merged 9 commits into
hw-native-sys:mainfrom
Zhendong404:improve-vmi-legality-check

Conversation

@Zhendong404

@Zhendong404 Zhendong404 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Strengthens VMI legality validation and closes PTODSL surface gaps, rebased on current hwsys/main.
Fixes #1058

New op

  • feat(vmi): add vmi.vsstb implementation — adds the block-strided store op with a required mask and fixed zero repeat stride, plus lowering guards: pmode="merge" is now rejected by both the verifier (clear diagnostic) and the legacy lowering instead of being silently dropped.

VMI legality checks

  • fix(vmi): improve legality check for vmi.vload/vstore — memory element compatibility, block-stride/mask rules, and group divisibility are checked in all mode branches.
  • fix(vmi): enhance vcvt conversion attributes — rounding/saturation attribute validation with positive/negative tests.
  • fix(vmi): enforce legal lane counts for vreg and mask — unified group verifiers align with the documented domain.
  • fix(vmi): add UB-backed memory verification for gather/scattervgather/vgatherb/vscatter reject non-UB memory operands at verify time.

PTODSL surface

  • fix(ptodsl): enforce VMI lane-count whitelist on vinterpret_cast — the lane count derived by vinterpret_cast is checked against {1,2,4,8,64,128,256} (previously 8xf32 -> si8 silently produced 32 lanes, bypassing the constructor whitelist); the source layout is only preserved when the lane count is unchanged, and a layout-assigned source across a lane-count change is rejected instead of reusing a stale group/slot layout.
  • test(ptodsl): improve coverage of vmi dsl tests — inventory/emission coverage for the formal pto.vmi namespace.

Test fixes

  • fix(test): fix failed lit testcases — updates tadd_* and soft_postupdate expectations to the deterministic lowering output (constant ordering, set_mask_norm, shared vs duplicated -1 constants) and fixes the vmi_gather_scatter_address_space_invalid RUN line.

Validation

  • check-pto: 1538/1539 pass (1 unsupported: vfsim-costmodel feature off)
  • check-dsl: 25/25 pass

Segfault fix

Root cause

pto.merge_jit_modules() built each kernel in an independent MLIR Context, then directly cloned operations from later modules into the first module. The cloned operations retained types and attributes owned by the source context. When that context was destroyed, destruction of the merged module accessed freed MLIR objects and could terminate with SIGSEGV in mlir::Operation::~Operation().

Fix

Reparse each source module text in the first module's target Context before cloning its operations. This keeps all operations, types, attributes, and dialect objects in the merged module under one Context lifetime.

Validation

  • ptodsl/tests/test_ast_rewrite_example_ir.py: PASS
  • check-dsl: 29/29 passed
  • check-pto: 1622 tests passed, 0 failures
  • Valgrind: no invalid read/use-after-free or pure virtual method called on the merged AST softmax case

@Zhendong404
Zhendong404 force-pushed the improve-vmi-legality-check branch 3 times, most recently from a822e58 to df7c720 Compare August 2, 2026 03:05
@Zhendong404
Zhendong404 force-pushed the improve-vmi-legality-check branch from df7c720 to 09d8bf2 Compare August 4, 2026 13:26
@zhangstevenunity
zhangstevenunity merged commit 9c49c36 into hw-native-sys:main Aug 5, 2026
12 of 13 checks passed
@reedhecre

Copy link
Copy Markdown

A3 板测完成(有跳过)

  • 触发方式:merged
  • 源码提交:9c49c3697de3
  • 结果汇总:OK 220 / FAIL 0 / SKIP 3
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260805_012110_merged_pr1087.log
  • 结果 TSV:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260805_012110_merged_pr1087.tsv

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.

[Feature] Validate VMI register types in PTODSL and TileLang frontends

3 participants