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

Merge qiskit-runtime into qiskit-ibm-runtime #90

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
dbf45e6
add intro and upload tutorials
jyu00 May 4, 2021
ca0842b
update some texts
ismaelfaro May 4, 2021
845b84b
fix directories
jyu00 May 4, 2021
3f8d30e
add to/from json
jyu00 May 5, 2021
f0594e8
rename intro
jyu00 May 5, 2021
06576c4
fix json
jyu00 May 5, 2021
e38c640
add circuit runner tutorial
jyu00 May 5, 2021
83a3e86
Merge remote-tracking branch 'origin/main' into circuit-runner-tutorial
jyu00 May 6, 2021
24f51e5
fix plot
jyu00 May 6, 2021
12d4cac
add 120x wording
jyu00 May 6, 2021
e8bc46f
Add a tutorial for the VQE script and ``VQEProgram`` (#11)
Cryoris May 7, 2021
1b398c9
Fix circuit runner parameters (#14)
jyu00 May 7, 2021
e686062
remove program update from title (#16)
jyu00 May 7, 2021
3cb88ab
add links (#20)
jyu00 May 7, 2021
640416a
add API direct tutorial (#30)
ismaelfaro May 8, 2021
8c590a2
runtime to program inputs (#28)
jyu00 May 10, 2021
3081031
move runnerresult import (#36)
jyu00 May 10, 2021
a4e946f
Move api direct tutorial from 05 to 01 (#32)
jyu00 May 10, 2021
dd00e5a
Update intro wording (#39)
jyu00 May 10, 2021
d52516a
Add circuit runner overview (#40)
nonhermitian May 11, 2021
d66be5b
Update VQE tutorial (#45)
Cryoris May 11, 2021
d825fa9
Add qka files and figs (#37)
jenglick May 11, 2021
ae6707b
Update 01_circuit_runner.ipynb (#50)
beckykd May 28, 2021
69b3703
Rename runtime-simple to sample-program (#52)
jyu00 Jun 4, 2021
908ccc8
Update tutorials (#65)
LucyXing Sep 1, 2021
02b97f6
Add IEEE workshop tutorial (#67)
jyu00 Sep 9, 2021
f92b3ca
Remove system limitation (#68)
jyu00 Sep 16, 2021
2318c41
update upload tutorial (#69)
LucyXing Sep 21, 2021
c6943e0
update tutorial (#71)
jyu00 Sep 28, 2021
ed55164
update requirements (#72)
jyu00 Sep 29, 2021
6477a46
Move IEEE tutorial (#73)
jyu00 Sep 29, 2021
02a6aa5
Circuit runner tutorial not using proper format (#74)
jyu00 Sep 29, 2021
6821fa3
Add full custom program tutorial (#77)
nonhermitian Oct 6, 2021
3317c08
fix some typos, lang consistency, etc. (#78)
abbycross Oct 6, 2021
e8e877c
Add back cell contents (#79)
nonhermitian Oct 6, 2021
bcf5100
Tweaks to full example based on review (#80)
nonhermitian Oct 6, 2021
1313038
Add UUID to program name in full example (#82)
nonhermitian Oct 6, 2021
240a2a9
Add custom expval program (#83)
nonhermitian Oct 13, 2021
afc03be
minor update the sample expval program (#85)
HwajungKang Oct 24, 2021
a03edbc
Update tutorials (#90)
kwoane Nov 11, 2021
8b872a3
Update wording on public programs (#88)
jyu00 Nov 11, 2021
d884bb7
Add link to article on 120x quantum speedup (#91)
rathishcholarajan Nov 11, 2021
55dddcb
Introduction Tutorial - more updates (#92)
rathishcholarajan Nov 11, 2021
93662e9
Update tutorials for ibmq-provider 0.18 (#93)
jyu00 Nov 11, 2021
5346d39
71 rename sample_program to hello_world (#96)
LucyXing Jan 5, 2022
c1a3399
moved files
daka1510 Jan 11, 2022
e1c78ef
Merge remote-tracking branch 'merge/main' into merge
daka1510 Jan 11, 2022
212ae5c
remove API_direct that is no longer needed
daka1510 Jan 11, 2022
de98aad
Merge branch 'main' into merge
daka1510 Jan 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
344 changes: 344 additions & 0 deletions tutorials/00_introduction.ipynb

Large diffs are not rendered by default.

623 changes: 623 additions & 0 deletions tutorials/01_circuit_runner.ipynb

Large diffs are not rendered by default.

654 changes: 654 additions & 0 deletions tutorials/02_uploading_program.ipynb

Large diffs are not rendered by default.

Binary file added tutorials/images/chip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/images/subgraphs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
634 changes: 634 additions & 0 deletions tutorials/qka.ipynb

Large diffs are not rendered by default.

823 changes: 823 additions & 0 deletions tutorials/sample_expval_program/qiskit_runtime_expval_program.ipynb

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions tutorials/sample_expval_program/sample_expval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import mthree
from qiskit import transpile

# The entrypoint for our Runtime Program
def main(backend, user_messenger,
circuits,
expectation_operators='',
shots = 8192,
transpiler_config={},
run_config={},
skip_transpilation=False,
return_stddev=False,
use_measurement_mitigation=False,
):

"""Compute expectation values for a list of operators after
executing a list of circuits on the target backend.

Parameters:
backend (ProgramBackend): Qiskit backend instance.
user_messenger (UserMessenger): Used to communicate with the program user.
circuits: (QuantumCircuit or list): A single list of QuantumCircuits.
expectation_operators (str or dict or list): Expectation values to evaluate.
shots (int): Number of shots to take per circuit.
transpiler_config (dict): A collection of kwargs passed to transpile().
run_config (dict): A collection of kwargs passed to backend.run().
skip_transpilation (bool): Skip transpiling of circuits, default=False.
return_stddev (bool): Return upper bound on standard devitation,
default=False.
use_measurement_mitigation (bool): Improve resulting using measurement
error mitigation, default=False.

Returns:
array_like: Returns array of expectation values or a list of (expval, stddev)
tuples if return_stddev=True.
"""

# transpiling the circuits using given transpile options
if not skip_transpilation:
trans_circuits = transpile(circuits, backend=backend,
**transpiler_config)

if not isinstance(trans_circuits, list):
trans_circuits = [trans_circuits]
# If skipping set circuits -> trans_circuits
else:
if not isinstance(circuits, list):
trans_circuits = [circuits]
else:
trans_circuits = circuits

# If we are given a single circuit but requesting multiple expectation values
# Then set flag to make multiple pointers to same result.
duplicate_results = False
if isinstance(expectation_operators, list):
if len(expectation_operators) and len(trans_circuits) == 1:
duplicate_results = True

if use_measurement_mitigation:
# Get an the measurement mappings at end of circuits
meas_maps = mthree.utils.final_measurement_mapping(trans_circuits)
# Get an M3 mitigator
mit = mthree.M3Mitigation(backend)
# Calibrate over the set of qubits measured in the transpiled circuits.
mit.cals_from_system(meas_maps)

# Compute raw results
result = backend.run(trans_circuits, shots=shots, **run_config).result()
raw_counts = result.get_counts()

# When using measurement mitigation we need to apply the correction and then
# compute the expectation values from the computed quasi-probabilities.
if use_measurement_mitigation:
quasi_dists = mit.apply_correction(raw_counts, meas_maps,
return_mitigation_overhead=return_stddev)

if duplicate_results:
quasi_dists = mthree.classes.QuasiCollection([quasi_dists]*len(expectation_operators))
# There are two different calls depending on what we want returned.
if return_stddev:
return quasi_dists.expval_and_stddev(expectation_operators)
return quasi_dists.expval(expectation_operators)

# If the program didn't return in the mitigation loop above it means
# we are processing the raw_counts data. We do so here using the
# mthree utilities
if duplicate_results:
raw_counts = [raw_counts]*len(expectation_operators)
if return_stddev:
return mthree.utils.expval_and_stddev(raw_counts, expectation_operators)
return mthree.utils.expval(raw_counts, expectation_operators)
Loading