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

Add RebaseTket to DFSC #104

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions qermit/clifford_noise_characterisation/dfsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def preparation_circuit_for_partition(
# transform string, then append gates for preparing
# +1 eigenstate to circuit
# use RemoveRedundancies after to minimise gates required in cosntruction
Transform.RebaseToTket().apply(clifford_circuit)
Transform.RebaseToCliffordSingles().apply(clifford_circuit)
for string in partition:
transformed_string = apply_clifford_basis_change(string, clifford_circuit)
Expand Down
30 changes: 29 additions & 1 deletion tests/dfsc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@


from pytket import Circuit, Qubit
from pytket.circuit import fresh_symbol # type: ignore
from pytket.circuit import fresh_symbol, PauliExpBox # type: ignore
from pytket.transform import Transform # type: ignore

from qermit import ( # type: ignore
AnsatzCircuit,
SymbolsDict,
ObservableTracker,
MeasurementCircuit,
Expand Down Expand Up @@ -309,6 +310,32 @@ def test_DFSC_mitex_gen():
assert res[0][qps_12] == -1.0
assert res[1][qps_012] == 0.7

def test_CRY_case():
backend=AerBackend()
dfsc_mitex = gen_DFSC_MitEx(backend=backend)
sym = fresh_symbol("test")
peb_xyz = PauliExpBox([Pauli.X, Pauli.Y, Pauli.Z], sym)

c = Circuit(3, 3)
c.add_pauliexpbox(peb_xyz, [Qubit(0), Qubit(1), Qubit(2)]).CRy(sym, 0,1).Z(1).Z(2)
c.add_pauliexpbox(peb_xyz, [Qubit(0), Qubit(1), Qubit(2)]).Z(0).Z(1).Z(2)
c.add_pauliexpbox(peb_xyz, [Qubit(0), Qubit(1), Qubit(2)]).Z(0).Z(1).Z(2)
c.add_pauliexpbox(peb_xyz, [Qubit(0), Qubit(1), Qubit(2)])
Transform.DecomposeBoxes().apply(c)

symbols = SymbolsDict.symbols_from_dict({sym: 0.25})

qubit_pauli_string = QubitPauliString(
[Qubit(0), Qubit(1), Qubit(2)], [Pauli.Z, Pauli.Z, Pauli.Z]
)
ansatz_circuit = AnsatzCircuit(c, 2000, symbols)

exp = [
ObservableExperiment(
ansatz_circuit, ObservableTracker(QubitPauliOperator({qubit_pauli_string: 1.0}))
)
]
assert dfsc_mitex.run(exp)

if __name__ == "__main__":
test_get_clifford_mcs()
Expand All @@ -318,3 +345,4 @@ def test_DFSC_mitex_gen():
test_DFSC_characterisation_task_gen()
test_DFSC_correction_task_gen()
test_DFSC_mitex_gen()
test_CRY_case()