Repository navigation
[Bug][PTODSL/VPTO] [阻塞]合并多个 Vector Kernel 时 init_core 生成重复符号并导致 fatobj 链接失败 #1582
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Activity
- changed the title
[-][Bug][PTODSL/VPTO] Multiple vector kernels with init_core fail fatobj link due to duplicate symbol[/-][+][Bug][PTODSL/VPTO] [阻塞]合并多个 Vector Kernel 时 init_core 生成重复符号并导致 fatobj 链接失败[/+]on Sep 24, 2026 已确认这是 PTODSL/PTOAS 的符号可见性问题,修复已提交:
merge_jit_modules()会保留独立的 backend child module,并分别生成 fatobj。此前普通@pto.funchelper(包括init_core)保持外部可见;当两个 kernel 产生同名 specialization 时,两个 fatobj 都导出相同全局符号,最终链接报duplicate symbol: init_core...。MR 将 child module 中的普通 helper 标记为 private;真正的 kernel primary function 仍通过独立路径保持 public/external,并新增了合并两个 vector kernel 的回归测试。
验证结果:
test_stdlib_init_core.py通过;test_jit_compile.py全量通过;- CANN 9.2 对照验证:修复前稳定复现 duplicate symbol,修复后相同输入成功生成 fatobj。
- added a commit that references this issue
on Sep 30, 2026 使用930weekly版本问题还在:
ptoas --pto-arch=a5 --pto-backend=vpto merged.pto -o merged.fatobj.o Warning: PTO_ISA_PATH/PTO_ISA_ROOT is not set; C++ device object emission may fail to include pto/pto-inst.hpp. Warning: Bisheng scheduler auto: SIMD VF stack report unavailable; keeping on, so auto behaves like --bisheng-vec-misched=on and no stack size is compared. Check that this Bisheng toolchain can emit SIMD VF stack reports with -mllvm --cce-res-usage. PTOAS: VF_SIMT size verification passed; no patch required Warning: Bisheng scheduler auto: SIMD VF stack report unavailable; keeping on, so auto behaves like --bisheng-vec-misched=on and no stack size is compared. Check that this Bisheng toolchain can emit SIMD VF stack reports with -mllvm --cce-res-usage. PTOAS: VF_SIMT size verification passed; no patch required Error: fatobj link failed Command: /data/caojian/env/CANN260930/cann-9.3.0/bin/bisheng --cce-fatobj-link --cce-aicore-arch=dav-c310 -r -o merged.fatobj.o /data/caojian/tmp/ptoas-vpto-fatobj-b8300e..o /data/caojian/tmp/ptoas-vpto-fatobj-f7f50e..o ld.lld: error: duplicate symbol: init_core__ptodsl_cccb7eefe6.vector >>> defined at ptoas.hivm.official.vector >>> /data/caojian/tmp/ptoas-vpto-fatobj-b8300e..o-be2d4b.extract:(init_core__ptodsl_cccb7eefe6.vector) >>> defined at ptoas.hivm.official.vector >>> /data/caojian/tmp/ptoas-vpto-fatobj-f7f50e..o-6449fc.extract:(.text+0x98) cceld: ccec ReturnCode: 1 cceld: ExecutionFailed: 0 cceld: ErrMsg: bisheng: error: linker command failed with exit code 1 (use -v to see invocation)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
问题概述
在 PTOAS 0.65 中,将两个包含
pto.init_core()的 VPTO vector kernel 通过pto.merge_jit_modules()合并后,PTOAS 在生成 fatobj 时链接失败:两个 kernel 单独编译均成功;只有多 kernel 合并场景失败。
环境
9.3.00.653.11a5vptodav-c310最小复现
执行:
实际结果:
TileLang 复现
测试程序包含两个独立的
T.Kernel/T.SimtVF区域,分别执行向量加法和向量缩放。TileLang 生成的两个 PTODSL kernel 都包含:测试在 PTO fatobj link 阶段失败。
分析结果
合并后的 PTO IR 中出现两份同名 helper:
两个 entry 都调用该符号:
两个 helper 的函数体相同,负责配置 control register、UB/OUT loop size 和 store atomic configuration。
但
merge_jit_modules()保留了两个定义,PTOAS 随后将它们转换为同名全局符号:最终 fatobj link 阶段报 duplicate symbol。
已完成的对照实验
两个 kernel 分别编译
分别执行:
结果均成功:
去掉
pto.init_core()去掉两个 kernel 中的
pto.init_core()后:merge_jit_modules()生成的 PTO 可以成功编译;因此问题与多 kernel host launch、参数 ABI 或 SIMT lowering 无关,触发条件是多个 kernel 同时包含
pto.init_core()。期望行为
以下任一方案都可以解决问题:
merge_jit_modules()对完全相同的 helper 自动去重;临时规避
不能简单删除
pto.init_core()作为通用 workaround,因为该函数负责硬件控制寄存器和存储配置,在复杂 kernel 中删除可能导致错误行为。当前只能避免合并多个包含
pto.init_core()的 vector kernel,或使用包含相关修复的 PTOAS/PTODSL 版本。请确认该问题应由 PTODSL module merge、PTOAS lowering,还是 fatobj linker 侧修复。