Skip to content

Commit

Permalink
add test for timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdilkes committed Nov 19, 2024
1 parent 1f68c99 commit edcfdad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pytket/tests/predicates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,6 @@ def test_greedy_pauli_synth() -> None:
circ.measure_all()
circ.Reset(0)
circ.add_pauliexpbox(pg1, [2, 3])
assert not GreedyPauliSimp(0.5, 0.5, 100, 100, 0, True, 0).apply(circ)
assert GreedyPauliSimp(0.5, 0.5, 100, 100, 0, True, 100).apply(circ)
# PauliExpBoxes implemented using ZZPhase
d = Circuit(4, 4, name="test")
Expand All @@ -1084,6 +1083,16 @@ def test_greedy_pauli_synth() -> None:
GreedyPauliSimp().apply(circ)
err_msg = "Predicate requirements are not satisfied"
assert err_msg in str(e.value)
# large circuit that doesn't complete within thread_timeout argument
c = Circuit(13)
for _ in range(20):
for i in range(13):
for j in range(i + 1, 13):
c.CX(i, j)
c.Rz(0.23, j)
c.H(i)
assert not GreedyPauliSimp(thread_timeout=1).apply(c)
assert GreedyPauliSimp().apply(c)


def test_auto_rebase_deprecation(recwarn: Any) -> None:
Expand Down
1 change: 0 additions & 1 deletion tket/src/Transformations/GreedyPauliOptimisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,6 @@ Transform greedy_pauli_optimisation(
while (threads_started < trials) {
std::shared_ptr<std::atomic<bool>> stop_flag =
std::make_shared<std::atomic<bool>>(false);
// Circuit copy(circ);
std::future<Circuit> future = std::async(
std::launch::async,
[&, stop_flag]() { // Capture `stop_flag` explicitly in the lambda
Expand Down

0 comments on commit edcfdad

Please sign in to comment.