Skip to content

Commit

Permalink
compute EPLG
Browse files Browse the repository at this point in the history
  • Loading branch information
itoko committed Nov 28, 2023
1 parent 81caf03 commit 168a3b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ def _run_analysis(
extra={},
)

# TODO: Plot LF by chain length for a full 2q-gate chain

# Return combined results
analysis_results = [slf_result] + analysis_results
return analysis_results, figures
Expand All @@ -209,6 +207,7 @@ def __init__(self, layers, analyses=None):

super().__init__(analyses, flatten_results=True)
self.num_layers = len(layers)
self.num_2q_gates = sum(1 if len(qs) == 2 else 0 for lay in layers for qs in lay)

def _run_analysis(
self, experiment_data: ExperimentData
Expand All @@ -233,7 +232,15 @@ def _run_analysis(
quality=quality_lf,
extra={},
)

eplg = 1 - (lf ** (1/self.num_2q_gates))
eplg_result = AnalysisResultData(
name="EPLG",
value=eplg,
chisq=None,
quality=quality_lf,
extra={},
)

# Return combined results
analysis_results = [lf_result] + analysis_results
analysis_results = [lf_result, eplg_result] + analysis_results
return analysis_results, figures
48 changes: 24 additions & 24 deletions test/library/randomized_benchmarking/test_layer_fidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ def test_experiment_config(self):
self.assertNotEqual(exp, loaded_exp)
self.assertEqualExtended(exp, loaded_exp)

# def test_invalid_two_qubit_layers(self):
# """Test raise error when creating experiment with invalid configs."""
# valid_kwargs = {
# "lengths": [10, 20, 30],
# "two_qubit_gate": "cx",
# "one_qubit_basis_gates": ["rz", "sx", "x"],
# }
# # not disjoit
# with self.assertRaises(QiskitError):
# LayerFidelity(
# physical_qubits=(0, 1, 2, 3),
# two_qubit_layers=[[(0, 1), (1, 2)]],
# **valid_kwargs
# )
# # no 2q-gate on the qubits (FakeManilaV2 has no cx gate on (0, 3))
# with self.assertRaises(QiskitError):
# LayerFidelity(
# physical_qubits=(0, 1, 2, 3),
# two_qubit_layers=[[(0, 3)]],
# backend=FakeManilaV2(),
# **valid_kwargs
# )
def test_invalid_two_qubit_layers(self):
"""Test raise error when creating experiment with invalid configs."""
valid_kwargs = {
"lengths": [10, 20, 30],
"two_qubit_gate": "cx",
"one_qubit_basis_gates": ["rz", "sx", "x"],
}
# not disjoit
with self.assertRaises(QiskitError):
LayerFidelity(
physical_qubits=(0, 1, 2, 3),
two_qubit_layers=[[(0, 1), (1, 2)]],
**valid_kwargs
)
# no 2q-gate on the qubits (FakeManilaV2 has no cx gate on (0, 3))
with self.assertRaises(QiskitError):
LayerFidelity(
physical_qubits=(0, 1, 2, 3),
two_qubit_layers=[[(0, 3)]],
backend=FakeManilaV2(),
**valid_kwargs
)

def test_roundtrip_serializable(self):
"""Test round trip JSON serialization"""
Expand Down Expand Up @@ -190,8 +190,8 @@ def test_backend_with_directed_basis_gates(self):
class TestRunLayerFidelity(QiskitExperimentsTestCase, RBTestMixin):
"""Test for running LayerFidelity on noisy simulator."""

def test_three_qubit(self):
"""Test two qubit RB. Use default basis gates."""
def test_run_layer_fidelity(self):
"""Test layer fidelity RB. Use default basis gates."""
exp = LayerFidelity(
physical_qubits=(0, 1, 2, 3),
two_qubit_layers=[[(1, 0), (2, 3)], [(1, 2)]],
Expand Down

0 comments on commit 168a3b7

Please sign in to comment.