Skip to content

Commit

Permalink
Method to prune error budget.
Browse files Browse the repository at this point in the history
  • Loading branch information
msoeken committed Oct 5, 2024
1 parent c8e987a commit 3743568
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 156 deletions.
6 changes: 4 additions & 2 deletions resource_estimator/examples/basic_logical_counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ fn main() {

// After we have set up all required inputs for the resource estimation
// task, we can set up an estimation instance.
let estimation = PhysicalResourceEstimation::new(code, qubit, builder, logical_counts, budget);
let estimation = PhysicalResourceEstimation::new(code, qubit, builder, logical_counts);

// In this example, we perform a standard estimation without any further
// constraints.
let result = estimation.estimate().expect("estimation does not fail");
let result = estimation
.estimate(&budget)
.expect("estimation does not fail");

// There is a lot of data contained in the resource estimation result
// object, but in this sample we are only printing the total number of
Expand Down
2 changes: 1 addition & 1 deletion resource_estimator/src/estimates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mod error;
pub use error::Error;
mod error_budget;
pub use error_budget::ErrorBudget;
pub use error_budget::{ErrorBudget, ErrorBudgetStrategy};
mod error_correction;
pub use error_correction::{
CodeWithThresholdAndDistance, CodeWithThresholdAndDistanceEvaluator, ErrorCorrection,
Expand Down
21 changes: 20 additions & 1 deletion resource_estimator/src/estimates/error_budget.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct ErrorBudget {
/// Probability of at least one logical error
logical: f64,
Expand Down Expand Up @@ -36,15 +36,34 @@ impl ErrorBudget {
self.logical
}

pub fn set_logical(&mut self, logical: f64) {
self.logical = logical;
}

/// Get the error budget's tstates.
#[must_use]
pub fn magic_states(&self) -> f64 {
self.magic_states
}

pub fn set_magic_states(&mut self, magic_states: f64) {
self.magic_states = magic_states;
}

/// Get the error budget's rotations.
#[must_use]
pub fn rotations(&self) -> f64 {
self.rotations
}

pub fn set_rotations(&mut self, rotations: f64) {
self.rotations = rotations;
}
}

#[derive(Default, Copy, Clone)]
pub enum ErrorBudgetStrategy {
#[default]
Static,
PruneLogicalAndRotations,
}
7 changes: 6 additions & 1 deletion resource_estimator/src/estimates/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use serde::Serialize;

use super::ErrorBudget;
use super::{ErrorBudget, ErrorBudgetStrategy};

/// Trait to model post-layout logical overhead
pub trait Overhead {
Expand All @@ -23,6 +23,11 @@ pub trait Overhead {
/// The index is used to indicate the type of magic states and must be
/// supported by available factory builders in the physical estimation.
fn num_magic_states(&self, budget: &ErrorBudget, index: usize) -> u64;

/// When implemented, prunes the error budget with respect to the provided
/// strategy
#[allow(unused_variables)]
fn prune_error_budget(&self, budget: &mut ErrorBudget, strategy: ErrorBudgetStrategy) {}
}

/// This is the realized logical overhead after applying an error budget. This
Expand Down
Loading

0 comments on commit 3743568

Please sign in to comment.