Skip to content

Commit

Permalink
fix inferred errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri committed Feb 10, 2024
1 parent cf1002b commit 6994800
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions cirq-core/cirq/experiments/two_qubit_xeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,27 +179,27 @@ def all_qubit_pairs(self) -> Sequence[Tuple['cirq.GridQubit', 'cirq.GridQubit']]
return self.xeb_result.all_qubit_pairs

def _pauli_error(self, q0: 'cirq.GridQubit', q1: 'cirq.GridQubit') -> float:
"""Return the total pauli error."""
"""Return the inferred pauli error."""
q0, q1 = sorted([q0, q1])
single_q_paulis = self.rb_result.pauli_error()
return self.xeb_result.pauli_error()[(q0, q1)] + single_q_paulis[q0] + single_q_paulis[q1]
return self.xeb_result.pauli_error()[(q0, q1)] - single_q_paulis[q0] - single_q_paulis[q1]

@cached_method
def pauli_error(self) -> Dict[Tuple['cirq.GridQubit', 'cirq.GridQubit'], float]:
"""Return the equivalent pauli error for all pairs."""
"""Return the inferred pauli error for all pairs."""
return {pair: self._pauli_error(*pair) for pair in self.all_qubit_pairs}

@cached_method
def decay_constant(self) -> Dict[Tuple['cirq.GridQubit', 'cirq.GridQubit'], float]:
"""Return the equivalent decay constant for all pairs."""
"""Return the inferred decay constant for all pairs."""
return {
pair: noise_utils.pauli_error_to_decay_constant(pauli, 2)
for pair, pauli in self.pauli_error().items()
}

@cached_method
def xeb_error(self) -> Dict[Tuple['cirq.GridQubit', 'cirq.GridQubit'], float]:
"""Return the equivalent XEB error for all pairs."""
"""Return the inferred XEB error for all pairs."""
return {
pair: 1 - noise_utils.decay_constant_to_xeb_fidelity(decay, 2)
for pair, decay in self.decay_constant().items()
Expand Down
30 changes: 15 additions & 15 deletions cirq-core/cirq/experiments/two_qubit_xeb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,23 @@ def test_pauli_error(q0: cirq.GridQubit, q1: cirq.GridQubit, pauli: float):
class MockParallelRandomizedBenchmarkingResult(ParallelRandomizedBenchmarkingResult):
def pauli_error(self) -> Dict[cirq.Qid, float]:
return {
cirq.GridQubit(4, 4): 0.1,
cirq.GridQubit(5, 4): 0.2,
cirq.GridQubit(5, 3): 0.3,
cirq.GridQubit(5, 6): 0.4,
cirq.GridQubit(4, 3): 0.5,
cirq.GridQubit(6, 3): 0.6,
cirq.GridQubit(6, 4): 0.7,
cirq.GridQubit(4, 4): 0.01,
cirq.GridQubit(5, 4): 0.02,
cirq.GridQubit(5, 3): 0.03,
cirq.GridQubit(5, 6): 0.04,
cirq.GridQubit(4, 3): 0.05,
cirq.GridQubit(6, 3): 0.06,
cirq.GridQubit(6, 4): 0.07,
}


@pytest.mark.parametrize(
'q0,q1,pauli',
[
(cirq.GridQubit(4, 4), cirq.GridQubit(5, 4), 1 / 8 + 0.3),
(cirq.GridQubit(5, 3), cirq.GridQubit(6, 3), 1 / 4 + 0.9),
(cirq.GridQubit(4, 3), cirq.GridQubit(5, 3), 0.8 + 3 / 40 + 0.8),
(cirq.GridQubit(6, 3), cirq.GridQubit(6, 4), 5 / 8 + 1.3),
(cirq.GridQubit(4, 4), cirq.GridQubit(5, 4), 1 / 8 - 0.03),
(cirq.GridQubit(5, 3), cirq.GridQubit(6, 3), 1 / 4 - 0.09),
(cirq.GridQubit(4, 3), cirq.GridQubit(5, 3), 0.8 + 3 / 40 - 0.08),
(cirq.GridQubit(6, 3), cirq.GridQubit(6, 4), 5 / 8 - 0.13),
],
)
def test_combined_pauli_error(q0: cirq.GridQubit, q1: cirq.GridQubit, pauli: float):
Expand All @@ -197,10 +197,10 @@ def test_combined_pauli_error(q0: cirq.GridQubit, q1: cirq.GridQubit, pauli: flo
@pytest.mark.parametrize(
'q0,q1,xeb',
[
(cirq.GridQubit(4, 4), cirq.GridQubit(5, 4), 0.34),
(cirq.GridQubit(5, 3), cirq.GridQubit(6, 3), 0.92),
(cirq.GridQubit(4, 3), cirq.GridQubit(5, 3), 1.34),
(cirq.GridQubit(6, 3), cirq.GridQubit(6, 4), 1.54),
(cirq.GridQubit(4, 4), cirq.GridQubit(5, 4), 0.076),
(cirq.GridQubit(5, 3), cirq.GridQubit(6, 3), 0.128),
(cirq.GridQubit(4, 3), cirq.GridQubit(5, 3), 0.636),
(cirq.GridQubit(6, 3), cirq.GridQubit(6, 4), 0.396),
],
)
def test_combined_xeb_error(q0: cirq.GridQubit, q1: cirq.GridQubit, xeb: float):
Expand Down

0 comments on commit 6994800

Please sign in to comment.