Skip to content

Commit

Permalink
fix(remote): Block non QuantumCircuit experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxence Drutel committed Apr 24, 2024
1 parent 844e442 commit ecfd505
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qiskit_alice_bob_provider/remote/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ def run(self, run_input: QuantumCircuit, **kwargs) -> AliceBobRemoteJob:
Wait for the results by calling
:func:`AliceBobRemoteJob.result`.
"""
if not isinstance(run_input, QuantumCircuit):
# Qiskit's execute() allows also for list[QuantumCircuit],
# Schedule and list[Schedule] as inputs. These types of experiments
# are not yet handled by the provider.
raise NotImplementedError(
'Experiments input not supported by the Alice & Bob provider. '
'Please provide an instance of QuantumCircuit.'
)
if self._verbose:
write_current_line('Sending circuit to the API...')
options = self.update_options(kwargs)
Expand Down
16 changes: 16 additions & 0 deletions tests/remote/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import pytest
from qiskit import QiskitError, QuantumCircuit, execute, transpile
from qiskit.providers import Options
from qiskit.pulse.schedule import Schedule
from qiskit.result import Result
from qiskit.transpiler.exceptions import TranspilerError
from requests_mock.mocker import Mocker
Expand Down Expand Up @@ -92,6 +93,21 @@ def test_too_many_qubits_clients_side(mocked_targets) -> None:
execute(c, backend)


def test_input_not_quantum_circuit(mocked_targets) -> None:
c1 = QuantumCircuit(1, 1)
c2 = QuantumCircuit(1, 1)
s1 = Schedule()
s2 = Schedule()
provider = AliceBobRemoteProvider(api_key='foo')
backend = provider.get_backend('EMU:1Q:LESCANNE_2020')
with pytest.raises(NotImplementedError):
execute([c1, c2], backend)
with pytest.raises(NotImplementedError):
execute(s1, backend)
with pytest.raises(NotImplementedError):
execute([s1, s2], backend)


def test_counts_ordering(successful_job: Mocker) -> None:
c = QuantumCircuit(1, 2)
c.initialize('+', 0)
Expand Down

0 comments on commit ecfd505

Please sign in to comment.