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

Quantum volume #15

Merged
merged 10 commits into from
Feb 8, 2019
Merged

Quantum volume #15

merged 10 commits into from
Feb 8, 2019

Conversation

kylegulshen
Copy link
Contributor

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.

@mpharrigan
Copy link
Contributor

Very cool. Went through the python code; haven't checked out the notebook

"metadata": {},
"outputs": [],
"source": [
"from forest_qcvv.quantum_volume import measure_quantum_volume\n",
Copy link
Contributor

@joshcombes joshcombes Jan 22, 2019

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.

"metadata": {},
"outputs": [],
"source": [
"noisy_outcomes = measure_quantum_volume(noisy_qc, num_circuits=200, num_shots=500)"
Copy link
Contributor

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)"
Copy link
Contributor

@joshcombes joshcombes Jan 22, 2019

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)])

@kylegulshen
Copy link
Contributor Author

Now uses pyQVM (requires rigetti/pyquil#552)

@joshcombes
Copy link
Contributor

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.

@ecpeterson
Copy link

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 PRAGMA INITIAL_REWIRING "PARTIAL" or whatever). Otherwise, I think this is a good use of our toolchain (and hence a faithful recreation of the experiment).

@kylegulshen kylegulshen changed the title [WIP] Quantum volume Quantum volume Jan 25, 2019
Copy link
Contributor

@mpharrigan mpharrigan left a 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
Copy link
Contributor

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)
Copy link
Contributor

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

  1. qc.qubits() will return a sorted list
  2. if the user provides qubits in a specific order, it is slightly surprising that they will be sorted "under the hood"

Copy link
Contributor

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))
Copy link
Contributor

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

forest_benchmarking/quantum_volume.py Show resolved Hide resolved
forest_benchmarking/quantum_volume.py Show resolved Hide resolved
forest_benchmarking/quantum_volume.py Show resolved Hide resolved
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
Copy link
Contributor

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

Copy link
Contributor

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

forest_benchmarking/quantum_volume.py Outdated Show resolved Hide resolved
"""
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]
Copy link
Contributor

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

forest_benchmarking/quantum_volume.py Show resolved Hide resolved
@mpharrigan mpharrigan dismissed their stale review February 8, 2019 00:15

addressed changes

Copy link
Contributor

@mpharrigan mpharrigan left a 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

@mpharrigan mpharrigan merged commit 92f383d into master Feb 8, 2019
@mpharrigan mpharrigan deleted the quantum-volume branch February 8, 2019 00:19
@karalekas karalekas added this to the v0.3 milestone Mar 20, 2019
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

Successfully merging this pull request may close these issues.

5 participants