Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBMQEmulatorBackend and IBMQBackend don't properly enforce MaxNQubitsPredicate #93

Open
CalMacCQ opened this issue Mar 24, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Mar 24, 2023

If I ask IBMQBackend and IBMQEmulatorBackend which predicates they require with Backend.required_predicates I get the following...

[NoFastFeedforwardPredicate,
 NoSymbolsPredicate,
 GateSetPredicate:{ Rz noop Reset X SX Barrier CX Measure }]

I would've expected MaxNQubitsPredicate to appear on this list.

As its not enforced I can run a 7 qubit circuit on a 5 qubit emulator which shouldn't be possible.

from pytket import Circuit
from pytket.extensions.qiskit import IBMQEmulatorBackend

backend = IBMQEmulatorBackend('ibmq_belem') # Backend is supposed to only support 5 qubits

# Define a 7 qubit circuit that is already in the IBM gateset: {X, SX, CX, Rz} - no compilation needed
circ = Circuit(7).X(0).CX(0, 1).CX(0, 2).CX(0, 3).CX(0, 4).CX(0, 5).CX(0, 6).measure_all() 

result = backend.run_circuit(circ, n_shots=100)
print(result.get_counts) # get some length 7 bitstrings back from the simulator (shouldn't be possible)

However if I compile the circuit first with Backend.get_compiled_circuit an error message is thrown saying the circuit does not respect the MaxNQubitsPredicate. I'm not sure how this is enforced as it does not appear in Backend.required_predicates.

@CalMacCQ CalMacCQ added the bug Something isn't working label Mar 24, 2023
@CalMacCQ
Copy link
Contributor Author

CalMacCQ commented Mar 27, 2023

@cqc-alec @cqc-melf

Once #94 is merged can we consider this issue to be resolved? Or should we also be concerned that the only thing stopping a 7 qubit job running on a 5 qubit emulator is the MaxNQubitsPredicate on the pytket side?

@cqc-alec
Copy link
Collaborator

@cqc-alec @cqc-melf

Once #94 is merged can we consider this issue to be resolved? Or should we also be concerned that the only thing stopping a 7 qubit job running on a 5 qubit emulator is the MaxNQubitsPredicate on the pytket side?

I think we can close this issue, but I'd still like to understand why the qiskit runtime didn't balk at the circuit. So I think I will open another issue for that.

@cqc-alec
Copy link
Collaborator

On second thoughts -- let's leave this issue open to track that, since the description is still accurate. With no compilation, a 7=qubit circuit seems to run on a 5-qubit backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants