AI4Finance-Foundation / AI4Finance-Foundation/RLSolver
🐛 contract in some orders on a circuit with ring struction may get incorrect multiplication counts.
- 主要言語
- Python
- スター
- 169
- フォーク
- 36
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
收缩 sycamore 以及 tensor grid ,tensor ring 这种有环状结构的电路,会有bug,导致乘法次数计算错误
(刚好我们测试的 tensor train,tensor tree 没有环状结构)
需要有环状结构,且按某个顺序收缩张量节点,才会触发
下面的代码,在一个小规模的 sycamore 电路 NodesSycamoreN12M14 上得到,然后逐行检查发现了这个bug
```
num_nodes 51
num_edges 99
ban_edges 0
```
先粗略记录一下。
这是print代码
```
'''calculate the multiple and avoid repeat'''
contract_dims = node_dims_arys[node_i0] + node_dims_arys[node_i1] # 计算收缩后的node 的邻接张量的维度 以及来源
contract_bool = node_bool_arys[node_i0] | node_bool_arys[node_i1] # 计算收缩后的node 由哪些原初node 合成
# assert contract_dims.shape == (num_nodes, )
# assert contract_bool.shape == (num_nodes, )
print(';;;', i, node_i0, node_i1)
print(node_dims_arys[node_i0].numpy().astype(int))
print(node_dims_arys[node_i1].numpy().astype(int))
print(contract_dims.numpy().astype(int))
print(contract_bool.numpy().astype(int))
```
这是print内容。可以看到,对已经收缩的节点竟然进行了不可能的收缩,并且产生了多余的乘法次数。
```
;;; 52 tensor(3) tensor(9)
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 352 0 0 0 0 96 0 0 0 128 0 0 0 0 320 0 128 0 0 0 64 0 64 64 0 0 0 0 192 0 64 64 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 352 0 0 0 0 96 0 0 0 128 0 0 0 0 320 0 128 0 0 0 64 0 64 64 0 0 0 0 192 0 64 64 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 704 0 0 0 0 192 0 0 0 256 0 0 0 0 640 0 256 0 0 0 128 0 128 128 0 0 0 0 384 0 128 128 0]
[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 0 1 0 0 1]
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Start with the contraction-counting code shown in the issue and reproduce it on the NodesSycamoreN12M14 circuit using the reported 51 nodes, 99 edges, and contraction-order conditions. Trace the node dimension and boolean arrays around the printed duplicate contraction. Done means cyclic circuits no longer contract an already-combined node or add duplicate multiplication counts.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100