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

tests: verify transpilation and execution of CSWAP gates #113

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion test/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

from qiskit_aqt_provider import AQTProvider
from qiskit_aqt_provider.aqt_resource import AQTResource
from qiskit_aqt_provider.test.circuits import qft_circuit
from qiskit_aqt_provider.test.circuits import assert_circuits_equivalent, qft_circuit
from qiskit_aqt_provider.test.fixtures import MockSimulator
from qiskit_aqt_provider.test.resources import TestResource
from qiskit_aqt_provider.test.timeout import timeout
Expand Down Expand Up @@ -399,6 +399,28 @@ def test_initialize_not_supported(offline_simulator_no_noise: AQTResource) -> No
qiskit.transpile(qc, offline_simulator_no_noise)


@pytest.mark.parametrize("optimization_level", range(4))
def test_cswap(optimization_level: int, offline_simulator_no_noise: AQTResource) -> None:
"""Verify that CSWAP (Fredkin) gates can be transpiled and executed (in a trivial case)."""
qc = QuantumCircuit(3)
qc.prepare_state("101")
qc.cswap(0, 1, 2)

trans_qc = qiskit.transpile(
qc, offline_simulator_no_noise, optimization_level=optimization_level
)
assert_circuits_equivalent(qc, trans_qc)

qc.measure_all()
shots = 200
job = qiskit.execute(
qc, offline_simulator_no_noise, optimization_level=optimization_level, shots=shots
)
counts = job.result().get_counts()

assert counts == {"011": shots}


@pytest.mark.parametrize(("shots", "qubits"), [(100, 3)])
def test_simulator_quantum_volume(
shots: int, qubits: int, offline_simulator_no_noise: AQTResource
Expand Down