Skip to content

Commit

Permalink
remove testcases, solve some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-melf committed Mar 4, 2024
1 parent c6034bd commit e689aec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
31 changes: 28 additions & 3 deletions tests/qiskit_backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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()
Expand All @@ -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)]
Expand Down

0 comments on commit e689aec

Please sign in to comment.