- (20 points)
Let's create the 1-bit full adder in QMI.
- First form the QUBO for the full-adder.
- Obtain the weights and strengths of all qubits and their
connections using the Quantum Apprentice spreadsheet.
- Perform the embedding on to the bi-partite graph
and then encode it fadd.q (QUBO terms) and fadd.e (embedding).
Turn in file fadd.bash, fadd.q, fadd.e
- (20 points)
Combine the half and full adders to create a 2-bit adder QUBO.
- Look at the half-adder program from HW1
- Fuse both embeddings into one to create a 2 bit
adder (see embedding slide mentioned in HW2)
Turn in file add2.bash, add2.q, add2.e
- (10 points)
Let's create the 1-bit full adder from
slide 41 on
Quirk with inputs c0, a0, b0
and outputs s0 and c1.
Hints:
- Watch the tutorial.
- Create the adder circuit by just dropping down X gates (marked
as "cross", right below the Y gate) and adding one or two control
probes (solid dot) for C-Not and Hadamard gates, respectively.
- Put a Sample box on the inputs (left).
- Test your circuit by verifying that inputs/outputs are
correct. You can change inputs by putting one or more X gates on
Qbit input lines (very left, left of the sample box), and then
watch the output.
- Label inputs and outputs. You can do this by creating a
labeled gate for each symbol, i.e., click: make gate, from matrix
"{{1,0},{0,1}}" circuit symbol "c0", create. Place it on the c0 input
line, etc. for a0/b0/s0/c1.
- Export your solution as a URL (copy clipboard) in the file
adder.txt.
Turn in file adder.txt
- (15 points)
Combine two adders to create a 2-bit adder in Quirk with inputs c0, a0, a1,
b0, b1 and outputs s0, s1, and c2. Make sure to label inputs/outputs.
Turn in file doubleadder.txt
- (15 points) Create a Toffoli gate in Quirk from basic gates by
modifying
this
solution. We now try
construct Toffoli variation. Start with the given circuit but
substitute gates as follows:
- T is Z^1/8
- T-dagger is Z^-1/8
- S is Z
- add a Sample on the inputs
- try to add one more gate, X^1/2, in the right place with the
right wiring (controls)
- try out all input combinations to verify output
Turn in file toffoli2.txt
- (20 points) Test drive the
IBM Quantum
Experience and create a Toffoli equivalent circuit.
Hints:
- Sign up for an account (free).
- Open the composer, choose some machine, e.g., ibmqx4 (5 qubits).
- Create a Toffoli circuit from this
solution, i.e., by directly using the indicated gates on IBM Q.
- Set both controls to 1 (using X gates).
- Simulate a run, print out the result and capture the qasm
code. Your output should be 111 on the 3 Qubits.
- Run on the real machine. After you hit the run button, you
will have to wait for an email (several minutes in my case)
reporting the outcome. Your output should be 111 on the 3
Qubits with a higher probability (0.572 for me). This is your
first program running on a real quantum computer!!!
- Remove your X gates and instead place Hadamards as the first
gate for each of the 3 qubits. Simulate and explain the
output (in the txt file). Repeat on the real machine.
Turn in file toffoli.pdf, toffoli.qasm and toffoli.txt.