Download presentation
Presentation is loading. Please wait.
1
Classical and Quantum Circuit Synthesis An Algorithmic Approach
2
Problem How do we synthesize efficient n-input quantum circuits using CNOT gates only ? Of the n! possible n-qubit permutations, how many can be implemented in this way? What is the longest such circuit? How can long chains of CNOTs be systematically reduced?
3
Goals Way to synthesize quantum circuits Currently, reducing chains of C-Not gates is important More complex circuits (with Toffoli gates, etc...) Larger circuits (more qubits, more gates, etc...)
4
Reducing C-Nots Want to minimize error Need an algorithmic approach Classical circuit approach discrete reversible case
5
wire 0: -------X--O-----X--X--O- wire 1: -O--X-----X--O--O-----X- wire 2: -X--O--O-----X-----O---- Reduces to: wire 0: -O- wire 1: --- wire 2: -X- Example
6
Classical program goals Synthesize optimal classical circuits Provides method for creating reduced chains of C-Not gates Scalable As many inputs/outputs as necessary Versatile Use various gate libraries (AND, OR, NOT, etc...)
7
Refresher – Truth Tables XYZ=X^Y 000 010 100 111 AND gate (Columnar format) These can be represented in row format as well: X = 0011 -> 3 Y = 0101 -> 5 -------- Z = 0001 -> 1 (3^5)==1
8
How to Synthesize? Inputs X = 0011 Y = 0101 Desired result Z = 0110 ?
9
How to Synthesize? Inputs X = 0011 Y = 0101 Desired result Z = 0110 Gate Library: AND, OR, NAND
10
Tree Structure Solution space representable as a tree Inputs at head of tree Each level down represents addition of new gate Branch factor depends on number of current gates and allowable new gates
11
Inputs X, Y A=X*YA=X+Y B=X*YB=X+YB=X*AB=X+AB=Y*AB=Y+A Level 1 Level 2(Same as left) If we have N inputs (N=2 here) G gate types (G=2, we have AND and OR) Then at level L we have a branch factor of B = G * (N+L-1, 2) / 2
12
Branch and Bound Depth-first search First do top bottom, then left right Travel down to leaves before going to siblings Can be implemented by a recursive function, passing L+1 with each call
13
DFS Branch & Bound
18
B&B Synthesis Inputs X = 0011 Y = 0101 Desired result Z = 0110 A=X*X=0011
19
B&B Synthesis Inputs X = 0011 Y = 0101 Desired result Z = 0110 A=X*X=0011B=X*X=0011
20
B&B Synthesis Inputs X = 0011 Y = 0101 Desired result Z = 0110 A=X*X=0011B=X*X=0011 C=X*X=0011 C=X+X=0011 C=(X*X)’=1100 C=X*Y=0001...
21
B&B Synthesis Inputs X = 0011 Y = 0101 Desired result Z = 0110 A=X*X=0011B=X+X=0011 C=X*X=0011 C=X+X=0011 C=(X*X)’=1100 C=X*Y=0001...
22
B&B Synthesis Inputs X = 0011 Y = 0101 Desired result Z = 0110 A=X*X=0011B=(X*X)’=0011 C=X*X=0011 C=X+X=0011 C=(X*X)’=1100 C=X*Y=0001...
23
Solution Found! Inputs X = 0011 Y = 0101 Desired result Z = 0110 A=X+Y=0111B=(X*Y)’=1110C=A*B=0110
25
Bounding Conditions Branch factor unnecessarily large Need bounding conditions Don’t need duplicate gates (A=X*X,B=X*X) Symmetrical gates done only once Don’t need X*Y, then Y*X Symmetrical branches of solution space can be bounded away Optimality requirement creates a bound
26
Optimality Bounding Current circuit Assume we are only allowed one more gate This gate cannot use all three level-two gates as inputs If added, two of the level-two gates would be used, one would be left dangling No reason to add a gate, bound now
27
Don’t-cares Suppose we are interested in only part of the output. Say Z=0110 and Z=0111 are both desirable outputs. We don’t care about the last bit. Can represent output as Z = 011X This relaxed restriction allows us to find a suitable match more quickly Quantum circuits can also have don’t-cares, but they are different than classical ones.
28
Multiple Outputs We may desire more than one output Ex: Half adder. Has two bits as input, two bits as output (sum, carry) Optimal multi-output circuit may be different than circuit created by merging the individual optimal ones. Causes an approximately linear increase in synthesis time.
29
Reversible Synthesis To maintain reversibility, must have same number of qubits at every stage Fan out must be 1, so there is no expansion in the number of gates at any stage Both the input/output functions and all the gates must be reversible
30
Compact Representation (Revisited) For a three qubit function, our inputs (A, B, C) will have these values: ABCV 0000 0011 0102 0113 1004 1015 1106 1117 A = 00001111 = 15 B = 00110011 = 51 C = 01010101 = 85
31
Permutation Representation We want to synthesize the outputs A’, B’, and C’ from the inputs A, B, and C ABCV 0000 0011 0102 0113 1004 1015 1106 1117 A’B’C’V 1004 0102 1106 1117 0113 0000 1015 0011 To be reversible, all of the values of V must be distinct. This allows us to treat the outputs as permutations of the inputs.
32
Permutation Representation ABCV 0000 0011 0102 0113 1004 1015 1106 1117 155185 A’B’C’V’ 1004 0102 1106 1117 0113 0000 1015 0011 17812027 So the problem: (15,51,85)->(178,120,27) Can be expressed as: 01234567 -> 42673051
33
Simplified Circuit Representation A B C A’ B’ C’ (A, B) (B, C)
34
Simplified Circuit Representation A B C A’ B’ C’ A1 B1 C1 A2 C2 B2 (A, B) (B, C)
35
ABCV 0000 0011 0102 0113 1004 1015 1106 1117 A1B1C1V1 0000 0011 0102 0113 1106 1117 1004 1015 (A, B) (B, C) A2B2C2V2 0000 0011 0113 0102 1117 1106 1004 1015 A’B’C’V’ 0000 0011 0113 0102 1117 1106 1004 1015
36
Results Question: given a 3-Qubit system, what is the longest possible irreducible chain of C-Nots? Note that some longest chain *must* exist because there are finitely many (8!) permutations.
37
Bounding At each stage, we store the value on each wire. If all wire values are the same, bound If two gates can be permuted w/o affecting the circuit, only try one of them -O-O- -X--- = ---X- ---X- -X---
38
Answer Longest chains: wire 0: --O--X--O----------- wire 1: -----------X--O--X-- wire 2: --X--O--X--O--X--O-- AND wire 0: -----------X--O--X-- wire 1: --O--X--O----------- wire 2: --X--O--X--O--X--O--
39
Why? Recall that C-Nots act like XOR gates. That is, |x>|y> |x>|x XOR y> What does this code do? A = A xor B B = A xor B A = A xor B This is a variable swap. The chains on the previous page represent wire swaps.
40
How many C-Nots? Experimental results: Of the 40320 (=8!) permutations, exactly 168 are achievable. 2 of them require 6 C-Not gates 24 require 5 60 require 4 51 require 3 24 require 2 (6 * 6 - duplicates) 6 require 1 (3 control choices * 2 targets) 1 requires 0
41
Why only 168? Not all of the 8! permutations are achievable The permutation must be even. Recall every C-Not caused two pairs of values to be swapped Exactly half of the 8! permutations are even Various other factors reduce this more
42
Parity of a Permutation The number of line crossings determines the parity of a permutation. There are four in this case, and so the permutation is even.
43
Future Plans... Make Program: More scalable Currently using 32-bit integers to store wire values. 2^5 = 32; only 5 wires at a time now. More versatile Currently only using C-Not gates. Allow n-input Toffoli gates, other gates Quicker Determine methods for bounding better, exploit characteristics of quantum circuits.
44
Potential improvements Scalability Use STL bit_vector, or bit_set... fully expandable Speed Since all the gates and the functions are reversible, the whole circuit is too. Functions can be synthesized in reverse
45
Reversible Synthesis Recall that C-Not acts like XOR C-Not is its own inverse (going left to right is same as right to left) Synthesis can be done right left We already know how to achieve the input values with several gates, because we’ve done this left right before This allows us to have a LUT when we get near enough to the inputs
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.