Max number of qubits in Qnode

Hello, i use this qnode on a hybrid keras model

@qml.qnode(dev, interface="tf", grad_method="backprop")
def qnode(inputs, weights):
    for i in range(blocks):
        qml.templates.AngleEmbedding(inputs, wires=range(n_qubits))
        qml.templates.StronglyEntanglingLayers(weights[i], wires=range(n_qubits)) 
    return [qml.expval(qml.PauliZ(i)) for i in range(n_qubits)]

Is there a limitation on the number n_qubits? for example when i set it to 20 the kernel dies, Is this internal or due to insufficient memory of my pc? Thanks!

(p.s. would it make sense to use two qnodes with 10 qubits in parallel? )

So in quantum computing, the effective size of your simulation doubles with every qubit you simulate, so 10 qubits takes 2 ** 10 complex numbers, and 20 qubits takes 2 ** 20 complex numbers. Using the grad_method="backprop" will also increase your memory usage linearly with each gate you add, as default backprop will store each wavefunction output after every gate.

(p.s. would it make sense to use two qnodes with 10 qubits in parallel? )

You could try this, but it won’t have the same “power” as doing a 20 qubit simulation.

1 Like