Skip to content

Commit

Permalink
Error budget pruning strategy in resource estimator core (#1951)
Browse files Browse the repository at this point in the history
Resource estimation takes as input an error budget. This is a triplet of
budget contribution to logical errors, rotation synthesis errors, and
magic state distillation errors. The user can either specify each of
these three values separately or provide a total value that is uniformly
distributed among the three parts. So far, RE does not modify these
provided values.

This PR implements a pruning strategy for the error budget that will
decrease the budget for logical errors and rotation synthesis errors
(without affecting the estimation), while increasing the budget for
magic state distillation errors in order to reduce the resources
required for factories.

For logical errors, we can reduce the budget by finding the largest
value that still leads to the same code parameter (e.g., code distance).
Similarly, for synthesis errors, we can reduce the budget by finding the
largest value that still leads to the same number of magic states. The
latter is layout dependent, and therefore a new function is added to the
`Overhead` trait. The function has an empty default implementation, and
therefore does not break existing layout implementations.

The strategy needs to be explicitly set for the resource estimation and
only works for a resource estimation without any other constraints
(e.g., maximum number of qubits or duration), and does not work for
frontier based estimation. There is no job parameter yet to enable the
behavior.
  • Loading branch information
msoeken authored Oct 9, 2024
1 parent 0261bf6 commit 3195043
Show file tree
Hide file tree
Showing 11 changed files with 308 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 3195043

Please sign in to comment.