-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_design_doc
More file actions
73 lines (60 loc) · 3.23 KB
/
system_design_doc
File metadata and controls
73 lines (60 loc) · 3.23 KB
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
73
## System Design
### Architecture
* Sims contain a list of SubGates
* Each SubGate is a representation of a gate within a Sim
* Each SubGate is associated with a GateContainer and a mapping of the gate inputs to Sim indices
* A GateContainer is a dataclass containing info of a quantum gate (independent of a Sim)
### Relevant Classes
#### Sim
* Describes a quantum register with n_qbits # of qubits
* Quantum gates can be added, turned into SubGates when passed in
* to_gate(): Creates a single black box gate from the Sim
* Matrix multiplication process:
* Does not have a single statevector throughout runtime, multiplying statevector with gates as they are added to modify this statevector
* Instead, there is a single matrix representing all gates added previously, to enable used of to_gate()
* Statevector and probability distribution is calculated each time they are printed
* Currently assumes statevector is initialized with all qubits as |0>
* Options to inspect state of register:
* print_sim(): also the repr, prints a circuit diagram of the Sim, showing gates within
* for control gates, the control and target bits are differentiated
* print_statevector(): prints the current statevector
* print_prob_dist(): prints the current probability distribution based on the statevector
#### GateContainer
* Data class for containing information for a quantum gate
* Gate matrix: Unitary matrix represented by the quantum gate
* Gate label: String used for printouts
* Number of control bits (num_cb): Used for printing and multi-controlled gates
* Expected qubits: Size of gate in qubits
* Independent of any Sim it might be used in
#### SubGate
* Describes a GateContainer within a Sim (dependent on Sim)
* Data includes:
* A gate (GateContainer)
* i_qbits: Which qubit indices of the Sim has the gate been placed on
* n_qbits: Number of qubits in the Sim
* full_mat:
* The gate matrix placed in parallel (kron) with Identity gates
* Calculated after initialization
* Bits are swapped into the correct order indicated by i_qbits
#### Gate
* Function definitions for predefined gates to be used
* Gates can be easily created and added here
* Common gates are hardcoded to avoid unnecessary extra computation
* Some gates have arguments (all are theta right now):
* Phase, rotational, Ising coupling gates
* Modifiers for gates, takes in a gate as an argument, returns modified gate without change:
* Multi-controlled (MC):
* num_cb: number of control bits for gate
* Control bits will be the MSB bits
* Can also get an MC gate of an MC gate
* Multi-targeted (MT):
* num_tb: number of target bits
* Accepts only single bit gates
* Dagger (dg):
* Returns the conjugate transpose of the gate
#### Permute
* Functional class, used for swapping bit order in gate matrices
* Permutation is performed using successive swaps on two bits
* A swap matrix is used to swap the two bits, reordering a specific set of matrix rows/cols
* These swap matrices are preprocessed using memoization
* They are preprocessed for n_qbits up to a max number, if a permutation is needed on a larger matrix, the swap matrices need to be reprocessed