-
Notifications
You must be signed in to change notification settings - Fork 23
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
Quantum volume #15
Quantum volume #15
Conversation
Very cool. Went through the python code; haven't checked out the notebook |
examples/quantum_volume.ipynb
Outdated
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from forest_qcvv.quantum_volume import measure_quantum_volume\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would suggest splitting into two cells.
One with "from forest_qcvv.quantum_volume import measure_quantum_volume"
Another with
"# takes about 4.5 minutes
ideal_start = time.time()
ideal_outcomes = measure_quantum_volume(ideal_qc, num_circuits=200)
ideal_end = time.time()
print('Run time: ' + str(ideal_end - ideal_start) + 'seconds')"
or something like that.
examples/quantum_volume.ipynb
Outdated
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"noisy_outcomes = measure_quantum_volume(noisy_qc, num_circuits=200, num_shots=500)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again just as a warning to the user
"# also takes about 4.5 min
noisy_start = time.time()
noisy_outcomes = measure_quantum_volume(noisy_qc, num_circuits=200, num_shots=500)
noisy_end = time.time()
print('Run time: ' + str(noisy_end - noisy_start) + 'seconds')"
"qubits = ideal_qc.qubits()\n", | ||
"print(qubits)\n", | ||
"graph = ideal_qc.qubit_topology()\n", | ||
"nx.draw_networkx(graph, with_labels=True)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show users how to play with different topologies using
_get_qvm_with_topology(name=yo, connection=connection,
topology=topology,
noisy=noisy,
requires_executable=False)
and
num_of_qubits = 5
>line_graph = nx.Graph([(idx,idx+1) for idx in range(num_of_qubits-1)])
>ring_graph = nx.Graph([(idx,idx+1) for idx in range(num_of_qubits-1)] +[(0,num_of_qubits-1)])
>star_graph = nx.Graph([(0,idx+1) for idx in range(num_of_qubits-1)])
1f1ea6d
to
68cd57e
Compare
Now uses pyQVM (requires rigetti/pyquil#552) |
At this point I think it would be good to merge and run this module on the hardware for benchmarking. Moreover we might get feedback and improvements from @ecp-rigetti @notmgsk and @stylewarning on the compilation aspects. |
This looks good to me. As for compiler advice, I'd recommend being able to prefix these generated programs with some user-supplied fixed string, expected to be populated by some compiler directives (like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor things. The only thing that earns this a "request changes" is adding tqdm as a dependency
from typing import List, Sequence, Tuple, Callable | ||
import warnings | ||
import logging | ||
from tqdm import tqdm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add tdqm to requirements.txt and the install_requires part of setup.py
"to be valid.") | ||
if qubits is None: | ||
qubits = qc.qubits() | ||
qubits = sorted(qubits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still mid-review but note to self: figure out if this sorting is necessary
qc.qubits()
will return a sorted list- if the user provides qubits in a specific order, it is slightly surprising that they will be sorted "under the hood"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i'm back. I think you should be able to trivially remove the sorting, although it really doesn't matter since we apply permutations anyways. Not blocking merge of this pr
|
||
results = [] | ||
for depth in depths: | ||
logging.info("Starting depth {}".format(depth)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for not telling you the whole story previously. The best-practice for logging is to put at the top of the file
import logging
log = logging.getLogger(__name__)
and then use log
in the program
gates: np.ndarray) -> List[int]: | ||
""" | ||
Uses the provided wfn_sim to calculate the probability of measuring each bitstring from the | ||
output of the circuit comprised of the given permutations and gates; those 'heavy' bitstrings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split after the ;
for a shorter one(-ish) first line summary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for harping on this. When we render API docs in sphinx it becomes important. The first line will go in the table of functions and the rest of it will be rendered nicely when you click through
""" | ||
num_measure_qubits = len(permutations[0]) | ||
# at present, naively select the minimum number of qubits with smallest labels to run on | ||
qubits = sorted(qubits)[:num_measure_qubits] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: another sorting of the qubits
…ogram generation and updated notebook.
… from permutation.
03d15eb
to
d7a9107
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry i forgot my "request changes" was blocking this
So far this is a very basic implementation of the quantum volume measurement. I was able to replicate the simulated points in Fig 2 of https://arxiv.org/pdf/1811.12926.pdf in the example notebook. We may want to restructure things to be more modular so that different approaches and future improvements can more easily be incorporated.