Sending QONN to photonic backend


This is my first message here, then I would like to thank all Xanadu staff for this fantastic library, I am deeply in love with it.

I am fitting a Fano resonance over 20 scattered points I obtained in the lab with SF, I got some good results on fitting with the simulator and I would like to send the code to the photonic backend X8, please can you point me some information about how to measure the outcome? I get an error on the X-gate which is not allowed in the real backend.

Here is my code.

Thank you so much for your help!

Hi @Sergio, welcome to the Forum!

Thank you for your kind words about our libraries. Thank you for using them and sharing your love for them!

I think the problem you’re having is related to the data you’re inputting.

I ran the following code and I got no errors. You should check the dimensions in your data to make sure that whatever goes into the Displacement gate is a single float.

import pennylane as qml
from pennylane import numpy as np

dev = qml.device("", wires=1, cutoff_dim=10)

def layer(v):
    qml.CVNeuralNetLayers(*v, wires=list(range(num_qubits)))
def quantum_neural_net(var, x):
    # Encode input x into quantum state
    for i in range(num_qubits):
        #qml.Rotation(x, wires=i)
        qml.Displacement(x, 0.0, wires=i)

    return qml.expval(qml.X(0))

num_qubits = 1

shapes = qml.CVNeuralNetLayers.shape(n_layers=3, n_wires=num_qubits)
weights = [np.random.random(shape) for shape in shapes]
x = 0.1

quantum_neural_net(weights, x)

Please let me know if this solves your problem, or otherwise please share a minimal version of your code, with an example of your ‘X_data’ after all of the processing that you perform.

Hopefully this helps you solve the problem!

Thanks a lot @CatalinaAlbornoz, indeed I already set a float into Displacement gate, but I will have a look at my code twice to dig in my issue.


Let us know if you find the issue @Sergio!