Closed
[Requirement|需求建议]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败优化 #3426
gggxinmengAdd on Sep 22Closed at Sep 24
Sep 22 Assign gggxinmeng as responsible person
Sep 22 Added label: Passes
Sep 23 changed custom category from 缺陷 to 需求
Sep 23 Change title to "# [Bug-Report|缺陷反馈]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败优化", originally titled "# [Bug-Report|缺陷反馈]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败(F4FFFF)".
Sep 23 Change title to "# [Bug-Report|缺陷反馈]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败优化", originally titled "# [Bug-Report|缺陷反馈]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败(F4FFFF)".
Sep 23 Change title to "[Requirement|需求建议]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败优化", originally titled "# [Bug-Report|缺陷反馈]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败优化".
Sep 23 Change title to "[Requirement|需求建议]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败优化", originally titled "# [Bug-Report|缺陷反馈]: RealignAllocByIso 在 DualDst 融合无对时盲目镜像重排,ALLOC 提前且集中物化导致 UB 峰值 spill 失败优化".
Sep 23 Modify description of issue
KaiqiJin
Sep 23 Comments:
Sep 23 Comments:
请10月跟踪闭环


Sep 24 changed custom state from 待办的 to 已解决
Sep 24 Close issue
Sep 24 Added label: resolved
Describe the current behavior / 问题描述 (Mandatory / 必填)
flash_attention_mha_automix.jsoncase 11(pypto_flash_attention_mha_id0011_bf16_b1_n24_d128_actseqlistmix,-t=user)在 9.2.0 基线9c6ef6d8d上编译失败:F4FFFF! InternalError::PASS_INNER_ERROR. [OoOSchedule.Operation]:Spill all buffer failed! [FuncMagic:47][OpMagic:12284](spill 回载 UB_ALLOC[12284] 需 64KB,第二轮 spill all 候选全为空壳,无 buffer 可腾)。根因:
RealignAllocByIso将 AIV1 侧同构算子按 AIV0 顺序镜像重排,目的是保证 DualDst 融合后两核的下发序(内存申请/释放顺序)一致。但同构判定只校验 AIV task 的结构镜像(opcode/shape/签名)。而两核 ALLOC 的执行位置由它消费的数据决定——数据由哪个 AIC task 生产,ALLOC 就排在那个 AIC task 附近。AIC 是单核,一次只跑一个 task,调度时只看依赖和空闲,不存在也不需要"两核同构"的概念:AIV0 依赖的 AIC task 可能排在时间轴前段,AIV1 依赖的排在后段。因此两核的同构配对在各自序列中的位置天然不一致——这不是排序错误,是单核 AIC 调度顺序的必然结果。当两核的前序 AIC task 完全不相交(L0C 输出仅到单 AIV 核)时:
以 flash_attention case11 为例:task18 与 task0 结构同构,但前序 AIC 分别为 {22,24,26,28,30}@7739-13163 和 {3,5,7,9,11}@11931-15783,完全不相交(L0C 输出均仅到单 AIV 核,ALLOC 位置由 AIC task 排序决定)。序号镜像把 UB_ALLOC[12182] 从全局 602 拉到 421、UB_ALLOC[12183] 从 944 拉到 422,与 11823/11822 挤成连续四段 ALLOC——AIV0 基准中不存在这种结构(其 12181 与下一个 UB_ALLOC 相隔 66 个全局位)。两块 80KB buffer 在远离消费者的位置提前且相邻物化,正值 UB 峰值,spill 回载所需 64KB 无法分配,编译以 F4FFFF 失败。
Environment / 环境信息 (Mandatory / 必填)
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
source CANN/set_env.sh+export PTO_TILE_LIB_CODE_PATH=<pto-isa>cd PyPTO_Test python3 xrunfk.py -i=./test_cases/experimental/flash_attention_mha_automix.json \ -o=./output/08_flash_attention_mha_automix_user_CURRENT_DATETIME \ -s=11 -e=11 -d=0 -t=user \ -r=./output/08_flash_attention_mha_automix_user_CURRENT_DATETIME.xlsxSpill all buffer failed! [FuncMagic:47][OpMagic:12284]Describe the expected behavior / 预期结果 (Mandatory / 必填)
test_flash_attention_mha.py7 用例 ALL PASSED、261 对融合成功、reordered=1 且零搬动,已验证)Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
1) 配对错位全景(同构判定建立 247 对,240 对核内序差 ≤2,仅 2 对严重错位即问题对):
12182/12183 的消费者链(SUB[10363]/SUB[10359] ← MULS[10229]/[10226] ← L0C_COPY_UB[10228]/VIEW[10225] 等)一个都不在同构配对集合中——置换只搬 ALLOC、消费者留在原地。
2) 配对 task 的前序 AIC 完全不相交(task 图数据):
其余 6 对 AIV task(纯 AIV 链、无直接 AIC 前驱)核内序差 ≤2,未受影响。
3) 置换制造了 AIV0 基准中不存在的结构:
4) 死锁时间线(重排后 SeqSchedule):24.878 Allocate Tensor4303 → 24.879 Allocate Tensor4304 → 24.882 Allocate Tensor3298 + Launch UB_ALLOC[12284](spill 回载, 需 64K) → 池满 → 第二轮 spill all 候选 [4303,4304,3298] 全为 ALLOC 产出空壳(无数据可搬)→ F4FFFF。
日志文件(含 P1/P2/P3 pair 打印与 task schedule 汇总):
/data/g00946962/PyPTO_Test/921_2012.log;完整分析数据:pair 对照表/data/g00946962/debug_logs/pair_table.txt、36 task 甘特图(依赖+startTime)/data/g00946962/debug_logs/task_graph.html。Special notes for this issue/备注 (Optional / 选填)
修复建议:将
RealignAllocByIso移入RunDualDstFuse,仅当 identify 确认存在真实融合对(两核确实分食同一 L0C 输出)时才执行重排,并在改序后就地刷新 execOrder;fuse 无对时保持初始排序不动。identify 的pairs.empty()结果本身就是两核数据流错拍的信号,可直接作为 Realign 的前置条件,无需显式识别 AIC 调度。该修复已在双场景验证:case 11 F4FFFF→PASS(精度三项全过);pypto-gymtest_flash_attention_mha.pyALL PASSED(正常 DualDst 场景 261 对融合、Realign 零扰动)。残留边界(可作后续优化):部分共享场景(identify 找到对但两核仅部分 AIC 前驱相交)下,非共享部分的 iso 配对仍可能被序号镜像搬动;实测正常 DualDst 场景两核顺序天然镜像(moved=0),风险较低。若需根治,可在
CheckAndRecordDualDstPair中增加前序 AIC task 闭包相交校验(配对 AIV task 的可达 AIC 祖先集合必须相交,不相交判不同构)。