n_bits = 3
dev = qml.device('default.qubit', wires = n_bits*2, shots = 10)
@qml.qnode(dev)
def main():
  qml.PauliX(1)
  #qml.QFT(wires = range(n_bits,n_bits*2))
  for i in range(n_bits,n_bits*2):
    qml.Hadamard(i)
  for i in reversed(range(1,n_bits+1)):
    k = 1
    for j in reversed(range(1,i+1)):
      qml.ControlledPhaseShift(np.pi*2/(2**(k)), [n_bits-j,n_bits*2-i])
      k+=1
  qml.adjoint(qml.QFT)(wires = range(n_bits,n_bits*2))
  return qml.sample(wires=range(n_bits,n_bits*2))
res= main(3,2)
print(res)
draw = qml.draw(main)(2,3)
print(draw)
I am working on implementing a Draper Adder in Pennylane and I am having issues. The circuit I have created seems identical to the one in the paper, but I am not getting the correct output. I believe I should get qml.sample to return |010> every time, but I am getting very mixed values. If either register was not classically representing the values, I would understand the problem but I’m not sure what is going on here. Anything would help!
My qml.about():
Name: PennyLane
Version: 0.35.1
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: GitHub - PennyLaneAI/pennylane: PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.
Author:
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane_Lightning
Platform info:           Linux-6.1.58±x86_64-with-glibc2.35
Python version:          3.10.12
Numpy version:           1.25.2
Scipy version:           1.11.4
Installed devices:
- default.clifford (PennyLane-0.35.1)
 - default.gaussian (PennyLane-0.35.1)
 - default.mixed (PennyLane-0.35.1)
 - default.qubit (PennyLane-0.35.1)
 - default.qubit.autograd (PennyLane-0.35.1)
 - default.qubit.jax (PennyLane-0.35.1)
 - default.qubit.legacy (PennyLane-0.35.1)
 - default.qubit.tf (PennyLane-0.35.1)
 - default.qubit.torch (PennyLane-0.35.1)
 - default.qutrit (PennyLane-0.35.1)
 - null.qubit (PennyLane-0.35.1)
 - lightning.qubit (PennyLane_Lightning-0.35.1)
 
Thank you!