acqdp
acqdp copied to clipboard
TensorNetwork.find_order() returns None when cost/cw is high
I executed examples/circuit_simulation.py
on the workstation machine (Ubuntu 20.04), with order_finder_name
in khp_params.json
set to default
.
The code spend more than 2 hours but halts with AttributeError. I found in line 97 to 102 in tensor_network.py
that ResourceWarning
should be raised when cost is too high. However, since res
is None, it does not have the cost
attribute. A temporary fix is to raise error or warning before the find_order
function returns None
, but it would be nice to investigate why line 92 res = next(get_order_finder(**kwargs).find_order(self))
returns None
. It would be great to raise warning before the software wastes too much time searching for contraction order if the result is probably None
.
python3 ../../../acqdp/examples/circuit_simulation.py ../../../benchmarks/simulation/bv/bv_1000.txt
{'order_finder_name': 'sliced', 'order_finder_params': {'base_order_finder': {'order_finder_name': 'default', 'order_finder_params': {'num_iters': 10, 'num_threads': 1, 'num_cmas': 1}}, 'slicer': {'slicer_name': 'default', 'slicer_params': {'num_iter_before': 30, 'num_iter_middle': 20, 'num_iter_after': 50, 'max_tw': 28, 'max_num_slice': 25, 'num_threads': 1}}}, 'compiler_params': {'do_patch': True}, 'contractor_params': {}}
Process 0 initial cost: cost = 264.93273759683797, cw = 874.0, num_slice = 0
Traceback (most recent call last):
File "/home/user/experiments/simulation/2022-04-11-Test1/../../../acqdp/examples/circuit_simulation.py", line 152, in <module>
print(order.cost)
AttributeError: 'NoneType' object has no attribute 'cost'
Hello ChienKaiMa,
Thank you very much for raising this issue. We will look into that and make corrections accordingly. In the meantime, could you provide a test script that reproduces this error? Thanks!
Cupjin
I have difficulties attaching files right here, so I forked the repository and committed the modified code and circuit files in use in https://github.com/ChienKaiMa/acqdp/commit/fce402e48d573372ff3105d6101132abc12030d2
Hello @ChienKaiMa ,
I have added a warning when the order finding returns None
. However I did not change the return type, since it being None
is used elsewhere.
Regarding your concern that it took too long for the process to halt, I have also slightly changed the code logic for slight improvement of performance. I would like to mention that there are cases where it is not clear if the tensor network is indeed intractable or not without a heavy pre-processing. In cases where such pre-processing is not needed, I suggest changing the slicer.slicer_params.num_iter_before
in khp_params.json
to a smaller number. This should help accelerate the pre-processing process.
Hope this helps.
Cupjin