GCC Code Coverage Report


Directory: ./
File: Characterisation/include/Characterisation/DeviceCharacterisation.hpp
Date: 2022-10-15 05:10:18
Exec Total Coverage
Lines: 0 12 0.0%
Functions: 0 2 0.0%
Branches: 0 10 0.0%
Decisions: 0 0 -%

Line Branch Decision Exec Source
1 // Copyright 2019-2022 Cambridge Quantum Computing
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #pragma once
16
17 #include <map>
18 #include <nlohmann/json.hpp>
19
20 #include "Architecture/Architecture.hpp"
21 #include "ErrorTypes.hpp"
22 #include "OpType/OpType.hpp"
23 #include "Utils/UnitID.hpp"
24
25 /**
26 * Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in
27 * commute_SQ_gates_through_SWAPS as a simple device noise model.
28 * This is just a container of errors.
29 *
30 * This supports single-qubit errors, two-qubit errors and readout errors.
31 * Errors can either be OpType-specific, or a default value (average over all
32 * possible OpTypes) If an OpType-specific value is provided, this will be used.
33 * If not it will fallback to the default value for the given Node or Node pair,
34 * which itself falls back to zero error.
35 */
36
37 namespace tket {
38
39 class DeviceCharacterisation {
40 public:
41 DeviceCharacterisation(
42 avg_node_errors_t _node_errors = {}, avg_link_errors_t _link_errors = {},
43 avg_readout_errors_t _readout_errors = {})
44 : default_node_errors_(_node_errors),
45 default_link_errors_(_link_errors),
46 default_readout_errors_(_readout_errors),
47 op_node_errors_(),
48 op_link_errors_() {}
49 explicit DeviceCharacterisation(
50 op_node_errors_t _node_errors, op_link_errors_t _link_errors = {},
51 avg_readout_errors_t _readout_errors = {})
52 : default_node_errors_(),
53 default_link_errors_(),
54 default_readout_errors_(_readout_errors),
55 op_node_errors_(_node_errors),
56 op_link_errors_(_link_errors) {}
57
58 // get device gate errors, preferring OpType-specific over default values over
59 // 0. error
60 // single-qubit case
61 gate_error_t get_error(const Node& n) const;
62 gate_error_t get_error(const Node& n, const OpType& op) const;
63 // two-qubit case
64 gate_error_t get_error(const Architecture::Connection& link) const;
65 gate_error_t get_error(
66 const Architecture::Connection& link, const OpType& op) const;
67 // readout errors
68 readout_error_t get_readout_error(const Node& n) const;
69
70 bool operator==(const DeviceCharacterisation& other) const;
71
72 friend void to_json(nlohmann::json& j, const DeviceCharacterisation& dc);
73 friend void from_json(const nlohmann::json& j, DeviceCharacterisation& dc);
74
75 private:
76 // default errors per Node
77 avg_node_errors_t default_node_errors_;
78 avg_link_errors_t default_link_errors_;
79 avg_readout_errors_t default_readout_errors_;
80
81 // OpType-specific errors per Node
82 op_node_errors_t op_node_errors_;
83 op_link_errors_t op_link_errors_;
84 };
85
86 JSON_DECL(DeviceCharacterisation)
87
88 } // namespace tket
89