Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions resource_estimator/src/estimates/error_correction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ pub trait ErrorCorrection {
.ok_or_else(|| format!("No code parameter achieves required logical error rate {required_logical_error_rate:.3e}"))
}

/// Adjusts code parameter after computing it
///
/// This function is called after the initial code parameter has been
/// computed. The initial code parameter will fit the required logical
/// error rate, but it's possible to further refine it, if necessary.
///
/// Note, that when implementing the `ErrorCorrection` trait and providing a
/// custom implementation for this function, it may return a code parameter
/// that will not fit the required logical error rate any longer.
///
/// The default implementation does not update the code parameter.
fn adjust_code_parameter(&self, parameter: Self::Parameter) -> Result<Self::Parameter, String> {
// Default implementation does not update the code parameter
Ok(parameter)
}

/// Returns an iterator of all possible code parameters
///
/// Implementors of this method should sort the code parameters such that
Expand Down
7 changes: 6 additions & 1 deletion resource_estimator/src/estimates/physical_estimation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,13 @@ impl<

/// Computes the code parameter for the required logical error rate
fn compute_code_parameter(&self, error_rate: f64) -> Result<E::Parameter, Error> {
self.ftp
let parameter = self
.ftp
.compute_code_parameter(&self.qubit, error_rate)
.map_err(Error::CodeParameterComputationFailed)?;

self.ftp
.adjust_code_parameter(parameter)
.map_err(Error::CodeParameterComputationFailed)
}

Expand Down