0
$\begingroup$

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!

$\endgroup$
1

1 Answer 1

3
$\begingroup$

The Q-Object not valid error you received is caused by the amount of shots you set. The max shots allowed is 8192. Since the amount of shots you set (16384) is greater than the max amount of shots allowed, you get that error.

The TranspilerError is caused by the second format for layout. When I tested your code with the second layout, I received this error and a warning stating that the format being used for initial_layout was being deprecated. So I would stick to the first format for layout.

If you change the amount of shots to be <=8192 and use the first format for layout, then I believe the code should run.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.