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

Add layer fidelity experiment #1322

Merged
merged 43 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2fc4c8a
WIP: Add layer fidelity experiment
itoko Nov 17, 2023
7897561
fix critical bugs and add layer fidelity computation
itoko Nov 22, 2023
2029739
fix style
itoko Nov 22, 2023
781b8eb
fix critical bug in measurements
itoko Nov 22, 2023
1b46de5
add test
itoko Nov 22, 2023
5c6f927
compute EPLG
itoko Nov 28, 2023
a6c0326
Fixes for backends with ECRGate employing #1288
itoko Nov 29, 2023
53dc8ca
Add figure title
itoko Nov 30, 2023
eebed5b
Add qubits column to analysis results table
itoko Nov 30, 2023
706f17e
Change to return results with quality=='failed' so that the lack of s…
itoko Dec 1, 2023
f538f15
add logging
itoko Dec 1, 2023
9d76044
Add replicate_in_parallel (a.k.a. seq_rep) option
itoko Dec 7, 2023
489538d
fix bugs
itoko Dec 12, 2023
27eec4f
fix some lint errors
itoko Dec 12, 2023
3515ad8
improve fitting quality check
itoko Dec 21, 2023
5e4b3be
add bad-quality reason and parameters as extra fields
itoko Dec 21, 2023
94cf76f
add generator of circuits
itoko Dec 22, 2023
ee43577
fix critical bug in the computation of process fidelity
itoko Dec 22, 2023
7411a1a
Add more validations
itoko Feb 14, 2024
3fc44fd
Fixes to pass all the tests
itoko Feb 14, 2024
d84ebce
Fix lint
itoko Feb 14, 2024
494462c
Require qiskit#11397
itoko Feb 14, 2024
e2ef0e2
Drop replicate_in_parallel option
itoko Feb 14, 2024
78eefae
Change to use fake provider in qiskit-ibm-runtime
itoko Feb 14, 2024
d2ed0f7
Fix to follow changes in what CurveAnalysis._run_analysis returns
itoko Feb 14, 2024
2702fcd
More informative figure names
itoko Feb 26, 2024
0393978
Improve docs
itoko Mar 19, 2024
d208460
fix lint
itoko Mar 19, 2024
a6786da
Merge branch 'main' into layer-fidelity
itoko Mar 19, 2024
f163ef7
Merge branch 'main' into layer-fidelity
itoko Mar 22, 2024
bf713dd
Add release note
itoko Mar 22, 2024
bacc3da
Add to autosummary
itoko Mar 22, 2024
599afc4
Fix bugs in docs
itoko Mar 22, 2024
9e09d8e
Fix lint
itoko Mar 22, 2024
f3c1791
Merge branch 'main' into layer-fidelity
itoko Mar 27, 2024
fe6d4b3
Merge branch 'main' into layer-fidelity
itoko Apr 1, 2024
9d5ac70
Make the method for evaluating result quality possible to override
itoko Apr 1, 2024
38e4636
Improve docs and reno following reviewer's comments
itoko Apr 8, 2024
0c3bd30
Cache 2q clifford integer table of the tensor product of 1q clifford …
itoko Apr 8, 2024
ec3f838
Update URL link in release note
itoko Apr 22, 2024
adbc6b4
Merge branch 'main' into layer-fidelity
itoko Apr 30, 2024
fafc233
fix url link in reno
itoko Apr 30, 2024
bc4e3c4
try to fix docs CI failure caused by the new Aer release
itoko May 1, 2024
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
2 changes: 1 addition & 1 deletion docs/manuals/measurement/readout_mitigation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Mitigation example
.. jupyter-execute::

qc = QuantumCircuit(num_qubits)
qc.h(0)
qc.sx(0)
for i in range(1, num_qubits):
qc.cx(i - 1, i)
qc.measure_all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

StandardRB
InterleavedRB
LayerFidelity


Analysis
Expand All @@ -36,6 +37,7 @@

RBAnalysis
InterleavedRBAnalysis
LayerFidelityAnalysis

Synthesis
=========
Expand All @@ -61,3 +63,5 @@
from .clifford_utils import CliffordUtils
from .rb_utils import RBUtils
from .clifford_synthesis import RBDefaultCliffordSynthesis
from .layer_fidelity import LayerFidelity
from .layer_fidelity_analysis import LayerFidelityAnalysis
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
_valid_sparse_indices = _clifford_compose_2q_data["valid_sparse_indices"]
# map a clifford number to the index of _CLIFFORD_COMPOSE_2Q_DENSE
_clifford_num_to_dense_index = {idx: ii for ii, idx in enumerate(_valid_sparse_indices)}
_CLIFFORD_TENSOR_1Q = np.load(f"{_DATA_FOLDER}/clifford_tensor_1q.npz")["table"]

# Transpilation utilities
def _transpile_clifford_circuit(
Expand Down Expand Up @@ -486,7 +487,11 @@ def inverse_1q(num: Integral) -> Integral:


def num_from_1q_circuit(qc: QuantumCircuit) -> Integral:
"""Convert a given 1-qubit Clifford circuit to the corresponding integer."""
"""Convert a given 1-qubit Clifford circuit to the corresponding integer.

Note: The circuit must consist of gates in :const:`_CLIFF_SINGLE_GATE_MAP_1Q`,
RZGate, Delay and Barrier.
"""
num = 0
for inst in qc:
rhs = _num_from_1q_gate(op=inst.operation)
Expand All @@ -497,7 +502,7 @@ def num_from_1q_circuit(qc: QuantumCircuit) -> Integral:
def _num_from_1q_gate(op: Instruction) -> int:
"""
Convert a given 1-qubit clifford operation to the corresponding integer.
Note that supported operations are limited to ones in :const:`CLIFF_SINGLE_GATE_MAP_1Q` or Rz gate.
Note that supported operations are limited to ones in :const:`_CLIFF_SINGLE_GATE_MAP_1Q` or Rz gate.

Args:
op: operation to be converted.
Expand Down Expand Up @@ -556,7 +561,11 @@ def inverse_2q(num: Integral) -> Integral:


def num_from_2q_circuit(qc: QuantumCircuit) -> Integral:
"""Convert a given 2-qubit Clifford circuit to the corresponding integer."""
"""Convert a given 2-qubit Clifford circuit to the corresponding integer.

Note: The circuit must consist of gates in :const:`_CLIFF_SINGLE_GATE_MAP_2Q`,
RZGate, Delay and Barrier.
"""
lhs = 0
for rhs in _clifford_2q_nums_from_2q_circuit(qc):
lhs = _CLIFFORD_COMPOSE_2Q_DENSE[lhs, _clifford_num_to_dense_index[rhs]]
Expand All @@ -568,7 +577,7 @@ def _num_from_2q_gate(
) -> int:
"""
Convert a given 1-qubit clifford operation to the corresponding integer.
Note that supported operations are limited to ones in `CLIFF_SINGLE_GATE_MAP_2Q` or Rz gate.
Note that supported operations are limited to ones in `_CLIFF_SINGLE_GATE_MAP_2Q` or Rz gate.

Args:
op: operation of instruction to be converted.
Expand Down Expand Up @@ -730,3 +739,8 @@ def _layer_indices_from_num(num: Integral) -> Tuple[Integral, Integral, Integral
idx1 = num % _NUM_LAYER_1
idx0 = num // _NUM_LAYER_1
return idx0, idx1, idx2


def _tensor_1q_nums(first: Integral, second: Integral) -> Integral:
"""Return the 2-qubit Clifford integer that is the tensor product of 1-qubit Cliffords."""
return _CLIFFORD_TENSOR_1Q[first, second]
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _hash_cliff(cliff):


def gen_clifford_inverse_1q():
"""Generate table data for integer 1Q Clifford inversion"""
"""Generate data for integer 1Q Clifford inversion table"""
invs = np.empty(NUM_CLIFFORD_1Q, dtype=int)
for i, cliff_i in _CLIFF_1Q.items():
invs[i] = _TO_INT_1Q[_hash_cliff(cliff_i.adjoint())]
Expand All @@ -68,7 +68,7 @@ def gen_clifford_inverse_1q():


def gen_clifford_compose_1q():
"""Generate table data for integer 1Q Clifford composition."""
"""Generate data for integer 1Q Clifford composition table"""
products = np.empty((NUM_CLIFFORD_1Q, NUM_CLIFFORD_1Q), dtype=int)
for i, cliff_i in _CLIFF_1Q.items():
for j, cliff_j in _CLIFF_1Q.items():
Expand All @@ -83,7 +83,7 @@ def gen_clifford_compose_1q():


def gen_clifford_inverse_2q():
"""Generate table data for integer 2Q Clifford inversion"""
"""Generate data for integer 2Q Clifford inversion table"""
invs = np.empty(NUM_CLIFFORD_2Q, dtype=int)
for i, cliff_i in _CLIFF_2Q.items():
invs[i] = _TO_INT_2Q[_hash_cliff(cliff_i.adjoint())]
Expand Down Expand Up @@ -191,6 +191,16 @@ def gen_cliff_single_2q_gate_map():
return table


def gen_clifford_tensor_1q():
"""Generate data for 2Q integer Clifford table of the tensor product of 1Q integer Cliffords."""
products = np.empty((NUM_CLIFFORD_1Q, NUM_CLIFFORD_1Q), dtype=int)
for i, cliff_i in _CLIFF_1Q.items():
for j, cliff_j in _CLIFF_1Q.items():
cliff = cliff_i.tensor(cliff_j)
products[i, j] = _TO_INT_2Q[_hash_cliff(cliff)]
return products


if __name__ == "__main__":
if _CLIFF_SINGLE_GATE_MAP_1Q != gen_cliff_single_1q_gate_map():
raise Exception(
Expand All @@ -212,3 +222,5 @@ def gen_cliff_single_2q_gate_map():
table=_CLIFFORD_COMPOSE_2Q_DENSE,
valid_sparse_indices=valid_sparse_indices,
)

np.savez_compressed("clifford_tensor_1q.npz", table=gen_clifford_tensor_1q())
Loading
Loading