-
Notifications
You must be signed in to change notification settings - Fork 53
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 11 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,127 @@ | ||
# 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. | ||
""" | ||
|
||
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 | ||
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. should have default value 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. 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
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 correction circuit.""" | ||
|
||
@abc.abstractmethod | ||
def error_detection_cycle_time(self, code_distance: int) -> float: | ||
"""The time of a quantum error correction cycle in seconds.""" | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class SurfaceCode(QuantumErrorCorrectionSchemeSummary): | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""A Surface Code Quantum Error Correction Scheme.""" | ||
|
||
def physical_qubits(self, code_distance: int) -> int: | ||
return 2 * code_distance**2 | ||
|
||
|
||
@frozen | ||
class SimpliedSurfaceCode(SurfaceCode): | ||
r"""SimpliedSurfaceCode assumes the error detection time is a linear function in code distance. | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The error detection time $\tau(d)$ is assumed to be given by a linear function | ||
$$ | ||
\tau(d) = a*d + b | ||
$$ | ||
Where $a$ is the `error_detection_cycle_time_slope_us` and $b$ is `error_detection_cycle_time_intercept_us` | ||
both of which depend only on the hardware. | ||
|
||
Attributes: | ||
error_detection_cycle_time_slope_us: | ||
error_detection_cycle_time_intercept_us: float | ||
""" | ||
|
||
error_detection_cycle_time_slope_us: float | ||
error_detection_cycle_time_intercept_us: float | ||
|
||
def error_detection_cycle_time(self, code_distance: int) -> float: | ||
return ( | ||
self.error_detection_cycle_time_slope_us * code_distance | ||
+ self.error_detection_cycle_time_intercept_us | ||
) * 1e-6 | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
Fowler = SimpliedSurfaceCode( | ||
error_rate_scaler=0.1, | ||
error_rate_threshold=0.01, | ||
# The Fowler model assumes an error detection time of 1us regardless of the code distance. | ||
error_detection_cycle_time_slope_us=0, | ||
error_detection_cycle_time_intercept_us=1, | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
reference='https://arxiv.org/pdf/1808.06709.pdf,https://arxiv.org/pdf/1208.0928.pdf', | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
# The Beverland model assumes an error detection time equal to a*d, where slope a depends only on the hardware. | ||
BeverlandTrappedIonQubits = SimpliedSurfaceCode( | ||
error_rate_scaler=0.03, | ||
error_rate_threshold=0.01, | ||
error_detection_cycle_time_slope_us=600, | ||
error_detection_cycle_time_intercept_us=0, | ||
reference='https://arxiv.org/pdf/2211.07629.pdf', | ||
) | ||
BeverlandSuperConductingQubits = SimpliedSurfaceCode( | ||
error_rate_scaler=0.03, | ||
error_rate_threshold=0.01, | ||
error_detection_cycle_time_slope_us=0.4, | ||
error_detection_cycle_time_intercept_us=0, | ||
reference='https://arxiv.org/pdf/2211.07629.pdf', | ||
) | ||
BeverlandMajoranaQubits = SimpliedSurfaceCode( | ||
error_rate_scaler=0.03, | ||
error_rate_threshold=0.01, | ||
error_detection_cycle_time_slope_us=0.6, | ||
error_detection_cycle_time_intercept_us=0, | ||
reference='https://arxiv.org/pdf/2211.07629.pdf', | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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.Fowler, 1e-3), (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], [qecs.Fowler, 242]] | ||
) | ||
def test_physical_qubits(qec: qecs.QuantumErrorCorrectionSchemeSummary, want: int): | ||
assert qec.physical_qubits(11) == want | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'qec,want', [[qecs.BeverlandSuperConductingQubits, 4.8e-6], [qecs.Fowler, 1e-6]] | ||
) | ||
def test_error_detection_cycle_time(qec: qecs.QuantumErrorCorrectionSchemeSummary, want: float): | ||
assert qec.error_detection_cycle_time(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.
can you be more specific about what this is supposed to be. Comma separated list of urls?
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.
for now I see it as just a human readable string