Skip to content

feat(ptodsl): Migrate TileLib from TilelangDSL to PTODSL: Daemon and metadata#894

Merged
zhangstevenunity merged 64 commits into
hw-native-sys:mainfrom
afshinarefi:mani/ptodsl
Jul 14, 2026
Merged

feat(ptodsl): Migrate TileLib from TilelangDSL to PTODSL: Daemon and metadata#894
zhangstevenunity merged 64 commits into
hw-native-sys:mainfrom
afshinarefi:mani/ptodsl

Conversation

@ManiSadati

@ManiSadati ManiSadati commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

PTOAS currently relies on TileLang DSL to render TileOp templates for the VPTO backend.

This PR introduces a PTODSL-native TileLib path while preserving the existing TileLang backend. It establishes the infrastructure needed to migrate templates incrementally without changing the default backend or requiring performance-based version selection yet.

What changed

PTODSL TileLib

  • Added a PTODSL-native template registry, decorator, metadata model, legality constraints, and render runtime.
  • Added initial A5 templates for:
    • tadd
    • tsub
    • tmul
    • tmax
    • tmin
    • default-precision tdiv
    • tcolmax
  • Added four registered implementations (versions) for tadd and tmul.
  • Added lazy per-operation template loading.
  • Added version selection and structured-MLIR rendering tests.

PTODSL daemon

  • Added an independent Unix-socket daemon, client, helper, wire protocol, and render cache.
  • Added separate RPC operations for:
    • retrieving all legal candidate metadata;
    • rendering a specifically selected candidate.
  • Removed any PTODSL dependency on TileLang template paths or daemon implementation.

PTOAS integration

  • Added --tile-lib-backend=tilelang|ptodsl.
  • Kept TileLang as the default backend.
  • Added InsertTemplateAttributes, which runs before fusion and stores legal candidates on each TileOp as an attribute.
  • Candidate attributes (for now) contain only:
    • id
    • name
    • loop_depth
    • postupdate
    • tail
  • Candidates are sorted by unique ID.
  • Updated ExpandTileOp to consume the attached candidates and render the first remaining candidate.
  • Kept the TileLang expansion path unchanged.
  • PTODSL daemon failures are reported directly and do not silently fall back to TileLang.

Current selection behavior

This PR does not introduce fusion-aware or cost-model-based version selection.

When multiple legal candidates remain, ExpandTileOp deterministically renders candidate index zero. A future change can filter or reorder the candidate array before expansion.

Out of scope

  • Making PTODSL the default TileLib backend.
  • Removing TileLang or lib/TileOps.
  • Fusion-driven performance selection.
  • Complete TileOp/template parity.
  • Mixed tile/scalar template operands.
  • Context-attribute-dependent templates.
  • Cube, DMA, and specialized-layout templates.

Validation

PTODSL TileLib daemon

Run the focused daemon tests:

python3 ptodsl/tests/test_tilelib_daemon.py

This covers:

  • daemon startup and ping;
  • owner-only Unix-socket permissions;
  • legal-candidate metadata queries;
  • request-specific tail metadata;
  • named-candidate rendering;
  • cache hits, clearing, and context-sensitive cache keys;
  • oversized RPC message rejection;
  • stale/broken socket-path cleanup;
  • explicit rejection of unsupported operands and unknown operations.

PTODSL TileLib Python suite

Run all TileLib Python tests:

python3 -m unittest discover \
  -s ptodsl/tests \
  -p 'test_tilelib_*.py'

This covers template registration, legality constraints, candidate selection,
structured MLIR rendering, elementwise templates, and daemon behavior.

PTOAS integration

Run the focused PTODSL and legacy TileLang integration tests through the
generated lit configuration:

"$LLVM_BUILD_DIR/bin/llvm-lit" -sv build/test/lit \
  --filter='expand_tile_op_(ptodsl_tsub|ptodsl_tadd|tilelang_tsub)'

This covers:

  • PTODSL single-candidate expansion;
  • compact multi-candidate metadata insertion;
  • deterministic candidate-zero rendering;
  • InsertTemplateAttributes placement before fusion;
  • legacy TileLang backend compatibility.

@reedhecre

reedhecre commented Jul 1, 2026

Copy link
Copy Markdown

Codex Review

该评论由 review 机器人自动更新。

Summary

Review failed at stage codex-review: exit=1

Findings

未生成结构化 findings,因为 review 过程提前失败。

Log Tail

 .../op_fusion_backend_lifecycle_level3.pto         |   10 +-
 .../op_fusion_frontend_stages_level2.pto           |   12 +-
 .../op_fusion_low_level_loop_dynamic_shape.pto     |   66 +-
 .../op_fusion_low_level_loop_reduce_epilogue.pto   |   12 +-
 ..._level_loop_softmax_prepare_unaligned_nopad.pto |    8 +-
 test/lit/vpto/expand_tile_op_ptodsl_tadd.pto       |   67 +
 test/lit/vpto/expand_tile_op_ptodsl_tsub.pto       |   47 +
 .../expand_tile_op_ptodsl_view_stride_cache.pto    |   67 +
 test/lit/vpto/fold_tile_buf_intrinsics.pto         |    5 +-
 test/lit/vpto/tcolargmax.pto                       |    2 +-
 test/lit/vpto/tcolargmin.pto                       |    2 +-
 .../textract_verify_invalid_vec2mat_loc_pair.pto   |    2 +-
 .../src/st/smoke/testcase/run_ptoas_to_file.cmake  |   11 +
 .../npu/a5/src/st/testcase/run_ptoas_to_file.cmake |   11 +
 test/tilelang_st/script/run_a5_st_all_parallel.py  |  418 ++++++
 test/tilelang_st/script/run_ptodsl_st_parallel.py  |  344 +++++
 tools/ptoas/CMakeLists.txt                         |    9 +-
 tools/ptoas/TilelangDaemon.cpp                     |   49 +-
 tools/ptoas/TilelangDaemon.h                       |   13 +-
 tools/ptoas/ptoas.cpp                              |  157 +-
 176 files changed, 16555 insertions(+), 258 deletions(-)
===== END STAGE clone rc=0 @ 2026-07-14 01:10:37 =====

===== STAGE codex-review @ 2026-07-14 01:10:37 =====
set -euo pipefail
cd '/tmp/ptoas-pr-review-monitor/runs/20260714_011029_pr894/repo'
'codex' exec -C '/tmp/ptoas-pr-review-monitor/runs/20260714_011029_pr894/repo' -s read-only -c 'model_provider="codereview"' -c 'model="gpt-5.4"' -c 'model_reasoning_effort="xhigh"' --output-schema '/tmp/ptoas-pr-review-monitor/runs/20260714_011029_pr894/review_schema.json' -o '/tmp/ptoas-pr-review-monitor/runs/20260714_011029_pr894/codex_last_message.json' --color never - < '/tmp/ptoas-pr-review-monitor/runs/20260714_011029_pr894/review_prompt.txt'
[monitor] stage timeout: 1800s
OpenAI Codex v0.115.0 (research preview)
--------
workdir: /tmp/ptoas-pr-review-monitor/runs/20260714_011029_pr894/repo
model: gpt-5.4
provider: codereview
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: none
session id: 019f5c75-991d-7133-a310-b8029d14bd43
--------
user
你现在在审查 GitHub PR。

仓库:hw-native-sys/PTOAS
PR:#894 feat(ptodsl): Migrate TileLib from TilelangDSL to PTODSL: Daemon and metadata
作者:ManiSadati
base branch:origin/main
head branch:HEAD(当前已 checkout 到 PR head)

要求:
1. 只审查这个 PR 相对 origin/main 的改动,必要时可以看上下文文件。
2. 重点找真实的 correctness / regression / contract mismatch / CI / runtime / compatibility 问题。
3. 不要提纯风格建议,不要提低价值猜测。
4. 严格按优先级输出:
   - P1:高概率会导致错误结果、编译/运行失败、严重回归、发布阻断
   - P2:重要缺陷、行为回归、遗漏校验/测试、较大兼容性问题
   - P3:次要但明确可改的问题
5. 如果没有问题,summary 直接写:未检查到 PR #894 存在问题,并返回 findings=[]。
6. 如果有问题,summary 简洁概括,findings 里每条都要给出:
   - severity
   - title
   - body(说明为什么是问题,尽量具体)
   - file(尽量给相对路径)
   - line(能确定就填整数,否则 null)

建议先查看:
- git status --short
- git diff --stat origin/main...HEAD
- git diff --unified=80 origin/main...HEAD

最终输出必须严格匹配 JSON schema。

mcp startup: no servers
Reconnecting... 1/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1a9e6fdfdabd8a6-LAX, request id: ce8b2c9f-ec62-4173-91ce-71fa2aec8212)
Reconnecting... 2/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1a9e700fcd3d7a8-LAX, request id: 32f08c2c-3a4e-4a16-a776-75b270e7b19d)
Reconnecting... 3/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1a9e7054d22fa3a-SJC, request id: aebd815e-14f5-4796-b8a7-71b9cda0aab3)
Reconnecting... 4/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1a9e70c7c33eb31-SJC, request id: 6ca05efb-7c8b-43a0-b253-2d39d3266bf2)
Reconnecting... 5/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1a9e718be83c528-SJC, request id: 0b84de4c-6eb3-4493-8e8f-f02fe86c4414)
ERROR: unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1a9e72fbc2067f8-SJC, request id: a406afa9-15ec-42af-a6a0-a3a678554d84
Warning: no last agent message; wrote empty content to /tmp/ptoas-pr-review-monitor/runs/20260714_011029_pr894/codex_last_message.json
===== END STAGE codex-review rc=1 @ 2026-07-14 01:10:47 =====

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the PTODSL TileLib backend, adding the InsertTemplateAttributes pass to attach legal template candidates to tile operations and updating ExpandTileOp to support both TileLang and PTODSL backends. It also implements a Unix-socket daemon server and client in Python to handle template metadata queries and specialization rendering. The review feedback is highly constructive, pointing out critical issues such as a potential denial-of-service vulnerability in socket message framing, race conditions in the template registry under concurrent access, and incorrect cache eviction logic. Additionally, the feedback addresses cross-platform compilation issues on Windows caused by POSIX-specific headers and functions, and suggests using MLIR's diagnostic infrastructure instead of direct llvm::errs() calls for better error reporting.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ptodsl/ptodsl/tilelib/serving/wire.py
Comment thread ptodsl/ptodsl/tilelib/registry.py
Comment thread ptodsl/ptodsl/tilelib/serving/daemon.py Outdated
Comment thread ptodsl/ptodsl/tilelib/serving/daemon.py Outdated
Comment thread tools/ptoas/TilelangDaemon.cpp
Comment thread tools/ptoas/TilelangDaemon.cpp
Comment thread lib/PTO/Transforms/ExpandTileOp.cpp
Comment thread lib/PTO/Transforms/ExpandTileOp.cpp
@ManiSadati ManiSadati changed the title Mani/ptodsl feat(ptodsl): Migrate TileLib from TilelangDSL to PTODSL: Daemon and metadata Jul 1, 2026
Comment thread ptodsl/docs/tilelib-migration-testing.md Outdated
Comment thread ptodsl/ptodsl/tilelib/templates/a5/tabs.py
Comment thread tools/ptoas/ptoas.cpp
Comment thread tools/ptoas/ptoas.cpp
@ManiSadati

Copy link
Copy Markdown
Contributor Author

/run a5

@ManiSadati

Copy link
Copy Markdown
Contributor Author

/run a3

@reedhecre

Copy link
Copy Markdown

已接收 /run a5,A5 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

已接收 /run a3,A3 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

A5 板测失败

日志尾部

_sync_basic.py) OK   generated: test_mem_inject_sync_basic-pto.cpp
Sync(test_set_wait_unified_api.py) OK   generated: test_set_wait_unified_api-pto.cpp
Sync(test_tmov_col_major_16x1_align_a5.pto) FAIL ptoas failed: test_tmov_col_major_16x1_align_a5.pto
Sync(test_tmov_col_major_16x1_align_a5.py) OK   generated: test_tmov_col_major_16x1_align_a5-pto.cpp
Sync(test_tmov_row_major_1x16_control_a5.pto) FAIL ptoas failed: test_tmov_row_major_1x16_control_a5.pto
Sync(test_tmov_row_major_1x16_control_a5.py) OK   generated: test_tmov_row_major_1x16_control_a5-pto.cpp
Sync(tmatmulk_autosync_a5.py) OK   generated: tmatmulk_autosync_a5-pto.cpp
TileSetGetValue(tile_getval_mat_invalid.py) XFAIL ptobc encode failed as expected
TileSetGetValue(tileSetGetValue.py) OK   generated: tileSetGetValue-pto.cpp
TInsert(tinsert_fp.py) OK   generated: tinsert_fp-pto.cpp
TInsert(tinsert.py) OK   generated: tinsert-pto.cpp
Tpows(tpows.py) OK   generated: tpows-pto.cpp
Tpow(tpow.py) OK   generated: tpow-pto.cpp
TPrefetchAsync(tprefetch_async_binding.py) OK   generated: tprefetch_async_binding-pto.cpp
TPrefetch(tprefetch.py) OK   generated: tprefetch-pto.cpp
TquantMx(tquant_mx.pto) OK   generated: tquant_mx-pto.cpp
Trans(trans.py) OK   generated: trans-pto.cpp
Trap(trap.py) OK   generated: trap-pto.cpp
TTri(ttri.py) OK   generated: ttri-pto.cpp
VectorAddition(vadd_pto_ir.py) OK   generated: vadd_pto_ir-pto.cpp
VectorAddition(vadd_validshape_hyper.py) OK   generated: vadd_validshape_hyper-pto.cpp
VectorAddition(vectorAddition.py) OK   generated: vectorAddition-pto.cpp
Xors(xors.py) OK   generated: xors-pto.cpp
Xor(xor.py)  OK   generated: xor-pto.cpp
-----------------------------
OK=240  FAIL=4  SKIP=29
=============================
===== END STAGE sample-build-and-test rc=1 @ 2026-07-13 11:00:14 =====

@reedhecre

Copy link
Copy Markdown

A3 板测完成(有跳过)

@alanwangtianqiwork

Copy link
Copy Markdown
Contributor

/run a5

@reedhecre

Copy link
Copy Markdown

已接收 /run a5,A5 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

A5 板测失败

失败用例

  • test_intercore_sync_a5 (run, exit=139)
  • shr (run, exit=139)
  • sels (run, exit=2)
  • sel (run, exit=2)
  • scatter (run, exit=2)
  • rowexpandsub (run, exit=2)
  • rowexpandmul (run, exit=2)
  • rowexpanddiv (run, exit=2)
  • bitcast_inplace_cvt (run, exit=139)
  • rope_kv_cache (run, exit=2)
  • rmsnorm (run, exit=2)
  • post_rmsnorm (run, exit=2)
  • partmin (run, exit=2)
  • partition5d_dynamic_a5 (run, exit=139)
  • mscatter (run, exit=2)
  • movfp_fixpipe_reuse (run, exit=2)
  • mgather (run, exit=2)
  • colexpandsub (run, exit=139)
  • colexpandmax (run, exit=139)
  • cmps (run, exit=2)
  • cmp (run, exit=2)

@reedhecre

Copy link
Copy Markdown

A5 板测失败详情:PR #894

test_intercore_sync_a5

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 1153224 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-13 22:42:58] ERROR: testcase failed (exit 139): test_intercore_sync_a5
shr

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 1174794 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-13 22:52:54] ERROR: testcase failed (exit 139): shr
sels

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=66.99866366386414 at idx=92 (golden=-2.9986636638641357, out=64.0, dtype=float32)
[ERROR] compare failed
[2026-07-13 22:53:46] ERROR: testcase failed (exit 2): sels
sel

stage=run info=exit=2

[ERROR] Mismatch: golden_v4.bin vs v4.bin, max diff=5.792495250701904 at idx=298 (golden=2.8790016174316406, out=-2.9134936332702637, dtype=float32)
[ERROR] compare failed
[2026-07-13 22:53:57] ERROR: testcase failed (exit 2): sel
scatter

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=3.6916218996047974 at idx=10 (golden=2.568453073501587, out=-1.1231688261032104, dtype=float32)
[ERROR] compare failed
[2026-07-13 22:54:08] ERROR: testcase failed (exit 2): scatter
rowexpandsub

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=5.565198540687561 at idx=202 (golden=1.555970311164856, out=-4.009228229522705, dtype=float32)
[ERROR] compare failed
[2026-07-13 22:55:42] ERROR: testcase failed (exit 2): rowexpandsub
rowexpandmul

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=14.702873229980469 at idx=206 (golden=8.388465881347656, out=-6.3144073486328125, dtype=float32)
[ERROR] compare failed
[2026-07-13 22:55:54] ERROR: testcase failed (exit 2): rowexpandmul
rowexpanddiv

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=18.47865390777588 at idx=963 (golden=10.328862190246582, out=-8.149791717529297, dtype=float32)
[ERROR] compare failed
[2026-07-13 22:57:03] ERROR: testcase failed (exit 2): rowexpanddiv
bitcast_inplace_cvt

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 1187568 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-13 22:58:04] ERROR: testcase failed (exit 139): bitcast_inplace_cvt
rope_kv_cache

stage=run info=exit=2

[ERROR] Mismatch (bf16 golden_v1.bin vs v1.bin): max ulp diff=30463 at idx=26720 (golden_bits=48012, out_bits=15218, golden=-0.0042724609375, out=0.003692626953125)
[ERROR] compare failed
[2026-07-13 22:59:21] ERROR: testcase failed (exit 2): rope_kv_cache
rmsnorm

stage=run info=exit=2

[ERROR] Mismatch (bf16 golden_v2.bin vs v2.bin): max ulp diff=4 at idx=73741 (golden_bits=15203, out_bits=15207, golden=0.0034637451171875, out=0.0035247802734375)
[ERROR] compare failed
[2026-07-13 22:59:33] ERROR: testcase failed (exit 2): rmsnorm
post_rmsnorm

stage=run info=exit=2

[ERROR] Mismatch (bf16 golden_v2.bin vs v2.bin): max ulp diff=3 at idx=8821 (golden_bits=15613, out_bits=15616, golden=0.0308837890625, out=0.03125)
[ERROR] compare failed
[2026-07-13 23:01:32] ERROR: testcase failed (exit 2): post_rmsnorm
partmin

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=nan at idx=112 (golden=-0.0, out=nan, dtype=float16)
[ERROR] compare failed
[2026-07-13 23:11:05] ERROR: testcase failed (exit 2): partmin
partition5d_dynamic_a5

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 1219739 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-13 23:12:06] ERROR: testcase failed (exit 139): partition5d_dynamic_a5
mscatter

stage=run info=exit=2

/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:104:25: error: cannot cast from type 'GlobalTensor<int32_t, pto::Shape<1, 1, 1, 32, 32>, pto::Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>' (aka 'GlobalTensor<int, Shape<1, 1, 1, 32, 32>, Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>') to pointer type '__gm__ int32_t *' (aka '__gm__ int *')
  __gm__ int32_t* v17 = (__gm__ int32_t*) v16;
                        ^~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:301:
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:461:24: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using T = typename TileSrc::DType;
                       ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:2055:5: note: in instantiation of function template specialization 'pto::MSCATTER_IMPL<pto::Coalesce::Row, pto::ScatterAtomicOp::None, pto::ScatterOOB::Undefined, pto::ScatterConflict::Last, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
    MSCATTER_IMPL<Mode>(dst, src, indexes);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:137:3: note: in instantiation of function template specialization 'pto::MSCATTER<pto::Coalesce::Row, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
  MSCATTER<pto::Coalesce::Row>(v17, v28, v29);
  ^
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:301:
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:462:27: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using TIdx = typename TileIdx::DType;
                          ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:466:60: error: member reference base type '__gm__ int *' is not a structure or union
    __gm__ T *tablePtr = reinterpret_cast<__gm__ T *>(table.data());
                                                      ~~~~~^~~~~
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:468:35: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    constexpr int kSrcValidRowS = TileSrc::ValidRow;
                                  ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:469:35: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    constexpr int kSrcValidColS = TileSrc::ValidCol;
                                  ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:473:35: error: member reference base type '__ubuf__ int *' is not a structure or union
    const uint32_t validRows = src.GetValidRow();
                               ~~~^~~~~~~~~~~~
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:474:35: error: member reference base type '__ubuf__ int *' is not a structure or union
    const uint32_t validCols = src.GetValidCol();
                               ~~~^~~~~~~~~~~~
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:477:37: error: type '__gm__ int *' cannot be used prior to '::' because it has no members
        using TableShape = typename GlobalTable::Shape;
                                    ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:480:63: error: member reference base type '__gm__ int *' is not a structure or union
        const uint32_t tableRows = static_cast<uint32_t>(table.GetShape(GlobalTensorDim::DIM_3));
                                                         ~~~~~^~~~~~~~~
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:482:26: error: member reference base type '__ubuf__ int *' is not a structure or union
            tablePtr, src.data(), indices.data(), validRows, validCols, tableRows);
                      ~~~^~~~~
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:394:24: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using T = typename TileSrc::DType;
                       ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:464:5: note: in instantiation of function template specialization 'pto::MScatterCheck<pto::Coalesce::Row, pto::ScatterAtomicOp::None, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
    MScatterCheck<Mode, Atomic>(table, src, indices);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:2055:5: note: in instantiation of function template specialization 'pto::MSCATTER_IMPL<pto::Coalesce::Row, pto::ScatterAtomicOp::None, pto::ScatterOOB::Undefined, pto::ScatterConflict::Last, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
    MSCATTER_IMPL<Mode>(dst, src, indexes);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:137:3: note: in instantiation of function template specialization 'pto::MSCATTER<pto::Coalesce::Row, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
  MSCATTER<pto::Coalesce::Row>(v17, v28, v29);
  ^
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:301:
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:395:27: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using TIdx = typename TileIdx::DType;
                          ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:404:43: error: type '__gm__ int *' cannot be used prior to '::' because it has no members
    static_assert(std::is_same_v<typename GlobalTable::DType, __gm__ T>,
                                          ^
14 errors generated.
gmake[2]: *** [CMakeFiles/mscatter_kernel.dir/build.make:76: CMakeFiles/mscatter_kernel.dir/mscatter_kernel.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/mscatter_kernel.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
[2026-07-13 23:13:57] ERROR: testcase failed (exit 2): mscatter
movfp_fixpipe_reuse

stage=run info=exit=2

[ERROR] Mismatch: golden_v5.bin vs v5.bin, max diff=nan at idx=8 (golden=-35.25, out=nan, dtype=float16)
[ERROR] Mismatch: golden_v6.bin vs v6.bin, max diff=nan at idx=120 (golden=-8.3125, out=nan, dtype=float16)
[ERROR] Mismatch: golden_v7.bin vs v7.bin, max diff=nan at idx=172 (golden=-17.5, out=nan, dtype=float16)
[ERROR] compare failed
[2026-07-13 23:14:49] ERROR: testcase failed (exit 2): movfp_fixpipe_reuse
mgather

stage=run info=exit=2

/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:92:25: error: cannot cast from type 'GlobalTensor<int32_t, pto::Shape<1, 1, 1, 32, 32>, pto::Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>' (aka 'GlobalTensor<int, Shape<1, 1, 1, 32, 32>, Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>') to pointer type '__gm__ int32_t *' (aka '__gm__ int *')
  __gm__ int32_t* v11 = (__gm__ int32_t*) v10;
                        ^~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:300:
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MGather.hpp:513:24: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using T = typename TileDst::DType;
                       ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:2004:5: note: in instantiation of function template specialization 'pto::MGATHER_IMPL<pto::Coalesce::Row, pto::GatherOOB::Undefined, __ubuf__ int *, __gm__ int *, __ubuf__ int *>' requested here
    MGATHER_IMPL<CMode>(dst, src, indexes);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:130:3: note: in instantiation of function template specialization 'pto::MGATHER<pto::Coalesce::Row, __ubuf__ int *, __gm__ int *, __ubuf__ int *>' requested here
  MGATHER<pto::Coalesce::Row>(v26, v11, v25);
  ^
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:300:
/tmp/ptoas-board-monitor-a5/runs/20260713_222805_manual_pr894/payload/pto-isa/include/pto/npu/a5/MGather.hpp:515:19: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    if constexpr (TileDst::Loc == TileType::Mat) {
                  ^
3 errors generated.
gmake[2]: *** [CMakeFiles/mgather_kernel.dir/build.make:76: CMakeFiles/mgather_kernel.dir/mgather_kernel.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/mgather_kernel.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
[2026-07-13 23:15:13] ERROR: testcase failed (exit 2): mgather
colexpandsub

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 1260646 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-13 23:28:41] ERROR: testcase failed (exit 139): colexpandsub
colexpandmax

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 1262572 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-13 23:29:38] ERROR: testcase failed (exit 139): colexpandmax
cmps

stage=run info=exit=2

[ERROR] Packed mask mismatch: golden_v2.bin vs v2.bin, idx=4 (golden=98, out=0)
[ERROR] compare failed
[2026-07-13 23:30:58] ERROR: testcase failed (exit 2): cmps
cmp

stage=run info=exit=2

[ERROR] Packed mask mismatch: golden_v3.bin vs v3.bin, idx=4 (golden=49, out=0)
[ERROR] compare failed
[2026-07-13 23:31:09] ERROR: testcase failed (exit 2): cmp

@Zhendong404

Copy link
Copy Markdown
Contributor

/run a5

@reedhecre

Copy link
Copy Markdown

已接收 /run a5,A5 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

A5 板测失败

失败用例

  • sels (run, exit=2)
  • sel (run, exit=2)
  • scatter (run, exit=2)
  • rowexpandsub (run, exit=2)
  • rowexpandmul (run, exit=2)
  • rowexpanddiv (run, exit=2)
  • rope_kv_cache (run, exit=2)
  • rmsnorm (run, exit=2)
  • post_rmsnorm (run, exit=2)
  • vector_example_dag_kernel_add (run, exit=139)
  • plan_memory_nested_loops (run, exit=139)
  • partmin (run, exit=2)
  • mscatter (run, exit=2)
  • movfp_fixpipe_reuse (run, exit=2)
  • mgather (run, exit=2)
  • cmps (run, exit=2)
  • cmp (run, exit=2)

@reedhecre

Copy link
Copy Markdown

A5 板测失败详情:PR #894

sels

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=66.99866366386414 at idx=92 (golden=-2.9986636638641357, out=64.0, dtype=float32)
[ERROR] compare failed
[2026-07-14 11:20:42] ERROR: testcase failed (exit 2): sels
sel

stage=run info=exit=2

[ERROR] Mismatch: golden_v4.bin vs v4.bin, max diff=5.792495250701904 at idx=298 (golden=2.8790016174316406, out=-2.9134936332702637, dtype=float32)
[ERROR] compare failed
[2026-07-14 11:20:54] ERROR: testcase failed (exit 2): sel
scatter

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=3.6916218996047974 at idx=10 (golden=2.568453073501587, out=-1.1231688261032104, dtype=float32)
[ERROR] compare failed
[2026-07-14 11:21:05] ERROR: testcase failed (exit 2): scatter
rowexpandsub

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=5.565198540687561 at idx=202 (golden=1.555970311164856, out=-4.009228229522705, dtype=float32)
[ERROR] compare failed
[2026-07-14 11:22:39] ERROR: testcase failed (exit 2): rowexpandsub
rowexpandmul

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=14.702873229980469 at idx=206 (golden=8.388465881347656, out=-6.3144073486328125, dtype=float32)
[ERROR] compare failed
[2026-07-14 11:22:50] ERROR: testcase failed (exit 2): rowexpandmul
rowexpanddiv

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=18.47865390777588 at idx=963 (golden=10.328862190246582, out=-8.149791717529297, dtype=float32)
[ERROR] compare failed
[2026-07-14 11:24:02] ERROR: testcase failed (exit 2): rowexpanddiv
rope_kv_cache

stage=run info=exit=2

[ERROR] Mismatch (bf16 golden_v1.bin vs v1.bin): max ulp diff=30463 at idx=26720 (golden_bits=48012, out_bits=15218, golden=-0.0042724609375, out=0.003692626953125)
[ERROR] compare failed
[2026-07-14 11:26:25] ERROR: testcase failed (exit 2): rope_kv_cache
rmsnorm

stage=run info=exit=2

[ERROR] Mismatch (bf16 golden_v2.bin vs v2.bin): max ulp diff=4 at idx=73741 (golden_bits=15203, out_bits=15207, golden=0.0034637451171875, out=0.0035247802734375)
[ERROR] compare failed
[2026-07-14 11:26:37] ERROR: testcase failed (exit 2): rmsnorm
post_rmsnorm

stage=run info=exit=2

[ERROR] Mismatch (bf16 golden_v2.bin vs v2.bin): max ulp diff=3 at idx=8821 (golden_bits=15613, out_bits=15616, golden=0.0308837890625, out=0.03125)
[ERROR] compare failed
[2026-07-14 11:28:37] ERROR: testcase failed (exit 2): post_rmsnorm
vector_example_dag_kernel_add

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 2049191 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-14 11:30:27] ERROR: testcase failed (exit 139): vector_example_dag_kernel_add
plan_memory_nested_loops

stage=run info=exit=139

./test/npu_validation/scripts/run_remote_npu_validation.sh: line 848: 2062732 Segmentation fault      (core dumped) LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
[2026-07-14 11:35:01] ERROR: testcase failed (exit 139): plan_memory_nested_loops
partmin

stage=run info=exit=2

[ERROR] Mismatch: golden_v3.bin vs v3.bin, max diff=nan at idx=112 (golden=-0.0, out=nan, dtype=float16)
[ERROR] compare failed
[2026-07-14 11:38:08] ERROR: testcase failed (exit 2): partmin
mscatter

stage=run info=exit=2

/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:104:25: error: cannot cast from type 'GlobalTensor<int32_t, pto::Shape<1, 1, 1, 32, 32>, pto::Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>' (aka 'GlobalTensor<int, Shape<1, 1, 1, 32, 32>, Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>') to pointer type '__gm__ int32_t *' (aka '__gm__ int *')
  __gm__ int32_t* v17 = (__gm__ int32_t*) v16;
                        ^~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:301:
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:461:24: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using T = typename TileSrc::DType;
                       ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:2055:5: note: in instantiation of function template specialization 'pto::MSCATTER_IMPL<pto::Coalesce::Row, pto::ScatterAtomicOp::None, pto::ScatterOOB::Undefined, pto::ScatterConflict::Last, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
    MSCATTER_IMPL<Mode>(dst, src, indexes);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:137:3: note: in instantiation of function template specialization 'pto::MSCATTER<pto::Coalesce::Row, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
  MSCATTER<pto::Coalesce::Row>(v17, v28, v29);
  ^
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:301:
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:462:27: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using TIdx = typename TileIdx::DType;
                          ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:466:60: error: member reference base type '__gm__ int *' is not a structure or union
    __gm__ T *tablePtr = reinterpret_cast<__gm__ T *>(table.data());
                                                      ~~~~~^~~~~
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:468:35: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    constexpr int kSrcValidRowS = TileSrc::ValidRow;
                                  ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:469:35: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    constexpr int kSrcValidColS = TileSrc::ValidCol;
                                  ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:473:35: error: member reference base type '__ubuf__ int *' is not a structure or union
    const uint32_t validRows = src.GetValidRow();
                               ~~~^~~~~~~~~~~~
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:474:35: error: member reference base type '__ubuf__ int *' is not a structure or union
    const uint32_t validCols = src.GetValidCol();
                               ~~~^~~~~~~~~~~~
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:477:37: error: type '__gm__ int *' cannot be used prior to '::' because it has no members
        using TableShape = typename GlobalTable::Shape;
                                    ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:480:63: error: member reference base type '__gm__ int *' is not a structure or union
        const uint32_t tableRows = static_cast<uint32_t>(table.GetShape(GlobalTensorDim::DIM_3));
                                                         ~~~~~^~~~~~~~~
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:482:26: error: member reference base type '__ubuf__ int *' is not a structure or union
            tablePtr, src.data(), indices.data(), validRows, validCols, tableRows);
                      ~~~^~~~~
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:394:24: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using T = typename TileSrc::DType;
                       ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:464:5: note: in instantiation of function template specialization 'pto::MScatterCheck<pto::Coalesce::Row, pto::ScatterAtomicOp::None, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
    MScatterCheck<Mode, Atomic>(table, src, indices);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:2055:5: note: in instantiation of function template specialization 'pto::MSCATTER_IMPL<pto::Coalesce::Row, pto::ScatterAtomicOp::None, pto::ScatterOOB::Undefined, pto::ScatterConflict::Last, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
    MSCATTER_IMPL<Mode>(dst, src, indexes);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:137:3: note: in instantiation of function template specialization 'pto::MSCATTER<pto::Coalesce::Row, __gm__ int *, __ubuf__ int *, __ubuf__ int *>' requested here
  MSCATTER<pto::Coalesce::Row>(v17, v28, v29);
  ^
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mscatter/mscatter/mscatter_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:301:
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:395:27: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using TIdx = typename TileIdx::DType;
                          ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MScatter.hpp:404:43: error: type '__gm__ int *' cannot be used prior to '::' because it has no members
    static_assert(std::is_same_v<typename GlobalTable::DType, __gm__ T>,
                                          ^
14 errors generated.
gmake[2]: *** [CMakeFiles/mscatter_kernel.dir/build.make:76: CMakeFiles/mscatter_kernel.dir/mscatter_kernel.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/mscatter_kernel.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
[2026-07-14 11:41:06] ERROR: testcase failed (exit 2): mscatter
movfp_fixpipe_reuse

stage=run info=exit=2

[ERROR] Mismatch: golden_v5.bin vs v5.bin, max diff=nan at idx=8 (golden=-35.25, out=nan, dtype=float16)
[ERROR] Mismatch: golden_v6.bin vs v6.bin, max diff=nan at idx=120 (golden=-8.3125, out=nan, dtype=float16)
[ERROR] Mismatch: golden_v7.bin vs v7.bin, max diff=nan at idx=172 (golden=-17.5, out=nan, dtype=float16)
[ERROR] compare failed
[2026-07-14 11:41:58] ERROR: testcase failed (exit 2): movfp_fixpipe_reuse
mgather

stage=run info=exit=2

/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:92:25: error: cannot cast from type 'GlobalTensor<int32_t, pto::Shape<1, 1, 1, 32, 32>, pto::Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>' (aka 'GlobalTensor<int, Shape<1, 1, 1, 32, 32>, Stride<1024, 1024, 1024, 32, 1>, pto::Layout::ND>') to pointer type '__gm__ int32_t *' (aka '__gm__ int *')
  __gm__ int32_t* v11 = (__gm__ int32_t*) v10;
                        ^~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:300:
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MGather.hpp:513:24: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    using T = typename TileDst::DType;
                       ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:2004:5: note: in instantiation of function template specialization 'pto::MGATHER_IMPL<pto::Coalesce::Row, pto::GatherOOB::Undefined, __ubuf__ int *, __gm__ int *, __ubuf__ int *>' requested here
    MGATHER_IMPL<CMode>(dst, src, indexes);
    ^
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:130:3: note: in instantiation of function template specialization 'pto::MGATHER<pto::Coalesce::Row, __ubuf__ int *, __gm__ int *, __ubuf__ int *>' requested here
  MGATHER<pto::Coalesce::Row>(v26, v11, v25);
  ^
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/npu_validation/Mgather/mgather/mgather_kernel.cpp:32:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/pto-inst.hpp:30:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr.hpp:18:
In file included from /tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/common/pto_instr_impl.hpp:300:
/tmp/ptoas-board-monitor-a5/runs/20260714_105505_manual_pr894/payload/pto-isa/include/pto/npu/a5/MGather.hpp:515:19: error: type '__ubuf__ int *' cannot be used prior to '::' because it has no members
    if constexpr (TileDst::Loc == TileType::Mat) {
                  ^
3 errors generated.
gmake[2]: *** [CMakeFiles/mgather_kernel.dir/build.make:76: CMakeFiles/mgather_kernel.dir/mgather_kernel.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/mgather_kernel.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
[2026-07-14 11:42:22] ERROR: testcase failed (exit 2): mgather
cmps

stage=run info=exit=2

[ERROR] Packed mask mismatch: golden_v2.bin vs v2.bin, idx=4 (golden=98, out=0)
[ERROR] compare failed
[2026-07-14 11:58:37] ERROR: testcase failed (exit 2): cmps
cmp

stage=run info=exit=2

[ERROR] Packed mask mismatch: golden_v3.bin vs v3.bin, idx=4 (golden=49, out=0)
[ERROR] compare failed
[2026-07-14 11:58:49] ERROR: testcase failed (exit 2): cmp

@zhangstevenunity zhangstevenunity 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.

Review - feat(ptodsl): Migrate TileLib to PTODSL (Daemon + metadata)

Deep-dive review of the C++ integration (InsertTemplateAttributes, ExpandTileOp, ptoas.cpp, PTOViewToMemref, FoldTileBufIntrinsics, TilelangDaemon), the PTODSL serving layer (daemon / wire / registry / render / constraints), and the 115 A5 templates. This is a well-architected, substantial piece of work, and the earlier bot-flagged infra issues are genuinely resolved. My one blocking concern is about what this PR ships as the default, not the infrastructure itself.

Blocker: this PR silently makes PTODSL the default backend while the A5 board is red

The description says "Kept TileLang as the default backend" and lists "Making PTODSL the default TileLib backend" under Out of scope. The code does the opposite:

  • tools/ptoas/ptoas.cpp:419 -> llvm::cl::init(TileLibBackend::PTODSL)
  • include/PTO/Transforms/Passes.td:545 -> tileLibBackend default "ptodsl"

(Commit c5e583a9 "make ptodsl default"; ptodsl/README.md was updated to match, so only the PR body is now stale.)

This matters because the now-default A5 path is failing the board. Latest run in this PR (69df138b84fb, 2026-07-14): OK 209 / FAIL 17 / SKIP 1, with genuine numeric miscompiles (not infra flakes):

  • sel, sels, cmp, cmps
  • rowexpandsub, rowexpandmul, rowexpanddiv
  • scatter, mscatter, mgather
  • partmin, movfp_fixpipe_reuse
  • rmsnorm, post_rmsnorm, rope_kv_cache
  • segfaults: plan_memory_nested_loops, vector_example_dag_kernel_add (exit 139)

The new expand_tile_op_ptodsl_* lit tests are FileCheck-structural only (they verify candidate-metadata insertion and MLIR shape, not numeric output), so ninja check-pto is green while these kernels compute wrong answers. The board (remote-NPU) is the only numeric gate, and it is red. The failures are A5-specific because templates exist only under templates/a5/ (A3/EmitC is unaffected, hence A3's 221/0).

Recommendation: keep --tile-lib-backend=tilelang as the default in this PR (matching the stated scope), land the PTODSL infra + templates behind the opt-in flag, and flip the default in a focused follow-up once the A5 board is green. That also de-risks the deliberate "no fallback to TileLang" policy: PTODSL-default + no-fallback means any daemon/env misconfiguration becomes a hard compile failure for every A5 user.

The failing set is disparate (the shared row-expand body and surface vsub/vmul/vdiv are operand-order-correct; the sel/cmp f32 paths use intricate pintlv_b16/punpack predicate interleaving that the out=64.0 constant mismatch implicates), so these look like per-template bugs the team is already iterating on. I am not asking to fix them all here, only not to default onto them yet.

Non-blocking

Daemon lifecycle (confirmed):

  • Multi-daemon process leak in mixed-backend fatobj compiles. runPTOASJobs runs child jobs in a sequential in-process loop (driver.cpp:1195), and each VPTO child with tile ops calls DaemonManager::start, which uses a pid-only socket path (TilelangDaemon.cpp:28) and overwrites the single static processInfo slot with no isRunning() guard (TilelangDaemon.cpp:87). With >=2 VPTO-tile-op children, only the last daemon pid is tracked; stop() kills only that one, leaking the earlier python -m ...daemon process(es). Suggest guarding on isRunning() (reuse the daemon) and/or making the socket path unique per job.
  • No cleanup on signal/crash. Cleanup is registered only via std::atexit (TilelangDaemon.cpp:142), which does not run on SIGINT (Ctrl-C), SIGTERM, or SIGSEGV, leaking the daemon process and /tmp/tilelib_daemon_{pid}.sock. Pre-existing, but PR #894 makes this the default path, so it is now the common case.

Daemon has no per-connection recv timeout. serving/daemon.py:428 + wire.py:recv_exactly: the server is now sequential, with no timeout on accepted sockets. A client that sends a 4-byte length prefix then fewer bytes and holds the connection wedges the single serve thread indefinitely; later real RPCs hang until each caller's 30s ExecuteAndWait fires, and the daemon never recovers. Same-user only (chmod 0o600), and a killed client EOFs cleanly, so only a live partial-send wedges it.

constraints.py:332 swallows all constraint-predicate exceptions as "not satisfied." A buggy predicate (typo / AttributeError) silently makes its candidate illegal instead of surfacing; if it is the only candidate, the op later fails with a confusing "no legal template candidates." Consider letting unexpected exceptions propagate (or log them).

Compile-time cost: 2N Python subprocess spawns. InsertTemplateAttributes spawns one get_metadata helper per tile op and ExpandTileOp one render helper per op (ExpandTileOp.cpp:1015), each re-importing the client stack; the metadata half is new work this PR adds. Worth batching or reusing a persistent client in a follow-up.

Minor daemon hardening: TOCTOU between bind() and chmod(0o600) (daemon.py:326, tighten via umask(0o077) before bind); a successful render >64 MB escapes send_message as an uncaught ValueError past dispatch's try; and context_attrs merge precedence differs between metadata_request (attrs override) and evaluate_candidate (setdefault, built context wins) - align them.

Verified good

  • Wire DoS fixed: length prefix checked against the 64 MiB cap before allocation (wire.py:45).
  • Registry race fixed: sequential UnixStreamServer, all locks removed - claim holds.
  • Broken-symlink socket cleanup and cache-eviction-on-overwrite: both correct.
  • replaceOpWithClonedAttrs (PTOViewToMemref.cpp:230) correctly preserves candidates/precision attrs across lowering (same op type in/out).
  • Pass order correct: InsertTemplateAttributes runs before FusionPlan; daemon started only for VPTO + has-tile-ops + PTODSL; both passes receive the same auto-started socket.

Comment thread tools/ptoas/ptoas.cpp
"Use the legacy TileLang DSL TileLib"),
clEnumValN(TileLibBackend::PTODSL, "ptodsl",
"Use the PTODSL TileLib daemon")),
llvm::cl::init(TileLibBackend::PTODSL));

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.

Blocker: this flips the default backend to PTODSL. The PR description says TileLang is kept as the default and lists making PTODSL default as out-of-scope, but this line (and Passes.td:545) default to ptodsl. Combined with the current A5 board failures (OK 209 / FAIL 17, real numeric miscompiles in sel/sels/cmp/cmps/rowexpand{sub,mul,div}/partmin/mgather/mscatter/rmsnorm/rope_kv_cache + segfaults), this defaults every A5 user onto a numerically-broken path while ninja check-pto stays green (lit tests are structural, not numeric). Suggest keeping tilelang as the default here and flipping in a follow-up once the board is green.

"Path to Unix domain socket for daemon RPC (if empty, uses subprocess)">
"Path to Unix domain socket for daemon RPC">,
Option<"tileLibBackend", "tile-lib-backend", "std::string",
/*default=*/"\"ptodsl\"",

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.

Pass-side default also flipped to ptodsl here (mirrors ptoas.cpp:419). Same concern as the CLI default: this makes PTODSL the default for --emit-vpto pipelines while the A5 board is red. Keep tilelang until the numeric failures are resolved.

return false;
}

processInfo = std::make_pair(procInfo.Pid, socketPath);

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.

processInfo is overwritten unconditionally with no isRunning() check, and generateSocketPath() (line 28) keys the socket only on ::getpid() (constant for the whole process). In a mixed-backend fatobj compile, runPTOASJobs (driver.cpp:1195) runs VPTO child jobs in a sequential in-process loop; each tile-op child calls start() again with the same socket path. The earlier daemon's pid is lost, so the exit-time stop() kills only the last one and the earlier python -m ...daemon process leaks. Suggest guarding on isRunning() (reuse the daemon) and/or a per-job unique socket path.

try:
if not predicate(**kwargs):
return False
except Exception:

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.

passes() swallows any exception from a constraint predicate as "not satisfied" (return False). A buggy predicate (typo, AttributeError, KeyError) therefore silently marks its candidate illegal rather than surfacing the error; if it is the only candidate, the op later fails with a confusing "InsertTemplateAttributes found no legal template candidates" far from the real cause. Consider letting unexpected exceptions propagate (or at least logging them) so template-authoring bugs are visible.

class _Handler(socketserver.BaseRequestHandler):
def handle(self):
try:
request = recv_message(self.request)

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.

The daemon is now a sequential UnixStreamServer with no timeout set on accepted connections, and recv_exactly blocks until it gets the full announced length. A client that sends the 4-byte prefix then fewer bytes and holds the socket open wedges the single serve thread forever; every subsequent real RPC then hangs until each C++ caller's 30s ExecuteAndWait times out, and the daemon never recovers (a regression from the old threaded model). Consider a per-handler socket timeout.

@zhangstevenunity zhangstevenunity merged commit a1371bc into hw-native-sys:main Jul 14, 2026
17 of 20 checks passed
@reedhecre

Copy link
Copy Markdown

A5 板测成功

  • 触发方式:merged
  • 源码提交:a1371bc7aab3
  • 结果汇总:OK 21 / FAIL 0 / SKIP 0
  • 日志:/root/ptoas-board-monitor-a5/logs/20260714_170408_merged_pr894.log
  • 结果 TSV:/root/ptoas-board-monitor-a5/logs/20260714_170408_merged_pr894.tsv

@reedhecre

Copy link
Copy Markdown

A3 板测完成(有跳过)

  • 触发方式:merged
  • 源码提交:a1371bc7aab3
  • 结果汇总:OK 221 / FAIL 0 / SKIP 2
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260714_020400_merged_pr894.log
  • 结果 TSV:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260714_020400_merged_pr894.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.

6 participants