pennylane icon indicating copy to clipboard operation
pennylane copied to clipboard

[BUG] `validate device wires`

Open Canoming opened this issue 5 months ago • 1 comments

Expected behavior

The default_qubit device should work with alternating regular gates and QAOA layers

Actual behavior

When the circuit includes both regular gates and QAOA layers, the wires of the layers may be converted to a tensor. This will fail the validate_device_wires method in the runtime check. set(wires) in validate_device_wires cannot convert it to a set.

Additional information

No response

Source code

n_nires = 4
dev = qml.device('default.qubit',wires = n_wires)
@qml.qnode(dev)
def circuit(params):
    for i in range(n_wires):
        qml.Hadamard(wires=i)
    for j in range(depth): 
        qaoa.cost_layer(params[j][0],cost_h)
        qaoa.mixer_layer(params[j][1],mixer_h)
    return qml.expval(cost_h)

# It raises error if the `circuit` is called

Tracebacks

No response

System information

Cannot run circuit(s) on default.qubit as they contain wires not found on the device: {0, 1, 2, 3}

Existing GitHub issues

  • [X] I have searched existing GitHub issues to make sure the issue does not already exist.

Canoming avatar Aug 29 '24 14:08 Canoming