Quantum Convolutional Neural Network implementation

Hi, I’m trying to implement QCNN in Pennylane and ran into a problem.

Given a circuit with n qubits, QCNN requires us to measure n/2 of the wires at first pooling layer, n/4 wires at second pooling layer and so on. The output of these measurements are used as parameters in rotation gates applied to the n/2 remaining wires after first pooling layer, n/4 remaining wires after the second pooling layer etc.

Now suppose we have 4 qubits. I tried to perform a measurement on the 0th and 2nd qubits, and then add RY gates to the 1st and 3rd qubits. Unfortunately, I got the error:

ValueError: Quantum operation RY(tensor(0.95956891, requires_grad=True), wires=[1]) must occur prior to any measurements.

Given this discussion (Ancillary Subsystem Measurement then Trace Out) a few months ago and my findings, it appears that such operation is not supported, therefore QCNN is impossible to be implemented in Pennylane. Am I correct? Are there any plans to add support for mid-circuit measurement in the near future?

Hi @karolishp, mid-circuit measurements were just added to PennyLane in the latest release! :smiley:

Be sure to upgrade to version 0.22 in order to use this feature. You can learn more about how to use these measurements on our release blog post.

Let me know if you have any further questions!