Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdilkes committed Nov 12, 2024
1 parent e51a3c3 commit 59d91ce
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pytket/binders/passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ PYBIND11_MODULE(passes, m) {
py::arg("seed") = 0, py::arg("allow_zzphase") = false,
py::arg("timeout") = 100, py::arg("only_reduce") = false);
m.def(
"MultiThreadGreedyPauliSimp", &gen_multi_thread_greedy_pauli_simp,
"GreedyPauliSimpMT", &gen_multi_thread_greedy_pauli_simp,
"Construct a pass that runs seeded `GreedyPauliSimp` in multiple threads "
"and returns the smallest circuit. Will return the original circuit if "
"no reduction is found."
Expand Down
2 changes: 1 addition & 1 deletion pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Features:
* Add `only_reduce` argument to `GreedyPauliSimp`.
* Add option to not relabel `ClassicalExpBox` when calling `rename_units`
and `flatten_registers`
* Add new pass `MultiThreadGreedyPauliSimp`.
* Add new pass `GreedyPauliSimpMT`.
* Implement `dagger()` and `transpose()` for `CustomGate`.
* Use `ClExprOp` by default when converting from QASM.

Expand Down
4 changes: 2 additions & 2 deletions pytket/pytket/_tket/passes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import pytket._tket.transform
import pytket._tket.unit_id
import sympy
import typing
__all__ = ['AASRouting', 'Audit', 'AutoRebase', 'AutoSquash', 'BasePass', 'CNotSynthType', 'CXMappingPass', 'CliffordPushThroughMeasures', 'CliffordResynthesis', 'CliffordSimp', 'CnXPairwiseDecomposition', 'CommuteThroughMultis', 'ComposePhasePolyBoxes', 'ContextSimp', 'CustomPass', 'CustomRoutingPass', 'DecomposeArbitrarilyControlledGates', 'DecomposeBoxes', 'DecomposeClassicalExp', 'DecomposeMultiQubitsCX', 'DecomposeSingleQubitsTK1', 'DecomposeSwapsToCXs', 'DecomposeSwapsToCircuit', 'DecomposeTK2', 'Default', 'DefaultMappingPass', 'DelayMeasures', 'EulerAngleReduction', 'FlattenRegisters', 'FlattenRelabelRegistersPass', 'FullMappingPass', 'FullPeepholeOptimise', 'GlobalisePhasedX', 'GreedyPauliSimp', 'GuidedPauliSimp', 'HamPath', 'KAKDecomposition', 'MultiThreadGreedyPauliSimp', 'NaivePlacementPass', 'NormaliseTK2', 'OptimisePhaseGadgets', 'PauliExponentials', 'PauliSimp', 'PauliSquash', 'PeepholeOptimise2Q', 'PlacementPass', 'RebaseCustom', 'RebaseTket', 'Rec', 'RemoveBarriers', 'RemoveDiscarded', 'RemoveImplicitQubitPermutation', 'RemoveRedundancies', 'RenameQubitsPass', 'RepeatPass', 'RepeatUntilSatisfiedPass', 'RepeatWithMetricPass', 'RoundAngles', 'RoutingPass', 'SWAP', 'SafetyMode', 'SequencePass', 'SimplifyInitial', 'SimplifyMeasured', 'SquashCustom', 'SquashRzPhasedX', 'SquashTK1', 'SynthesiseTK', 'SynthesiseTket', 'SynthesiseUMD', 'ThreeQubitSquash', 'ZXGraphlikeOptimisation', 'ZZPhaseToRz']
__all__ = ['AASRouting', 'Audit', 'AutoRebase', 'AutoSquash', 'BasePass', 'CNotSynthType', 'CXMappingPass', 'CliffordPushThroughMeasures', 'CliffordResynthesis', 'CliffordSimp', 'CnXPairwiseDecomposition', 'CommuteThroughMultis', 'ComposePhasePolyBoxes', 'ContextSimp', 'CustomPass', 'CustomRoutingPass', 'DecomposeArbitrarilyControlledGates', 'DecomposeBoxes', 'DecomposeClassicalExp', 'DecomposeMultiQubitsCX', 'DecomposeSingleQubitsTK1', 'DecomposeSwapsToCXs', 'DecomposeSwapsToCircuit', 'DecomposeTK2', 'Default', 'DefaultMappingPass', 'DelayMeasures', 'EulerAngleReduction', 'FlattenRegisters', 'FlattenRelabelRegistersPass', 'FullMappingPass', 'FullPeepholeOptimise', 'GlobalisePhasedX', 'GreedyPauliSimp', 'GuidedPauliSimp', 'HamPath', 'KAKDecomposition', 'GreedyPauliSimpMT', 'NaivePlacementPass', 'NormaliseTK2', 'OptimisePhaseGadgets', 'PauliExponentials', 'PauliSimp', 'PauliSquash', 'PeepholeOptimise2Q', 'PlacementPass', 'RebaseCustom', 'RebaseTket', 'Rec', 'RemoveBarriers', 'RemoveDiscarded', 'RemoveImplicitQubitPermutation', 'RemoveRedundancies', 'RenameQubitsPass', 'RepeatPass', 'RepeatUntilSatisfiedPass', 'RepeatWithMetricPass', 'RoundAngles', 'RoutingPass', 'SWAP', 'SafetyMode', 'SequencePass', 'SimplifyInitial', 'SimplifyMeasured', 'SquashCustom', 'SquashRzPhasedX', 'SquashTK1', 'SynthesiseTK', 'SynthesiseTket', 'SynthesiseUMD', 'ThreeQubitSquash', 'ZXGraphlikeOptimisation', 'ZZPhaseToRz']
class BasePass:
"""
Base class for passes.
Expand Down Expand Up @@ -491,7 +491,7 @@ def KAKDecomposition(target_2qb_gate: pytket._tket.circuit.OpType = pytket._tket
@typing.overload
def KAKDecomposition(cx_fidelity: float) -> BasePass:
...
def MultiThreadGreedyPauliSimp(threads: int, discount_rate: float = 0.7, depth_weight: float = 0.3, max_lookahead: int = 500, max_tqe_candidates: int = 500, seed: int = 0, allow_zzphase: bool = False, timeout: int = 100) -> BasePass:
def GreedyPauliSimpMT(threads: int, discount_rate: float = 0.7, depth_weight: float = 0.3, max_lookahead: int = 500, max_tqe_candidates: int = 500, seed: int = 0, allow_zzphase: bool = False, timeout: int = 100) -> BasePass:
"""
Construct a pass that runs seeded `GreedyPauliSimp` in multiple threads and returns the smallest circuit. Will return the original circuit if no reduction is found.
Expand Down
4 changes: 2 additions & 2 deletions pytket/tests/passes_serialisation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ def nonparam_predicate_dict(name: str) -> Dict[str, Any]:
"only_reduce": False,
}
),
"MultiThreadGreedyPauliSimp": standard_pass_dict(
"GreedyPauliSimpMT": standard_pass_dict(
{
"name": "MultiThreadGreedyPauliSimp",
"name": "GreedyPauliSimpMT",
"discount_rate": 0.4,
"depth_weight": 0.5,
"max_lookahead": 100,
Expand Down
4 changes: 2 additions & 2 deletions pytket/tests/predicates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
FlattenRelabelRegistersPass,
FullMappingPass,
GreedyPauliSimp,
MultiThreadGreedyPauliSimp,
GreedyPauliSimpMT,
NaivePlacementPass,
PauliSimp,
PauliSquash,
Expand Down Expand Up @@ -1095,7 +1095,7 @@ def test_mt_greedy_pauli_synth() -> None:
rega[0], regb[0]
).SWAP(regb[1], rega[0])
d = circ.copy()
pss = MultiThreadGreedyPauliSimp(5, 0.5, 0.5)
pss = GreedyPauliSimpMT(5, 0.5, 0.5)
assert pss.apply(d)
assert np.allclose(circ.get_unitary(), d.get_unitary())
assert d.name == "test"
Expand Down
6 changes: 3 additions & 3 deletions schemas/compiler_pass_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"RemoveImplicitQubitPermutation",
"RoundAngles",
"GreedyPauliSimp",
"MultiThreadGreedyPauliSimp"
"GreedyPauliSimpMT"
],
"description": "The name of the compiler pass. Matches the name of the pytket method used to generate it. List all the passes as enum."
},
Expand Down Expand Up @@ -385,7 +385,7 @@
},
"threads": {
"type": "number",
"definition": "number of threads to run in parallel when finding solutions to \"MultiThreadGreedyPauliSimp\"."
"definition": "number of threads to run in parallel when finding solutions to \"GreedyPauliSimpMT\"."
}
},
"required": [
Expand Down Expand Up @@ -928,7 +928,7 @@
"if": {
"properties": {
"name": {
"const": "MultiThreadGreedyPauliSimp"
"const": "GreedyPauliSimpMT"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion tket/src/Predicates/CompilerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ PassPtr deserialise(
discount_rate, depth_weight, max_lookahead, max_tqe_candidates, seed,
allow_zzphase, timeout, only_reduce);

} else if (passname == "MultiThreadGreedyPauliSimp") {
} else if (passname == "GreedyPauliSimpMT") {
double discount_rate = content.at("discount_rate").get<double>();
double depth_weight = content.at("depth_weight").get<double>();
unsigned max_tqe_candidates =
Expand Down
2 changes: 1 addition & 1 deletion tket/src/Predicates/PassGenerators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ PassPtr gen_multi_thread_greedy_pauli_simp(

// record pass config
nlohmann::json j;
j["name"] = "MultiThreadGreedyPauliSimp";
j["name"] = "GreedyPauliSimpMT";
j["discount_rate"] = discount_rate;
j["depth_weight"] = depth_weight;
j["max_lookahead"] = max_lookahead;
Expand Down
20 changes: 2 additions & 18 deletions tket/test/src/test_GreedyPauli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ SCENARIO("Test GreedyPauliSimp pass construction") {
}
}

SCENARIO("Test MultiThreadGreedyPauliSimp") {
SCENARIO("Test GreedyPauliSimpMT") {
GIVEN("Circuit with measures, classicals, and resets") {
Circuit circ(3, 1);
circ.add_box(
Expand All @@ -776,23 +776,6 @@ SCENARIO("Test MultiThreadGreedyPauliSimp") {
REQUIRE(circ.count_gates(OpType::Measure) == 1);
REQUIRE(circ.count_gates(OpType::Reset) == 1);
}
GIVEN("Compile to ZZPhase") {
Circuit circ(2);
circ.add_box(
PauliExpBox(SymPauliTensor({Pauli::X, Pauli::X}, 0.3)), {0, 1});
Circuit d1(circ);
Circuit d2(circ);
REQUIRE(Transforms::multi_thread_greedy_pauli_optimisation(
3, 0.7, 0.3, 500, 500, 0, true)
.apply(d1));
REQUIRE(Transforms::multi_thread_greedy_pauli_optimisation(
3, 0.7, 0.3, 500, 500, 0, false)
.apply(d2));
REQUIRE(test_unitary_comparison(circ, d1, true));
REQUIRE(test_unitary_comparison(circ, d2, true));
REQUIRE(d1.count_n_qubit_gates(2) == 1);
REQUIRE(d2.count_n_qubit_gates(2) == 2);
}
GIVEN("Large circuit with ZZPhase") {
Circuit circ(6);
circ.add_box(
Expand Down Expand Up @@ -851,6 +834,7 @@ SCENARIO("Test MultiThreadGreedyPauliSimp") {
{0, 5, 1, 4, 3, 2});

Circuit d(circ);
d.decompose_boxes_recursively();
REQUIRE(Transforms::multi_thread_greedy_pauli_optimisation(
3, 0.7, 0.3, 500, 500, 0, true, 100)
.apply(d));
Expand Down

0 comments on commit 59d91ce

Please sign in to comment.