forked from microsoft/qsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_logical_counts.rs
72 lines (59 loc) · 2.79 KB
/
basic_logical_counts.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::cast_precision_loss)]
// This example illustrates how to use the Resource Estimator crate to perform a
// standard resource estimation on top of the qubit and QEC models provided by
// the systems architecture that we ship. We are using logical resource counts
// to compute the post-layout logical overhead based on the PSSPC layout method
// as described in [https://arxiv.org/abs/2211.07629].
use std::rc::Rc;
use resource_estimator::{
estimates::{ErrorBudget, PhysicalResourceEstimation},
system::{floquet_code, LogicalResourceCounts, PhysicalQubit, TFactoryBuilder},
};
fn main() {
// There are 5 ingredients that we need to perform resource estimation.
// 1) A quantum error correction code; in this example we are using a
// Floquet code.
let code = floquet_code();
// 2) A qubit model; in this example we are using a Majorana type qubit
// using a physical error rate of 1e-6.
let qubit = Rc::new(PhysicalQubit::qubit_maj_ns_e6());
// 3) A factory builder to provide magic states; in this example we are
// using a T factory builder that can create T factories using multiple
// distillation rounds.
let builder = TFactoryBuilder::default();
// 4) The logical resource overhead; in this example we are using logical
// resource counts that compute the logical post-layout overhead based on
// the PSSPC algorithm.
let logical_counts = Rc::new(LogicalResourceCounts {
num_qubits: 100,
t_count: 10,
rotation_count: 10,
rotation_depth: 5,
ccz_count: 100,
ccix_count: 0,
measurement_count: 10,
});
// 5) An error budget; in this example we are using a uniform error budget
// of 0.1% distributed uniformly among logical errors, rotation synthesis
// errors, and T state production errors.
let budget = ErrorBudget::from_uniform(0.001);
// 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);
// In this example, we perform a standard estimation without any further
// constraints.
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
// physical qubits and the runtime in seconds (the value is returned in nano
// seconds).
println!("Number of physical qubits: {}", result.physical_qubits());
println!(
"Runtime: {:.2e} secs",
result.runtime() as f64 / 1e9
);
}