Open CSNWEB opened 5 months ago
Hello @CSNWEB , unlike in other numerical experiments, this function acqdp/demo/QAOA/qaoa.py at a8bd68e0a73814643e815f461c74a759858780cb · alibaba/acqdp directly translates a QAOA problem to a tensor network representing the ``lightcone'' of a set of qubits. Unfortunately, it is not possible to generate a unique quantum circuit from a json file representing a tensor network.
For all the numerical experiments mentioned in the original paper, we were given the option to utilize a code capsule. The specific version of the ACQDP package, along with scripts that replicate the results reported in the paper, is accessible at Code Ocean capsule.
You can find the input file and shell commands we ran at https://codeocean.com/capsule/8055748/tree/v3. The command line for CFI is
python -m demo.QAOA.qaoa_demo ../data/QAOA/cfi.json 6 > ../results/QAOA_cfi.result
For random circuit sampling tasks, the command line is
python -m examples.circuit_simulation ../data/SUPREMACY/circuit_n53_m12_s0_e0_pABCDCDAB.qsim -o ../data/SUPREMACY/m12_1.json > ../results/SUPREMACY_m12_1.result
Let me know if you have any further questions.
Hi, I work with @CSNWEB. Thank you for your answer!
I have another question relating to this. We've tried using the qaoa_demo script to generate tensor networks from the CFI circuits. We've managed to get the subscripts, but the tensor data (the numpy arrays) seem to be None. Where can we get the tensor data from?
Our attempt so far looks like this:
from . import qaoa
import json
import numpy as np
from sys import argv
exp_name = argv[1]
with open(exp_name, 'r') as f:
graphs = json.load(f)
num_layers = int(argv[2])
random_angles = np.random.uniform(0, 2 * np.pi, 2 * num_layers)
energy_list = []
a = qaoa.QAOAOptimizer({tuple(e): np.array([[1, -1], [-1, 1]]) for e in graphs['edges']}, num_layers=num_layers)
tn = a.preprocess(**graphs)[0]
inputs, output, shapes = tn.subscripts()
print(inputs)
print(output)
print(shapes)
tensors = [node['tensor']._data for node in tn.nodes.values()]
print(tensors)
Run with python -m demo.QAOA.qaoa_demo ../data/QAOA/tn_CFI_I_blue_4.json 6
The tensor data are not determined until QAOAOptimizer.query
is called with a concrete set of params, at which point query
calls decorate
to fill in the data.
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!