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

Fixed bug with checkpoint pass #296

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Log verification info and #CNOT during test_pam_verify
user committed Nov 5, 2024
commit 56ef79b1d3885572cc6cc5fad37958143ac94c71
14 changes: 14 additions & 0 deletions tests/compiler/compile/test_pam_verify.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,14 @@
from bqskit.passes import SetModelPass
from bqskit.qis.permutation import PermutationMatrix

from bqskit.ir.gates import *
import logging
_logger = logging.getLogger(__name__)

def test_pam_verify(compiler: Compiler, medium_qasm_file: str) -> None:

_logger.info(f' Reading from file: {medium_qasm_file}')

circuit = Circuit.from_file(medium_qasm_file)
out_circuit, data = compiler.compile(
circuit,
@@ -18,13 +24,21 @@ def test_pam_verify(compiler: Compiler, medium_qasm_file: str) -> None:
],
request_data=True,
)

_logger.info(f' Finished compiling, CNOT count: {out_circuit.count(CNOTGate())}')

upper_bound_error = data.error
pi = data['initial_mapping']
pf = data['final_mapping']
out_utry = out_circuit.get_unitary()
PI = PermutationMatrix.from_qubit_location(out_circuit.num_qudits, pi)
PF = PermutationMatrix.from_qubit_location(out_circuit.num_qudits, pf)
exact_error = out_utry.get_distance_from(PF.T @ circuit.get_unitary() @ PI)

_logger.info(f' Upper bound error: {upper_bound_error}')
_logger.info(f' Exact error: {exact_error}')
_logger.info(f' |upper_bound-exact| : {abs(upper_bound_error - exact_error)}')

assert upper_bound_error >= exact_error or abs(
upper_bound_error - exact_error,
) < 5e-7