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

No documentation for "circuit_file" in example #12

Open
zhoupingjay opened this issue Dec 31, 2020 · 6 comments
Open

No documentation for "circuit_file" in example #12

zhoupingjay opened this issue Dec 31, 2020 · 6 comments

Comments

@zhoupingjay
Copy link

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?

@zhoupingjay zhoupingjay changed the title No documentation for "circuit_file" No documentation for "circuit_file" in example Dec 31, 2020
@fangzh-umich
Copy link

The circuit simulation example reads an input file in the "qsim format" described in https://github.com/quantumlib/qsim/blob/master/docs/input_format.md, although we haven't implemented all those gates, but only h, cz, t, x_1_2, y_1_2, hz_1_2, is, rz, and fs.

We call this format the "GRCS format" because it is the same circuit format used in https://github.com/sboixo/GRCS. It also appears in the public dataset of the Nature paper by Google that claims quantum supremacy.

Maybe we should add a docstring for the GRCS function that explains this file format.

@zhoupingjay
Copy link
Author

zhoupingjay commented Jan 11, 2021

Hi, I tried writing a simplest circuit using the "qsim" format:

1
0 x 0
1 h 0

It only contains one qubit, using one X gate and one H gate. I then ran the circuit with circuit_simulation example:

python3 examples/circuit_simulation.py hello_acqdp.txt

But I got error from the example:

Traceback (most recent call last):
  File "/Users/zhouping/GitHub/acqdp/examples/circuit_simulation.py", line 122, in <module>
    c = GRCS(args.circuit_file, simplify=False)
  File "/Users/zhouping/GitHub/acqdp/examples/circuit_simulation.py", line 67, in GRCS
    int(x) for x in words[2:2 + size_table[words[1].lower()]])
KeyError: 'x'

@zhoupingjay
Copy link
Author

A relative comment: The qsim format is deprecated. Is it possible to import circuit from Cirq's JSON format?

@zhoupingjay
Copy link
Author

Another related question: How do I add measurements to the circuit, e.g. something like what I did this notebook:
https://github.com/zhoupingjay/quantum/blob/main/2-bit-Deutsch-Problem.ipynb

circuit.append([cirq.measure(q0), cirq.measure(q1)],
                  strategy=cirq.InsertStrategy.NEW_THEN_INLINE)

@fangzh-umich
Copy link

As mentioned above, we did not implement all the gates supported by the "qsim" format, but only the ones used in Google's random circuits. The GRCS function is intended as a demonstration of how one could convert other circuit formats to our format, not a fully functional converter.

Maybe we could try to implement importing circuits from Cirq's JSON format if you could link to a complete format specification.

@fangzh-umich
Copy link

fangzh-umich commented Jan 11, 2021

Measurements are a bit complicated. If you want to calculate the amplitude (or the probability) of a specific measurement result, you can use ZeroMeas or OneMeas. If you want to calculate the amplitude for all (computational basis) measurement results, you should just omit the measurement at all: The way the conversion from circuits to tensor networks work, all "open" qubits are implicitly "measured" in the computational basis. Other scenarios may require more creative solutions; see our QEC demo for some examples.

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