alibaba / acqdp Goto Github PK
View Code? Open in Web Editor NEWAlibaba Cloud - Quantum Development Platform
License: MIT License
Alibaba Cloud - Quantum Development Platform
License: MIT License
When package is installed in normal mode (without editable -e option), the cut_kKaHyPar_sea20.ini
file is missing in the installation location:
$ python examples/circuit_simulation.py benchmark/circuit_n53_m10_s0_e0_pABCDCDAB.qsim
(3_w,7)-aCMA-ES (mu_w=2.3,w_1=58%) in dimension 3 (seed=519671471, Thu Dec 24 23:55:13 2020)
Could not load context file at: /home/dmitry/acqdp/venv/lib/python3.8/site-packages/acqdp-0.1.1-py3.8.egg/acqdp/tensor_network/kahypar_profiles/cut_kKaHyPar_sea20.ini
I guess, the reason is the file is not in the data section of the setup.py
.
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'
There are two classes (Measurement
and PureMeas
) in circuit.py
. Since this simulator is based on tensor-network and density matrix, the effect of a measurement can be represented as a density-matrix update. To my understanding, this is the method acqdp adopts.
In some cases, we are only interested in the state vector update, where a measurement collapses the state vector and returns a single bit representing the measurement result. How could we do this in acqdp?
Thanks!
Hi,
acqdp is a great software, thanks for building it and make it public.
I'm wondering if there is anyway to visualize the tensor graph and contraction tree.
Thanks a lot.
I executed examples/circuit_simulation.py
on my laptop (WSL: Ubuntu 18.04) and the workstation machine (Ubuntu 20.04). The code worked on my laptop, but the program prints Invalid Object Identifier
and deadlocks.
This error seems to be related to multiprocessing, and the only place I could find this message was line 65 of https://github.com/kahypar/kahypar/blob/a05d75b9fd37880ab2853fad8e7ff54acd265247/kahypar/meta/abstract_factory.h .
The program worked as wished after I changed the order_finder_name
in khp_params.json
to default
. Besides the contraction costs were lower and the results had higher precision compared to the answers I got from my laptop. I wonder what makes the difference.
Hi, in file acqdp/tensor_network/contractor.py there is a function to import "tensor_network" submodule.
I'm wondering if this is the way you utilized GPU devices in your paper.
If that GPU library is available on the internet, could you add some document about what it is and how to use it?
The "circuit_simulation" example expects an input "circuit_file", but there is no documentation about how to construct this file. Could you please add some document and/or samples for this?
Hi, I just cloned and run the acqdp with the command shown below, and I found a error.
I redirected the output to a log, and I pasted both stderr and stdout as below:
(qulacs) [[email protected] acqdp]$ python3 ./examples/circuit_simulation.py benchmark/circuit_n53_m10_s0_e0_pABCDCDAB.qsim --save-order opt-m10 > m10-origional-d05-37.log
Traceback (most recent call last):
File "./examples/circuit_simulation.py", line 149, in <module>
tsk = tn.compile(order, **kwargs)
File "/home1/gengyura/acqdp/acqdp/tensor_network/tensor_network.py", line 113, in compile
return Compiler(**kwargs.get('compiler_params', {})).compile(self, order)
File "/home1/gengyura/acqdp/acqdp/tensor_network/compiler.py", line 50, in compile
res = self._generate_template(tn, scheme=scheme, **kwargs)
File "/home1/gengyura/acqdp/acqdp/tensor_network/compiler.py", line 70, in _generate_template
init_order, final_order = self._order_patch(tn_copy.copy(), order, split,
File "/home1/gengyura/acqdp/acqdp/tensor_network/compiler.py", line 220, in _order_patch
final_order = self._patch_order(tn_copy, final_order)
File "/home1/gengyura/acqdp/acqdp/tensor_network/compiler.py", line 258, in _patch_order
res = tree.patch(self.patch_size)
File "/home1/gengyura/acqdp/acqdp/tensor_network/contraction_tree.py", line 278, in patch
self.merge_nodes(width)
File "/home1/gengyura/acqdp/acqdp/tensor_network/contraction_tree.py", line 183, in merge_nodes
m0 = m0.union(brb[0][i][1]).difference(brb[0][i][2])
IndexError: list index out of range
in the log:
(3_w,7)-aCMA-ES (mu_w=2.3,w_1=58%) in dimension 3 (seed=698316605, Tue Jan 19 05:15:47 2021)
Iterat #Fevals function value axis ratio sigma min&max std t[m:s]
1 7 1.119770173288873e+01 1.0e+00 1.93e-01 2e-01 2e-01 0:08.2
2 14 1.125634101323780e+01 1.4e+00 1.68e-01 1e-01 2e-01 0:14.4
3 21 1.127719546809599e+01 1.6e+00 1.53e-01 1e-01 2e-01 0:21.5
4 28 1.136495725718497e+01 1.7e+00 1.32e-01 9e-02 1e-01 0:28.4
5 35 1.119770173288873e+01 1.7e+00 1.17e-01 7e-02 1e-01 0:35.5
6 42 1.125634101385395e+01 1.7e+00 1.32e-01 8e-02 1e-01 0:42.5
7 49 1.134322401217997e+01 1.7e+00 1.47e-01 8e-02 1e-01 0:48.7
9 63 1.119393613620733e+01 2.2e+00 1.06e-01 4e-02 1e-01 1:02.1
Process 0 initial cost: cost = 10.94684080523537, cw = 28.0, num_slice = 0
Process 0 succeeded with cost = 10.708556981162134, cw = 26.0, num_slice = 0
cost = 10.708556981162134, cw = 26.0, num_slice = 0
Saving order file opt-m10
In the session of "Example and test codes"
python examples/foo.py
python examples/ghz.py
Issue 1: foo.py doesn't exist at all, see https://github.com/alibaba/acqdp/tree/master/examples
Issue 2: ghz.py should be "GHZ.py". See the file at https://github.com/alibaba/acqdp/blob/main/examples/GHZ.py
Hi,
I'm trying to contract a circuit using your QAOA example. I create it from a graph and then do .preprocess() and .query().
See this file https://github.com/danlkv/acqdp/blob/main/demo/QAOA/bench_cli.py
for p=3, d=3 and p=2 d=4 the code fails with the following error:
ValueError: Internal error while evaluating ContractExpression. Note that few checks are performed - the number and rank of the array arguments must match the original expression. The internal error was: '('einstein sum subscripts string contains too many subscripts in the output',)'
I tried to simulate a 30-qubit GHZ state by ACQDP with slicing enabled, but an IndexError occurred. I modified line 128 of circuit_simulation.py
to open_indices = [i for i in range(n)]
. I found that self.branch_info()
of the ContractionTree
object was an empty list in this case. Is there a way to resolve this error without decreasing the size of open_indices
?
~/simulators/acqdp$ python3 examples/circuit_simulation.py entanglement_30.txt
(3_w,7)-aCMA-ES (mu_w=2.3,w_1=58%) in dimension 3 (seed=542818771, Fri Apr 15 09:37:11 2022)
Iterat #Fevals function value axis ratio sigma min&max std t[m:s]
1 7 9.031326093199107e+00 1.0e+00 1.95e-01 2e-01 2e-01 0:12.7
Process 0 initial cost: cost = 9.057243475079245, cw = 30.0, num_slice = 0
Process 0 succeeded with cost = 9.030954605585789, cw = 28.0, num_slice = 2
cost = 9.030954605585789, cw = 28.0, num_slice = 2
Traceback (most recent call last):
File "examples/circuit_simulation.py", line 157, in <module>
tsk = tn.compile(order, **kwargs)
File "/home/koova18/simulators/acqdp/acqdp/tensor_network/tensor_network.py", line 113, in compile
return Compiler(**kwargs.get('compiler_params', {})).compile(self, order)
File "/home/koova18/simulators/acqdp/acqdp/tensor_network/compiler.py", line 50, in compile
res = self._generate_template(tn, scheme=scheme, **kwargs)
File "/home/koova18/simulators/acqdp/acqdp/tensor_network/compiler.py", line 70, in _generate_template
init_order, final_order = self._order_patch(tn_copy.copy(), order, split,
File "/home/koova18/simulators/acqdp/acqdp/tensor_network/compiler.py", line 220, in _order_patch
final_order = self._patch_order(tn_copy, final_order)
File "/home/koova18/simulators/acqdp/acqdp/tensor_network/compiler.py", line 258, in _patch_order
res = tree.patch(self.patch_size)
File "/home/koova18/simulators/acqdp/acqdp/tensor_network/contraction_tree.py", line 281, in patch
self.merge_nodes(width)
File "/home/koova18/simulators/acqdp/acqdp/tensor_network/contraction_tree.py", line 178, in merge_nodes
if len(br[1]) >= len(br[2]):
IndexError: list index out of range
The documentation site does not have much information about how to construct a circuit from acqdb:
https://alibabaquantumlab.github.io/acqdp/
It will be very helpful if there could be some tutorials on creating and running a simple circuit in acqdb.
您好,运行了您的代码之后,有以下几个问题想要请教:
运行环境:
- Tesla V100 16G *1
- python 3.7
- Ubuntu 18.04
- backend = jax
计算一个perfect sample需要缩并所有slice并将结果相加,但经过我的多次实测,示例代码所需的时间要比论文上的多,比如将 acqdp/examples/circuit_simulation.py 的154-163行中的 num_samps 设为1 来计算单个 tsk[i]:
start_time = time.time()
results = 0
num_samps= 1
tsk.cast('complex64')
for i in range(num_samps):
res = tsk[i].execute(**kwargs)
results += res
compute_time = time.time()
print(compute_time - start_time)
运行得到:27.84s (m=12) , 26.06s (m=14)
在示例代码(acqdp/examples/circuit_simulation.py)中加载您开源的orders并打印 order.cost,得到的最好时间复杂度为
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.