Skip to content

[Bug] SIMT 指令(MSCATTER/MGATHER)通过 SU dispatcher fn-pointer 路径调用时 chip hang #970

Description

@ChaoWao

Platform

a5 (Ascend 950 hardware)

Runtime Variant

tensormap_and_ringbuffer

Description

在 a5 平台 tensormap_and_ringbuffer 运行时上,如果一个 user incore kernel 在内部直接或间接使用任何 SIMT 类指令(pto::MSCATTER、pto::MGATHER 及其内部展开的 cce::async_invoke<...>),通过当前 SU dispatcher 模型(src/a5/runtime/tensormap_and_ringbuffer/aicore/aicore_executor.cpp)调用进入这个 kernel 之后,SIMT scheduler 无法在 AICore 上正确启动,表现为 chip 静默 hang(host 上 stream sync 不返回,task-submit 超时被 kill,无 errcode 抛出)。

PR #764(Fix: a5 AICore SIMT launch — set localMemorySize + inject SIMT TLVs)已经把 launch-registration 阶段的 cfg.localMemorySize = 216 KB + ELF .ascend.meta.<func> 的 5 条 SIMT TLV(COMPILER_ALLOC_UB_SIZE, SU_STACK_SIZE, SIMT_WARP_STACK_SIZE, SIMT_DVG_WARP_STACK_SIZE, AIV_TYPE_FLAG=MIX_VF)装好,runtime 不再抛 ACL_ERROR_RT_PARAM_INVALID (107000),launch 注册成功。但进入 user kernel body 执行到 MSCATTER 时仍然 hang。

根因:bisheng 把 dispatcher aicore_executor.cpp:42 处通过 payload->function_bin_addr 加载的 fn-pointer call lowering 成 HiIPUISD::LongCALL(4 字编码,目标地址通过 linker reloc 填入,decode 期不可解析),而 SIMT scheduler 的启动需要 decode 期能解析目标 PC 才能预热。短分支 HiIPUISD::CALL(3 字 + 立即数偏移)路径上,bisheng 自动发了一组 SIMT-aware setup 指令(0x0c.. + 0x1c.. 系列),LongCALL 路径不发。bisheng 也未把这组 setup 暴露成 user-callable builtin。

详细实验记录会在评论里补。

Steps to Reproduce

  1. checkout PR Add: a5 AICore SIMT (mscatter) launch support #764 (ChaoZheng109:fix-a5-aicore-simt-tlv),包含 tests/st/a5/tensormap_and_ringbuffer/simt_basic/
  2. 在 a5 实机上跑 simt_basic:
    task-submit --timeout 600 --max-time 600 --device auto --device-num 2 \
      --run "python -m pytest \
        tests/st/a5/tensormap_and_ringbuffer/simt_basic/test_simt_basic.py \
        --platform a5 --device \$TASK_DEVICE -v -s"
  3. 观察到:
    • Orchestration .so 编译 ✅ (583KB)
    • AIV kernel kernel_simt_scatter.o 编译 ✅ (197KB,含 SIMT TLV)
    • 12 个 CANN runtime 线程 spawn(说明 runtime 已 init,chip handle 已开)
    • 接下来在 chip 上0 输出持续 600s,task-submit 超时 kill

Expected Behavior

simt_basic 用例应在硬件上完成 8x32→256 elements 的 MSCATTER,golden 比对 PASS,跟 pto-isa 自家 tests/npu/a5/src/st/testcase/mscatter 在同硬件上的 5332ms PASS 形态一致。

具体:

  • AIV 三个 block(block_dim=3)各自的 MSCATTER 应该把 8x32=256 float 元素按 identity 索引散写到 256-slot dst,使 out == src
  • max diff = 0,err count = 0
  • 任务在 ~10 秒内完成,不应该出现长时间静默

Actual Behavior

[npu-lock] 获取设备 0 的锁 (无超时)...
[npu-lock] 已获取设备 0 的锁 (pid=...)
[npu-lock] 获取设备 1 的锁 (无超时)...
[npu-lock] 已获取设备 1 的锁 (pid=...)
============================= test session starts ==============================
platform linux -- Python 3.10.20, pytest-9.0.3, pluggy-1.6.0
collected 1 item

tests/st/a5/tensormap_and_ringbuffer/simt_basic/test_simt_basic.py::TestSimtBasic::test_run
  [V5] [Orchestration] Compilation .../simt_basic_orch.cpp.orch_*.so successful: 583600 bytes
  [V5] [Incore] Compilation .../kernel_simt_scatter.cpp.incore_*.o successful: 197840 bytes
  ───── 之后整整 600s 零输出 ─────
错误: 等待超时 (600s)

对照参考:

Test 路径 结果
simpler simt_basic(本 issue 现象) SU dispatcher → fn-pointer → user kernel → MSCATTER ❌ 600s hang
pto-isa tests/npu/a5/.../mscatter(我用同一台 a5 硬件验证) host <<<1, nullptr, stream>>> → kernel(里头 MSCATTER) ✅ 5332ms PASS

两者跑的是同一段 MSCATTER 内核代码,唯一差别是 launch + dispatch 路径。

Git Commit ID

86b633c

CANN Version

9.1.T500 (V100R001C10B813)

Driver Version

25.6.rc1.b108 (ascendhal 7.35.23)

Host Platform

Linux (aarch64)

Additional Context

  • Related PR: Add: a5 AICore SIMT (mscatter) launch support #764(引入 simt_basic 测试 + 给 dispatcher 注入 SIMT TLV)
  • 上游参考:pto-isa tests/npu/a5/src/st/testcase/mgather/MGATHER.md §"Runtime Dispatch Requirement"(line 377-403)已经把这条限制写明:cce::async_invoke 需要 launch path 在 kernel 进入前装好 TID/warp/vec-pipe scheduler 状态,标准 rtKernelLaunch 这么做了,fn-pointer 直接调用 skips 这一步,所以第一条 async_invoke 起不来 warp 调度
  • pto-isa 给出三条 fix 路径(MGATHER.md line 400-402):全部需要 simpler dispatcher 侧改造
  • 我们做了一整套定位实验(byte-level disasm 对比、bisheng intrinsic 全扫、host-side builtin 注入、SDAG 节点分析),会在下面评论里补全

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions