I am trying to run an execution on IBMQx2 where I can specify the physical qubits to which I apply gates. The execution without the initial_layout
runs fine, but the one with it keeps giving me either "statusCode":400,"name":"Q_OBJECT_NOT_VALID"
or 'Not enough qubits in CouplingGraph'
. Here's the circuit that I use:
qr = QuantumRegister(5, 'q')
cr = ClassicalRegister(5)
qc = QuantumCircuit(qr, cr)
qc.h(qr[0])
qc.h(qr[1])
qc.h(qr[2])
qc.h(qr[3])
qc.h(qr[4])
qc.measure(qr, cr)
coupling_map = [[0, 1], [0, 2], [1, 2], [3, 2], [3, 4], [4, 2]]
layout = {0: qr[0], 1: qr[1], 2: qr[2], 3: qr[3], 4: qr[4]}
#layout = {('qr', 0): ('q', 0), ('qr', 1): ('q', 1), ('qr', 2): ('q', 2), ('qr', 3): ('q', 3), ('qr', 4): ('q', 4)}
job_exp = execute(qc, backend=backend, coupling_map=coupling_map, initial_layout=layout, shots=16384)
If I use the first layout, it gives me,
JobError: "{'statusCode': 400, 'name': 'Q_OBJECT_NOT_VALID', 'message': 'Q-Object not valid.', 'code': 'Q_OBJECT_NOT_VALID'}"
which I think may be caused by deprecated syntax or something, so I went on here to find what I hope is a more updated version of initial_layout
. It got worse: this seems to be even older, and with it another error,
TranspilerError: 'Not enough qubits in CouplingGraph'`
The problem persists whether I add coupling_map
in or not. Can anyone tell me how to fix this? Thank you!