Giter Site home page Giter Site logo

acqdp's Introduction

Alibaba Cloud Quantum Development Platform (ACQDP)

Introduction

ACQDP is an open-source simulator-driven development tool for quantum algorithms and quantum computers. The initial release of ACQDP in October 2020 features Alibaba Quantum Laboratory’s general-purpose, tensor-contraction based quantum circuit simulator, together with some applications on quantum algorithm and error correction simulations. Some future directions of ACQDP of higher prioritites are

  1. Strengthening the capabilities of the simulator, in terms of the scale of the target circuits, and allowing approximations.
  2. Improving the capabilities for and expanding the scope of applications.
  3. Developing friendly user interfaces for both the educational and research communities.
  4. Adding utilities facilitating the deployment in various computing environments.

Computing Engine

Partially inspired by the recent quantum supremacy experiment, classical simulation of quantum circuits attracts quite a bit of attention and impressive progress has been made along this line of research to significantly improve the performance of classical simulation of quantum circuits. Key ingredients include

  1. Quantum circuit simulation as tensor network contraction [1];
  2. Undirected graph model formalism[2];
  3. Dynamic slicing [3][4];
  4. Contraction tree [5];
  5. Contraction subtree reconfiguration [6].

We are happy to be part of this effort.

Use Cases

  • Efficient exact contraction of intermediate-sized tensor networks
  • Deployment on large-scale clusters for contracting complex tensor networks
  • Efficient exact simulation of intermediate sized quantum circuit
  • Classical simulation under different quantum noise models

Documentation

See full documentation here.

Installation

See instructions here.

Contributing

If you are interested in contributing to ACQDP feel free to contact me or create an issue on the issue tracking system.

References

[1] Markov, I. and Shi, Y.(2008) Simulating quantum computation by contracting tensor networks SIAM Journal on Computing, 38(3):963-981, 2008

[2] Boixo, S., Isakov, S., Smelyanskiy, V. and Neven, H. (2017) Simulation of low-depth quantum circuits as complex undirected graphical models arXiv preprint arXiv:1712.05384

[3] Chen, J., Zhang, F., Huang, C., Newman, M. and Shi, Y.(2018) Classical simulation of intermediate-size quantum circuits arXiv preprint arXiv:1805.01450

[4] Zhang, F., Huang, C., Newman M., Cai, J., Yu, H., Tian, Z., Yuan, B., Xu, H.,Wu, J., Gao, X., Chen, J., Szegedy, M. and Shi, Y.(2019) Alibaba Cloud Quantum Development Platform: Large-Scale Classical Simulation of Quantum Circuits arXiv preprint arXiv:1907.11217

[5] Gray, J. and Kourtis, S.(2020) Hyper-optimized tensor network contraction arXiv preprint arXiv:2002.01935

[6] Huang, C., Zhang, F.,Newman M., Cai, J., Gao, X., Tian, Z., Wu, J., Xu, H., Yu, H., Yuan, B.,
Szegedy, M., Shi, Y. and Chen, J. (2020) Classical Simulation of Quantum Supremacy Circuits arXiv preprint arXiv:2005.06787

acqdp's People

Contributors

alibaba-oss avatar alibabaquantumlab avatar cupjinhuang avatar maxxungao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acqdp's Issues

ContractionTree.branch_info() returns empty list when slicing is applied

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

KHP order finder halts with "Invalid object identifier"

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.

No documentation for "circuit_file" in example

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?

ValueError: too many enisum subscripts

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',)'

cut_kKaHyPar_sea20.ini is not found when package is installed

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.

Generation of CFI files / circuits.

Hello,

in the original paper (https://www.nature.com/articles/s43588-021-00119-7) and the dataset (https://datadryad.org/stash/dataset/doi:10.5061/dryad.nk98sf7t8) that belongs to it, there are these CFI files / circuits. Would you be able to provide the code to you used to generate the data files or describe how you generated the circuits they belong to? We tried to parse them, but for the sycamore files we get different circuits than the ones we get from the qsim files directly.

Thanks a lot!

Possible bug

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) [gengyura@d05-37 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


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'

实测结果问题

您好,运行了您的代码之后,有以下几个问题想要请教:

运行环境:

  • Tesla V100 16G *1
  • python 3.7
  • Ubuntu 18.04
  • backend = jax

1. 计算一个perfect sample所需时间与论文不一致 :

计算一个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)
  • 如果 tsk[i] 是指缩并一个slice(即论文中的subtask),那么计算一个perfect sample所需的时间应该约为 1个tsk所需时间 * slice数量,而这显然会大于论文里的时间:38.02s (m=12)。

2. 开源order的时间复杂度与论文不一致:

在示例代码(acqdp/examples/circuit_simulation.py)中加载您开源的orders并打印 order.cost,得到的最好时间复杂度为

  • (m=14) cost = 10^14.16 = 1.43*10^14
  • (m=12) cost = 10^13.34 = 2.17*10^13
    而论文中是
  • (m=14) cost = 7.16*10^13
  • (m=12) cost = 1.09*10^13
    请问开源的orders不是最优的吗,怎样才能得到符合论文数据的order?

How to perform a measurement in acqdp?

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.