[Docs]: update broadcast docstring, add dtype coverage tests and API doc - #1595
Conversation
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
| 4. 1D src 广播到 2D dst 时,自动推断广播轴;无法推断时抛出 `ValueError` | ||
| 5. 不支持 src 与 dst 地址重叠(硬件约束) | ||
| 6. 仅支持 ND 格式(硬件约束) | ||
| 7. dim=2 且 axis=0 时,srcShape[1] 必须 32 字节对齐(即元素个数 × 元素大小 ≥ 32 字节)(硬件约束) |
There was a problem hiding this comment.
"srcShape[1]必须 32 字节对齐(即元素个数 × 元素大小 ≥ 32 字节)(硬件约束)",实测结论:真正约束是 N×size 必须为 32 字节的整数倍,而非"≥ 32 字节",括号应改为"即 元素个数 × 元素大小 % 32 == 0"。另外建议顺带注明非对齐时是静默出错而非报错。
3cead4a to
6754cce
Compare
|
|
||
| ## 3. 示例代码 | ||
|
|
||
| **示例 1:1D src 广播到 2D dst(axis 自动推断)** |
There was a problem hiding this comment.
示例命中已知不支持路径标题称这是1D-2D,但src的(4,1)实际是二维;axis=None会推断为axis=1,且M=4正好命中本页已注明AscendC/PTO均不支持、可能静默算错的路径。请改成真正受支持的例子,例如src=(16,)、dst=(4,16),让其自动推断axis=0。
There was a problem hiding this comment.
已修复。示例 1 从 src=(4,1) 改为 src=(16,),axis=None 推断为 axis=0(受支持路径),不再命中 2D axis=1 M≥2 的已知限制。
| import tilelang.language as T | ||
| import torch | ||
|
|
||
| tilelang.disable_cache() |
There was a problem hiding this comment.
不要在模块导入时关闭全局缓存
disable_cache() 修改进程级 CacheState,这里在 collection/import 阶段执行且从不恢复。CI 使用 pytest-xdist + --forked,worker 收集模块后产生测试子进程,因此其他测试也会继承禁用状态,造成全量 CI 编译时间回归并掩盖缓存相关行为。请删除该调用,或移入保存并恢复原状态的 fixture。
There was a problem hiding this comment.
已修复。tilelang.disable_cache() 已改为 @pytest.fixture(scope="module", autouse=True) + yield + tilelang.enable_cache() 恢复。
6754cce to
9295e1d
Compare
9295e1d to
c36173b
Compare
|
/re-test |
|
🔄 Re-running failed jobs Original workflow run: View details Only the failed jobs will be re-executed. |
|
/re-test |
|
🔄 Re-running failed jobs Original workflow run: View details Only the failed jobs will be re-executed. |
改动内容
针对
T.tile.broadcastAPI 完成文档校验、测试用例补充和 docstring 更新。1. Docstring 更新(修改)
tilelang/language/ascend_tile.py中broadcast函数的 docstring2. 测试用例(新增)
testing/python/language/test_tilelang_ascend_language_tile_broadcast_dtype_coverage.pytest_tilelang_ascend_language_explicit_tmp.py和test_tilelang_ascend_language_elementwise.py中已有的测试(float32×ascendc explicit tmp runtime、codegen only 测试)test_broadcast_2d_axis0test_broadcast_1d_to_2d_auto_infertest_broadcast_1d_axis0_ascendctest_broadcast_dtype_mismatch_raisestest_broadcast_shape_mismatch_axis0_raisestest_broadcast_shape_mismatch_axis1_raisestest_broadcast_invalid_axis_raisestest_broadcast_1d_uninferable_raisesLP 标记策略:
low_prioritylow_priority3. API 文档(新增)
docs/api_docs/T.tile.broadcast.md测试结果
校验发现
真机测试发现 dtype 支持范围超出校验文档:校验文档原版仅列 int8/uint8/float16/float32(4 个),真机三重验证(编译+运行+精度)确认 int16/uint16/bfloat16/int32/uint32 在 ascendc + pto 后端均实际支持。CANN
BroadcastImpl的static_assert(SupportBytes<T, 1, 2, 4, 8>())按sizeof(T)分派,9 个 dtype 均在范围内。已补充至文档。已知限制(文档 Shape 支持已标注)
详细根因分析记录在
api/bug_investigation/broadcast_bug.md,包含修复尝试记录。文件改动
tilelang/language/ascend_tile.pytesting/python/language/test_tilelang_ascend_language_tile_broadcast_dtype_coverage.pydocs/api_docs/T.tile.broadcast.md