|
27 | 27 | #include "tket/Predicates/CompilerPass.hpp" |
28 | 28 | #include "tket/Predicates/PassGenerators.hpp" |
29 | 29 | #include "tket/Predicates/PassLibrary.hpp" |
| 30 | +#include "tket/Transformations/BasicOptimisation.hpp" |
30 | 31 | #include "tket/Transformations/GreedyPauliOptimisation.hpp" |
31 | 32 | #include "tket/Utils/Expression.hpp" |
32 | 33 |
|
@@ -368,6 +369,23 @@ SCENARIO("Complete synthesis") { |
368 | 369 | REQUIRE(Transforms::greedy_pauli_optimisation().apply(circ)); |
369 | 370 | REQUIRE(circ == d); |
370 | 371 | } |
| 372 | + |
| 373 | + GIVEN("Circuit with conditional gates 3") { |
| 374 | + Circuit c(2, 1); |
| 375 | + c.add_op<unsigned>(OpType::Rx, 1.0246, {0}); |
| 376 | + c.add_conditional_gate<unsigned>(OpType::Ry, {-0.25}, {1}, {0}, 0); |
| 377 | + c.add_conditional_gate<unsigned>(OpType::CZ, {}, {0, 1}, {0}, 0); |
| 378 | + REQUIRE(Transforms::greedy_pauli_optimisation().apply(c)); |
| 379 | + |
| 380 | + Circuit comp(2, 1); |
| 381 | + comp.add_op<unsigned>(OpType::Rx, 1.0246, {0}); |
| 382 | + comp.add_conditional_gate<unsigned>(OpType::Ry, {-0.25}, {1}, {0}, 0); |
| 383 | + comp.add_conditional_gate<unsigned>(OpType::CZ, {}, {1, 0}, {0}, 0); |
| 384 | + // Previously Conditional Ry was being commuted ahead of Rz and then CZ |
| 385 | + // merged in without checking commuting with Rx Returning the same circuit |
| 386 | + // is expected, except the CZ gate is "flipped" |
| 387 | + REQUIRE(comp == c); |
| 388 | + } |
371 | 389 | GIVEN("Circuit with conditional gates and measures") { |
372 | 390 | Circuit circ(2, 2); |
373 | 391 | Op_ptr cond1 = std::make_shared<Conditional>( |
@@ -405,6 +423,7 @@ SCENARIO("Complete synthesis") { |
405 | 423 | // should all be canceled |
406 | 424 | Circuit d(2, 2); |
407 | 425 | REQUIRE(Transforms::greedy_pauli_optimisation().apply(circ)); |
| 426 | + Transforms::remove_redundancies().apply(circ); |
408 | 427 | REQUIRE(circ == d); |
409 | 428 | } |
410 | 429 | GIVEN("Circuit with classical gates") { |
@@ -677,7 +696,8 @@ SCENARIO("Complete synthesis") { |
677 | 696 | .apply(d)); |
678 | 697 | REQUIRE(test_unitary_comparison(circ, d, true)); |
679 | 698 | // if the first XY was implemented using a ZZPhase |
680 | | - // then 2 TQEs is needed to conjugate the remaining two strings to weight 2 |
| 699 | + // then 2 TQEs is needed to conjugate the remaining two strings to |
| 700 | + // weight 2 |
681 | 701 | // hence 5 2-qubit gates in total. |
682 | 702 | REQUIRE(d.count_n_qubit_gates(2) == 4); |
683 | 703 | } |
|
0 commit comments