-
Notifications
You must be signed in to change notification settings - Fork 51
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 a summary of QEC algorithms class #378
Changes from 17 commits
c3ffd19
e1f9b4f
310c0dc
cf1cde3
4cab323
a24c06f
174c239
885f732
a1e00c8
8fa3272
ea9edc7
5a14ec6
b81e1ea
30092d7
3cc5d90
6c79a33
dd38ded
5d5e7e4
d3916ec
ac1ee47
234338a
28b2a8b
b4e9240
1fa2e68
b61d688
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import abc | ||
|
||
import numpy as np | ||
from attrs import field, frozen | ||
|
||
|
||
@frozen | ||
class QuantumErrorCorrectionSchemeSummary(abc.ABC): | ||
r"""QuantumErrorCorrectionSchemeSummary represents a high level view of a QEC scheme. | ||
|
||
QuantumErrorCorrectionSchemeSummary provides estimates for the logical error rate, | ||
number of physical qubits and the time of an error detection cycle. | ||
|
||
The logical error rate as a function of code distance $d$ and physical error rate $p$ | ||
is given by | ||
$$ | ||
a \left ( \frac{p}{p^*} \right )^\frac{d + 1}{2} | ||
$$ | ||
Where $a$ is the error_rate_scaler and $p^*$ is the error_rate_threshold. | ||
|
||
Note: The logical error-suppression factor $\Lambda = \frac{p^*}{p}$ | ||
|
||
Attributes: | ||
error_rate_scaler: Logical error rate coefficient. | ||
error_rate_threshold: Logical error rate threshold. | ||
reference: source of the estimates in human readable format. | ||
""" | ||
|
||
error_rate_scaler: float = field(repr=lambda x: f'{x:g}') | ||
error_rate_threshold: float = field(repr=lambda x: f'{x:g}') | ||
reference: str | None | ||
|
||
def logical_error_rate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a general form of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the |
||
self, code_distance: int, physical_error_rate: float | np.ndarray | ||
) -> float | np.ndarray: | ||
"""The logical error rate given the physical error rate.""" | ||
return self.error_rate_scaler * np.power( | ||
physical_error_rate / self.error_rate_threshold, (code_distance + 1) / 2 | ||
) | ||
|
||
@abc.abstractmethod | ||
def physical_qubits(self, code_distance: int) -> int: | ||
"""The number of physical qubits used by the error detection circuit.""" | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@abc.abstractmethod | ||
def error_detection_circuit_time_us(self, code_distance: int) -> float: | ||
"""The time of a quantum error detection cycle in seconds.""" | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
@frozen | ||
class SimpliedSurfaceCode(QuantumErrorCorrectionSchemeSummary): | ||
"""A Surface Code Quantum Error Correction Scheme. | ||
|
||
Attributes: | ||
single_stabilizer_time_us: Max time of a single X or Z stabilizer measurement. | ||
""" | ||
|
||
single_stabilizer_time_us: float | ||
|
||
def physical_qubits(self, code_distance: int) -> int: | ||
return 2 * code_distance**2 | ||
mpharrigan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def error_detection_circuit_time_us(self, code_distance: int) -> float: | ||
"""Equals the time to measure a stabilizer times the depth of the circuit.""" | ||
return self.single_stabilizer_time_us * code_distance | ||
|
||
|
||
BeverlandSuperConductingQubits = SimpliedSurfaceCode( | ||
error_rate_scaler=0.03, | ||
error_rate_threshold=0.01, | ||
single_stabilizer_time_us=0.4, # Equals 4*t_gate+2*t_meas where t_gate=50ns and t_meas=100ns. | ||
reference='https://arxiv.org/abs/2211.07629', | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import pytest | ||
|
||
from qualtran.surface_code import quantum_error_correction_scheme_summary as qecs | ||
|
||
|
||
@pytest.mark.parametrize('qec,want', [(qecs.BeverlandSuperConductingQubits, 3e-4)]) | ||
def test_logical_error_rate(qec: qecs.QuantumErrorCorrectionSchemeSummary, want: float): | ||
assert qec.logical_error_rate(3, 1e-3) == pytest.approx(want) | ||
|
||
|
||
@pytest.mark.parametrize('qec,want', [[qecs.BeverlandSuperConductingQubits, 242]]) | ||
def test_physical_qubits(qec: qecs.QuantumErrorCorrectionSchemeSummary, want: int): | ||
assert qec.physical_qubits(11) == want | ||
|
||
|
||
@pytest.mark.parametrize('qec,want', [[qecs.BeverlandSuperConductingQubits, 4.8]]) | ||
def test_error_detection_cycle_time(qec: qecs.QuantumErrorCorrectionSchemeSummary, want: float): | ||
assert qec.error_detection_circuit_time_us(12) == pytest.approx(want) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should have default value of
None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I do then any attribute in any class that inherets this class must have a default value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done