Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TensorNetwork.find_order() returns None when cost/cw is high #24

Open
ChienKaiMa opened this issue Apr 15, 2022 · 3 comments
Open

TensorNetwork.find_order() returns None when cost/cw is high #24

ChienKaiMa opened this issue Apr 15, 2022 · 3 comments

Comments

@ChienKaiMa
Copy link

ChienKaiMa commented Apr 15, 2022

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'
@cupjinhuang
Copy link
Contributor

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

@ChienKaiMa
Copy link
Author

I have difficulties attaching files right here, so I forked the repository and committed the modified code and circuit files in use in ChienKaiMa@fce402e

cupjinhuang added a commit to cupjinhuang/acqdp that referenced this issue May 10, 2022
cupjinhuang added a commit to cupjinhuang/acqdp that referenced this issue May 10, 2022
@cupjinhuang
Copy link
Contributor

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

alibabaquantumlab pushed a commit that referenced this issue May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants