microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.18.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/resource_estimator/src/estimates/factory.rs

60lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use std::{borrow::Cow, rc::Rc};
5
6use crate::estimates::ErrorCorrection;
7
8/// Helper structs when dispatching multiple magic states to different factories
9mod dispatch;
10pub use dispatch::{BuilderDispatch2, FactoryDispatch2};
11
12/// Helper structs for when no factories are used
13mod empty;
14pub use empty::NoFactories;
15
16/// Generic factory model based on multiple rounds of distillation
17mod round_based;
18pub use round_based::{
19 DistillationRound, DistillationUnit, FactoryBuildError, PhysicalQubitCalculation,
20 RoundBasedFactory,
21};
22
23pub trait FactoryBuilder<E: ErrorCorrection>
24where
25 Self::Factory: Clone,
26{
27 type Factory;
28
29 fn find_factories(
30 &self,
31 ftp: &E,
32 qubit: &Rc<E::Qubit>,
33 magic_state_type: usize,
34 output_error_rate: f64,
35 max_code_parameter: &E::Parameter,
36 ) -> Result<Vec<Cow<Self::Factory>>, String>;
37
38 fn num_magic_state_types(&self) -> usize {
39 1
40 }
41}
42
43pub trait Factory
44where
45 Self::Parameter: Clone,
46{
47 type Parameter;
48
49 fn physical_qubits(&self) -> u64;
50 fn duration(&self) -> u64;
51 /// The number of magic states produced by the factory
52 fn num_output_states(&self) -> u64;
53 fn normalized_volume(&self) -> f64 {
54 ((self.physical_qubits() * self.duration()) as f64) / (self.num_output_states() as f64)
55 }
56 /// The maximum code parameter setting for a magic state factory. This is
57 /// used to constrain the search space, when looking for magic state
58 /// factories.
59 fn max_code_parameter(&self) -> Option<Cow<Self::Parameter>>;
60}