Closed
[Bug-Report|缺陷反馈]: 新前端pypto.forntend.jit不支持torchTensor转成ptoTensor时Format(NZ)属性的带入 #189
zyt123Add on  Jan 23Closed at  Mar 17
zyt123
zyt123Collaborators
Jan 23 Create

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

新前端torchTensor转成ptoTensor时没有支持Format(NZ)属性,torchTensor是NZ格式,但是进入jit后转成ptoTensor后,格式还是ND;导致适配新前端后NZ场景出现精度报错。(适配前的老写法,NZ场景精度ok)

Environment / 环境信息 (Mandatory / 必填)

NPU: 910B
CANN : 8.5.0

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

前端老写法精度ok脚本:
55859784500c4b5283c8f2a5e278b7f0.zip

新前端写法精度Fail脚本:

15003ae6a52d41718efeadb406b64698.zip

Describe the expected behavior / 预期结果 (Mandatory / 必填)

新前端NZ场景 精度OK。

===================== NZ
Traceback (most recent call last):
File "/home/z00521416/open/122/pypto/examples/models/glm_v4_5/glm_attention_pre_quant.py", line 506, in
main()
File "/home/z00521416/open/122/pypto/examples/models/glm_v4_5/glm_attention_pre_quant.py", line 502, in main
test_quant_attention_pre()
File "/home/z00521416/open/122/pypto/examples/models/glm_v4_5/glm_attention_pre_quant.py", line 492, in test_quant_attention_pre
assert_allclose(np.array(q_r.cpu().flatten().tolist()), np.array(q.cpu().flatten().tolist()),
File "/usr/local/python3.11.10/lib/python3.11/site-packages/numpy/testing/_private/utils.py", line 1504, in assert_allclose
assert_array_compare(compare, actual, desired, err_msg=str(err_msg),
File "/usr/local/python3.11.10/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.10/lib/python3.11/site-packages/numpy/testing/_private/utils.py", line 797, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=0.0078125, atol=0.0001

Mismatched elements: 11834 / 12288 (96.3%)
Max absolute difference: 6.6171875
Max relative difference: 20530.34939759
x: array([ 0.400391, -0.004913, -0.211914, ..., 0.020264, 0.910156,
0.558594])
y: array([-0.173828, 0.007812, -0.163086, ..., 0.155273, 1.015625,
-0.176758])
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/python3.11.10/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/npu/s00835526/Ascend_20260116/cann-8.5.0/python/site-packages/tbe/common/repository_manager/utils/multiprocess_util.py", line 68, in run
item = self.task_q.get()
^^^^^^^^^^^^^^^^^
File "", line 2, in get
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/managers.py", line 822, in _callmethod
kind, result = conn.recv()
^^^^^^^^^^^
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/connection.py", line 250, in recv
buf = self._recv_bytes()
^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/connection.py", line 430, in _recv_bytes
buf = self._recv(4)
^^^^^^^^^^^^^
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/connection.py", line 399, in _recv
raise EOFError
EOFError
[ERROR] 2026-01-23-11:16:13 (PID:315578, Device:2, RankID:-1) ERR99999 UNKNOWN applicaiton exception
Traceback (most recent call last):
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/managers.py", line 814, in _callmethod
conn = self._tls.connection
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ForkAwareLocal' object has no attribute 'connection'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/util.py", line 303, in _run_finalizers
finalizer()
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/util.py", line 227, in call
res = self._callback(*self._args, **self._kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/npu/s00835526/Ascend_20260116/cann-8.5.0/python/site-packages/tbe/common/repository_manager/route.py", line 54, in wrapper
return func(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/npu/s00835526/Ascend_20260116/cann-8.5.0/python/site-packages/tbe/common/repository_manager/route.py", line 208, in finalize
cls.cann_kb_mgr.finalize()
File "/npu/s00835526/Ascend_20260116/cann-8.5.0/python/site-packages/tbe/common/repository_manager/cann_kb_manager/knowledge_bank_manager.py", line 42, in finalize
self.__static_mgr.close()
File "/npu/s00835526/Ascend_20260116/cann-8.5.0/python/site-packages/tbe/common/repository_manager/cann_kb_manager/base_manager.py", line 342, in close
for name in copy.deepcopy(self.write_kb.keys()):
^^^^^^^^^^^^^^^^^^^^
File "", line 2, in keys
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/managers.py", line 818, in _callmethod
self._connect()
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/managers.py", line 805, in _connect
conn = self._Client(self._token.address, authkey=self._authkey)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/connection.py", line 519, in Client
c = SocketClient(address)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.10/lib/python3.11/multiprocessing/connection.py", line 647, in SocketClient
s.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused

Special notes for this issue/备注 (Optional / 选填)

likedislike
Jie YinJie YinCollaborators
Jan 24 Assign jiawei_zhuang as responsible person
Jie Yin
Jie YinCollaborators
Jan 24 Comments:

@jiawei_zhuang 看一下这个新前端的问题

likedislike
LiuChang
LiuChangCollaborators
Jan 24 Comments:

已定位,修改中

likedislike
杨旭杨旭Collaborators
Jan 26 associated Kanban: PyPTO
杨旭杨旭Collaborators
Jan 26 Added label: Frontend
杨旭杨旭Collaborators
Mar 13 changed custom category from 任务 to 缺陷
jiawei_zhuangjiawei_zhuangCollaborators
Mar 17 Assign seu_chang as responsible person
LiuChang
LiuChangCollaborators
Mar 17 Comments:

相关问题已经在https://gitcode.com/cann/pypto/issues/669 的关联PR中修复,用户当前不需要在kernel入参显示写format。如有疑问,欢迎再次讨论

likedislike
LiuChangLiuChangCollaborators
Mar 17 changed custom state from 待办的 to 已完成
LiuChangLiuChangCollaborators
Mar 17 Close issue
Inspiron_st
Inspiron_st
Apr 2 Comments:

应该打上resolved标签

likedislike