已关闭
test: track IsInf MaskedFill E2E compile-only validation #160
Jett_Woo创建于 7月4日关闭于 7月7日
Jett_Woo
7月6日 评论:
7月6日 评论:
最新 NPU 设备验证结果(2026-07-06)
已基于当前最新本地代码重新编译并执行设备验证。
1. 重新编译
环境:
source /home/developer/Ascend/master/cann-9.1.0/set_env.sh
编译命令:
cmake --build build --target pyautofuse test_main -j 8
结果:
[100%] Built target pyautofuse
[100%] Built target test_main
设备信息:
NPU 7, 910B3, Health OK
No running processes found in NPU 7
2. PyTorch + Autofuse NPU 示例验证
执行命令:
ASCEND_DEVICE_ID=0 python3 autofuse/examples/af_pointwise/af_isinf_maskedfill_ge.py
结果:
Shape: torch.Size([128, 50])
Max diff: 0.0
Mismatch count: 0 / 6400
Inf position checks:
x[0,0] was +inf, result: -10000.0, expected: -10000.0
x[1,1] was -inf, result: -10000.0, expected: -10000.0
x[10,10] was +inf, result: -10000.0, expected: -10000.0
x[20,20] was -inf, result: -10000.0, expected: -10000.0
x[5,5] was masked, result: -10000.0, expected: -10000.0
x[3,3] was normal, result: -0.23828125, expected: -0.23828125
PASSED: All results match!
结论:PyTorch/Autofuse 端到端 NPU 执行结果与 golden 完全一致。
3. ASCIR Tool NPU ST 验证
执行命令:
source /home/developer/Ascend/master/cann-9.1.0/set_env.sh
export ASCEND_CUSTOM_PATH=/home/developer/Ascend/master/cann-9.1.0
export ASCEND_DEVICE_ID=0
export PYTHONPATH=/tmp/opencode/local_autofuse_cannpkg/python/site-packages:/mnt/workspace/gitCode/Jett_Woo/graph-autofusion/build/autofuse/tests:$PYTHONPATH
export LD_LIBRARY_PATH=/mnt/workspace/gitCode/Jett_Woo/graph-autofusion/build/autofuse/graph_metadef/graph/ascendc_ir/generator:/mnt/workspace/gitCode/Jett_Woo/graph-autofusion/build/autofuse/graph_metadef/graph:/mnt/workspace/gitCode/Jett_Woo/graph-autofusion/build/autofuse/graph_metadef/graph/expression:/mnt/workspace/gitCode/Jett_Woo/graph-autofusion/build/autofuse/graph_metadef/graph/ascendc_ir:/mnt/workspace/gitCode/Jett_Woo/graph-autofusion/build/autofuse/ascir/meta:/mnt/workspace/gitCode/Jett_Woo/graph-autofusion/build/autofuse/ascir/generator:/home/developer/Ascend/master/cann-9.1.0/lib64:/usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:$LD_LIBRARY_PATH
bash test_ascir.sh --mode=0 --case=isinf_maskedfill_fusion
结果关键输出:
################# end to launch kernel.
#################TEST RESULT#####################
output result: [-1.000e+04 -3.933e-01 1.964e-01 ... 6.255e-01 -7.783e-01 9.326e-01]
golden result: [-1.000e+04 -3.933e-01 1.964e-01 ... 6.255e-01 -7.783e-01 9.326e-01]
error ratio: 0.0000, tolrence: 0.0000
testcase: isinf_maskedfill_fusion , Result: PASS
结论:ASCIR 构图、codegen、device kernel 编译、NPU launch 和 golden 比对链路通过。
4. 环境注意事项
torch_npu示例不能在 source CANN 9.1 后直接运行;当前 Python NPU 栈会优先加载/home/developer/Ascend/master/cann-9.1.0/lib64/libhccl.so,出现 HCCL 符号不匹配。未注入 9.1 runtime 库路径时,torch 2.7.1+cpu/torch_npu 2.7.1.post2.dev20251226可正常执行 NPU 示例。- ASCIR Tool ST 不依赖
torch_npu,显式 source CANN 9.1 后运行通过。 - 验证结束后
npu-smi info显示设备无残留进程。
5. 总结
本次最新设备验证证明:IsInf + LogicalOr + MaskedFill 场景在 910B3 NPU 上执行正确,输出与 golden 完全一致;同时 ASCIR/codegen/kernel launch 链路也已通过设备侧 ST。


7月7日 添加了label:resolved
问题背景
在将
isinf_maskedfill_test_e2e纳入 backend E2E 执行列表时,发现IsInf + MaskedFill场景存在两类需要区分的问题:IsInfExtend<float>如果直接走DoIsInf<int>并调用AscendC::Abs<int>,DAV C220 头文件会报vabs(int*, ...)无匹配函数,属于编译期兼容问题。ReinterpretCast<float>()/ReinterpretCast<half>()调用Abs可以覆盖编译问题,但 CPU simulator 对该ReinterpretCastaliasing 路径模拟不准确,导致仿真执行阶段不适合作为正确性验证。原因分析
IsInf的计算流程会先将浮点输入按位处理成整型中间 buffer,再执行符号位清理和差值判断。CANN 9.1.0 在 910B/DAV C220 上没有Abs<int32_t>对应的vabs(int*)重载,因此中间 buffer 不能直接以int32_t调用AscendC::Abs。当前修复采用与
isfinite.h类似的方式:对整型中间 buffer 使用ReinterpretCast<float>()或ReinterpretCast<half>()后调用Abs,从而避免Abs<int32_t>编译错误。真实设备路径验证正常,但 CPU simulator 对该 reinterpret aliasing 行为存在已知限制。处理方案
IsInf对DT_FLOAT16和DT_FLOAT的注册,避免收窄 FP32 支持。isinf_maskedfill_test_e2e加入 backend E2E 执行列表,作为生成 kernel 的 compile-only 覆盖。GTEST_SKIP(),不作为正确性验证。测试验证
编译验证
环境:隔离安装的 CANN 9.1.0 + 910B ops 包。
命令:
source /tmp/opencode/cann-9.1.0-latest/install/cann/set_env.sh cmake --build build --target isinf_maskedfill_test_e2e -j 8结果:
说明:中间出现
libgcov profiling error ... overwriting an existing profile data with a different timestamp,属于覆盖率.gcda时间戳噪声,不是编译失败。真实设备正确性验证
环境:910B3 真实设备。
验证场景:PyTorch + Autofuse 的
IsInf + LogicalOr + MaskedFill。结果:
关联 PR