From e689aec00aa828a5d8dacd4d9931755419c09ea7 Mon Sep 17 00:00:00 2001 From: Melf Date: Mon, 4 Mar 2024 10:21:09 +0000 Subject: [PATCH] remove testcases, solve some issues --- tests/conftest.py | 9 +++++++++ tests/qiskit_backend_test.py | 31 ++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index af296a10..0e8bd6d0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -73,6 +73,15 @@ def brisbane_emulator_backend() -> IBMQEmulatorBackend: ) +@pytest.fixture(scope="module") +def ibmq_qasm_emulator_backend() -> IBMQEmulatorBackend: + return IBMQEmulatorBackend( + "ibmq_qasm_simulator", + instance="ibm-q/open/main", + token=os.getenv("PYTKET_REMOTE_QISKIT_TOKEN"), + ) + + @pytest.fixture(scope="module") def nairobi_emulator_backend() -> IBMQEmulatorBackend: return IBMQEmulatorBackend( diff --git a/tests/qiskit_backend_test.py b/tests/qiskit_backend_test.py index 26574934..978e1876 100644 --- a/tests/qiskit_backend_test.py +++ b/tests/qiskit_backend_test.py @@ -23,7 +23,8 @@ from qiskit.providers import JobStatus # type: ignore from qiskit_algorithms import Grover, AmplificationProblem, AlgorithmError # type: ignore from qiskit_aer import Aer # type: ignore - +from qiskit import QuantumCircuit # type: ignore +from qiskit_ibm_runtime import QiskitRuntimeService, Session, Sampler # type: ignore from qiskit_ibm_provider import IBMProvider # type: ignore from pytket.extensions.qiskit import ( @@ -112,15 +113,17 @@ def test_cancel() -> None: assert job.status() in [JobStatus.CANCELLED, JobStatus.DONE] +# https://github.com/CQCL/pytket-qiskit/issues/272 +@pytest.mark.xfail(reason="Qiskit sampler not working") @pytest.mark.skipif(skip_remote_tests, reason=REASON) -def test_qiskit_counts(nairobi_emulator_backend: IBMQEmulatorBackend) -> None: +def test_qiskit_counts(ibmq_qasm_emulator_backend: IBMQEmulatorBackend) -> None: num_qubits = 2 qc = QuantumCircuit(num_qubits) qc.h(0) qc.cx(0, 1) qc.measure_all() - s = BackendSampler(TketBackend(nairobi_emulator_backend)) + s = BackendSampler(TketBackend(ibmq_qasm_emulator_backend)) job = s.run([qc], shots=10) res = job.result() @@ -129,6 +132,28 @@ def test_qiskit_counts(nairobi_emulator_backend: IBMQEmulatorBackend) -> None: assert all(n in range(4) for n in res.quasi_dists[0].keys()) +# https://github.com/CQCL/pytket-qiskit/issues/272 +@pytest.mark.xfail(reason="Qiskit sampler not working") +@pytest.mark.skipif(skip_remote_tests, reason=REASON) +def test_qiskit_counts_0() -> None: + num_qubits = 32 + qc = QuantumCircuit(num_qubits) + qc.h(0) + qc.cx(0, 1) + qc.measure_all() + + _service = QiskitRuntimeService( + channel="ibm_quantum", + instance="ibm-q/open/main", + token=os.getenv("PYTKET_REMOTE_QISKIT_TOKEN"), + ) + _session = Session(service=_service, backend="ibmq_qasm_simulator") + + sampler = Sampler(session=_session) + job = sampler.run(circuits=qc) + job.result() + + def test_architectures() -> None: # https://github.com/CQCL/pytket-qiskit/issues/14 arch_list = [None, Architecture([(0, 1), (1, 2)]), FullyConnected(3)]