fix(TileOps): correct nd2nz/dn2nz src_inner_stride to use src physical stride in bytes.#924
fix(TileOps): correct nd2nz/dn2nz src_inner_stride to use src physical stride in bytes.#924TelGome wants to merge 3 commits into
Conversation
…l stride in bytes
Codex Review该评论由 review 机器人自动更新。
SummaryReview failed at stage Findings未生成结构化 findings,因为 review 过程提前失败。 Log Tail |
There was a problem hiding this comment.
Code Review
This pull request updates lib/TileOps/tload_template.py to use static dst.shape instead of dynamic dst.valid_shape in constraints, and scales the inner stride by the element byte width using the physical strides of the source tensor. The review feedback points out a potential crash where non-5D tensors can bypass the constraints and cause a ValueError during unpacking in the templates, recommending that src.rank == 5 be strictly enforced. Additionally, it suggests simplifying the unpacking of unused shape and stride variables by directly indexing the required strides.
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.
Zhendong404
left a comment
There was a problem hiding this comment.
后面需要切到PTODSL,等PR #894 合入再合吧,免得迁移漏掉了
好的 |
…nd GM physical stride
Summary
修复 issue #903 在 vpto 后端暴露的 TileOps stride / 约束缺陷,共三处改动,均在
lib/TileOps/:tloadnd2nz/dn2nzsrc_inner_stride改为源物理 stride × 字节宽(tload_template.py)src_inner_stride = k/m(dst 列/行数,元素单位)src_inner_stride = s3 * elem_bytes(ND)/s4 * elem_bytes(DN),与ND2ND模板写法对齐a5/TLoad.hpp的loop1_src_stride = GetByteSize<DType>(gStride)为字节单位dst.shape替代动态dst.valid_shape做模板消歧,避免valid_shape为[null, null]时 ND2NZ/DN2NZ 同时匹配tstoreacc2gmsrc_stride/dst_stride改用 tile 行数与 GM 物理 stride(tstore_template.py)src_stride = dst_stride = n(tile 列数)src_stride = src.shape[0](=TileData::Rows,L0C acc NZ 行 stride),dst_stride = s3(ND)/s4(DN)(GM 物理行 stride)a5/TStore.hpp的TStoreAccND把srcStride/dstD透传给copy_matrix_cc_to_gm,不乘GetByteSize,硬件内部按 dtype 转字节)nz2nd/nz2dn/nz2nz(仅 src)/fp_acc_to_gm四个模板tload 约束严格拒绝非 rank-5 源(
tload_template.py,回应 gemini code review)if hasattr(src, 'rank') and src.rank == 5:非 5D 时跳过 shape 检查并返回True,导致非 5D 张量匹配约束后在模板g0..g4 = src.shape处抛ValueErrorif not (hasattr(src, 'rank') and src.rank == 5): return False,在约束阶段即拒绝Repro
qwen3_decode_incore_2.pto第一条pto.tload(16×128 bf16,mat)生成的MOV_OUT_TO_L1_MULTI_ND2NZ指令被发射但永不 retire,紧跟BAR永久等待,整机死锁;真机报errcode 168 / L0C out of rangesrc_inner_stride = k(元素单位 + dst 列数),硬件按错误步进读 GM(应 16384 B/行,实按 128 B)Validation
cmake --build build --target check-pto:785 lit 用例全过cube_tile_ops_positive.pto(src 无显式 layout)未回归nd2nz正常 retire;tstore IR configdstD=1024/srcStride=16与 emitc 字段一致;cube pipeline 从第一条 tload 死锁推进到 matmul/sync 阶段