microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
source/resource_estimator/src/estimates/error_budget.rs
69lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | #[derive(Debug, Clone)] |
| 5 | pub struct ErrorBudget { |
| 6 | /// Probability of at least one logical error |
| 7 | logical: f64, |
| 8 | /// Probability of at least one faulty magic state distillation |
| 9 | magic_states: f64, |
| 10 | /// Probability of at least one failed rotation synthesis |
| 11 | rotations: f64, |
| 12 | } |
| 13 | |
| 14 | impl ErrorBudget { |
| 15 | #[must_use] |
| 16 | pub fn new(logical: f64, magic_states: f64, rotations: f64) -> Self { |
| 17 | Self { |
| 18 | logical, |
| 19 | magic_states, |
| 20 | rotations, |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | #[must_use] |
| 25 | pub fn from_uniform(total_error: f64) -> Self { |
| 26 | Self { |
| 27 | logical: total_error / 3.0, |
| 28 | magic_states: total_error / 3.0, |
| 29 | rotations: total_error / 3.0, |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | /// Get the error budget's plogical. |
| 34 | #[must_use] |
| 35 | pub fn logical(&self) -> f64 { |
| 36 | self.logical |
| 37 | } |
| 38 | |
| 39 | pub fn set_logical(&mut self, logical: f64) { |
| 40 | self.logical = logical; |
| 41 | } |
| 42 | |
| 43 | /// Get the error budget's tstates. |
| 44 | #[must_use] |
| 45 | pub fn magic_states(&self) -> f64 { |
| 46 | self.magic_states |
| 47 | } |
| 48 | |
| 49 | pub fn set_magic_states(&mut self, magic_states: f64) { |
| 50 | self.magic_states = magic_states; |
| 51 | } |
| 52 | |
| 53 | /// Get the error budget's rotations. |
| 54 | #[must_use] |
| 55 | pub fn rotations(&self) -> f64 { |
| 56 | self.rotations |
| 57 | } |
| 58 | |
| 59 | pub fn set_rotations(&mut self, rotations: f64) { |
| 60 | self.rotations = rotations; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | #[derive(Default, Copy, Clone)] |
| 65 | pub enum ErrorBudgetStrategy { |
| 66 | #[default] |
| 67 | Static, |
| 68 | PruneLogicalAndRotations, |
| 69 | } |
| 70 | |