Homework 1
Important: Write Names and Unity IDs on every submission file. Name the submission file correctly as asked for.
- (0 points)
Get a D-Wave account, download and install D-Wave Ocean as follows:
- (15 points, 5+15) Similar to the example with the 3-qubit
solution of Lecture 3, slide
13, create an OR relation:
- Create a solution in the
Quantum Apprentice spreadsheet with the correct
weights and strengths in the 3-qubit tab. Hint: It's already given
in the slide referenced above.
- Create a 4-qubit embedding in the corresponding tab of the same
spreadsheet, but ensure that q1-q4 and q2-q3 connections remain
unused (weight 0). This reflects the bipartite graph that has no
connections between these qubits on Dwave's machine. Ask yourself:
- How do you replicate a qubit in terms of weight and strengths?
- How do you connect the replicated qubits using the "equal"
relation?
The solution should have 4 ground states (lowest energy in blue)
for the same qubit combinations as in the 3-qubit solution, higher
energy states are results that are not considered (as the truth),
i.e., notice that we ignore duplicate (input) states with a higher
energy (output state). Remember: The analogy to input/output
states is misleading, this is only a mental bridge to classical
circuits for us. (There is no input/output, just an
equation/relation/state that we observe and interpret, usually in
classical terms.)
Turn in a screen shot of both tabs of spreadsheet as file or.pdf
- (30 points, 15 each)
Create an Ocean program for the OR relation in simulation and on actual hardware.
- Start with the simulated AND solution (slide 27). Modify it to reflect the
3-qubit Qubo from the previous problem. Make sure it runs and
outputs the correct answers with lowest energy. Annotate the
output as a comment (see AND solution).
- Start with the hardware AND solution (slide 28). Modify it to reflect the
4-qubit Qubo from the previous problem. Make sure it runs and
outputs the correct answers with lowest energy. Annotate the output
as a comment (see AND solution).
Turn in files or-sim.py and or-hw.py
- (20 points) Generalize D-Wave's factoring example to return 4-bit
factors.
D-Wave
factoring tutorial provides a rough idea of the problem.
The Jupiter Notebook
(Factoring Example) gives more details.
- Download the
factoring
example:
git clone https://github.com/dwavesystems/demos.git
cd demos/factoring
git clone https://github.com/dwavesystems/factoring-demo.git
cd factoring-demo
- Consult the following files:
demo.py
factoring/interfaces.py
https://github.com/dwavesystems/dwavebinarycsp/blob/master/dwavebinarycsp/factories/csp/circuits.py
and read the
factoring
paper, which explains how to express factoring as a binary CSP.
- Test demo.py and interfaces.py to factor the number 42:
python demo.py
- Verify that your results are correct. Notice that only 3-bit
factors are being considered.
- Modify demo.py and factoring/interfaces.py to use 4
bits for each factor and 8 bits for the product. Then factor
the number 42 again.
- Verify that your results are correct, i.e., you should now see
4-bit factors as well (every now and then, you may have to run repeatedly).
- Hints:
- Change the number of reads to 2000 (more than 50 samples needed)
- Change the output to be 8 bits (p0..p7) and inputs to be 4
bits (a0..a3, b0..b3).
- Change the multiplication_circuit to operate on 4 bits.
- Modify demo.py to invoke factor with a 2nd parameter of False to
indicate that no prior embedding exists.
- Change the chain strength in dimod.embed_bqm() to
3.55. This works best based on trail and error.
- Augment the sample output to include a new field
'energy'. Notice: Without this energy field, you may not see
the correct output, which are the values with lowest energy.
Turn in files demo.py and interfaces.py
- (15 points) In Lecture 4, slide
17, there are errors in the XOR hamiltonian. The ground sets,
indicated in green in the previous slide for a possible solution
with an ancilla bit, are correct. Construct a correct XOR hamiltonian
assuming qubits to be either in state 0 or 1 (Notice: the XOR slides
are assuming a state -1 and +1!!!) by
- writing down the constraints for your target ground states and
then all other states,
- reducing these constraints where possible,
- trying to find the correct values (by trial and error or
systematically, up to you), and
- verifying your solution in the Quantum Apprentice
spreadsheet.
Submit xor.pdf, the snapshot of the Quantum Apprentice spreadsheet.
- (20 points) Proof that there is no solution of XOR with only 3
qubits.
Submit proof.pdf