Skip to content

Commit

Permalink
Merge branch 'develop' into fix/round_angles
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMacCQ authored Jul 21, 2023
2 parents 38e4cbf + 1b25d79 commit 02ea72c
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
ccache -p
- name: Build tket
run: |
conan install tket --user=tket --channel=stable -s build_type=Debug -o boost/*:header_only=True -o tket/*:profile_coverage=True -o with_test=True -of build/tket
conan install tket --user=tket --channel=stable -s build_type=Debug --build=missing -o boost/*:header_only=True -o tket/*:profile_coverage=True -o with_test=True -of build/tket
conan build tket --user=tket --channel=stable -s build_type=Debug -o boost/*:header_only=True -o tket/*:profile_coverage=True -o with_test=True -o test-tket/*:with_coverage=True -of build/tket
conan export-pkg tket --user=tket --channel=stable -s build_type=Debug -o boost/*:header_only=True -o tket/*:profile_coverage=True -o with_test=True -of build/tket -tf ""
- name: Install runtime test requirements
Expand Down
3 changes: 2 additions & 1 deletion pytket/binders/partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ PYBIND11_MODULE(partition, m) {
.value(
"NonConflictingSets", PauliPartitionStrat::NonConflictingSets,
"Build sets of Pauli tensors in which each qubit has the "
"same Pauli or Pauli.I. Requires no additional CX gates.")
"same Pauli or Pauli.I. Requires no additional CX gates "
"for diagonalisation.")
.value(
"CommutingSets", PauliPartitionStrat::CommutingSets,
"Build sets of mutually commuting Pauli tensors. Requires "
Expand Down
2 changes: 1 addition & 1 deletion pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def package(self):
cmake.install()

def requirements(self):
self.requires("tket/1.2.26@tket/stable")
self.requires("tket/1.2.28@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tkassert/0.3.3@tket/stable")
Expand Down
7 changes: 4 additions & 3 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Changelog
=========

1.18.0 (unreleased)
-------------------
1.17.1 (July 2023)
------------------

General:

Expand All @@ -12,7 +12,8 @@ General:
Minor new features:

* New constructor for ``ToffoliBox`` that allows switching between two decomposition strategies:
``ToffoliBoxSynthStrat.Matching`` and ``ToffoliBoxSynthStrat.Cycle``.
``ToffoliBoxSynthStrat.Matching`` and ``ToffoliBoxSynthStrat.Cycle``.
* Prefer ``ZZPhase`` to ``CX`` or ``ZZMax`` when using ``auto_rebase_pass()``.

1.17.0 (July 2023)
------------------
Expand Down
2 changes: 1 addition & 1 deletion pytket/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# The short X.Y version
version = "1.17"
# The full version, including alpha/beta/rc tags
release = "1.17.0"
release = "1.17.1"


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pytket/pytket/passes/auto_rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def _TK2_using_TK2(a: Param, b: Param, c: Param) -> Circuit:

_TK2_CIRCS: Dict[OpType, Callable[[Param, Param, Param], "Circuit"]] = {
OpType.TK2: _TK2_using_TK2,
OpType.ZZPhase: _library._TK2_using_ZZPhase,
OpType.CX: _library._TK2_using_CX,
OpType.ZZMax: _library._TK2_using_ZZMax,
OpType.ZZPhase: _library._TK2_using_ZZPhase,
}


Expand Down
21 changes: 18 additions & 3 deletions pytket/pytket/utils/term_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,30 @@ def gen_term_sequence_circuit(
partition_strat: PauliPartitionStrat = PauliPartitionStrat.CommutingSets,
colour_method: GraphColourMethod = GraphColourMethod.Lazy,
) -> Circuit:
"""Sequences QubitPauliOperator terms to generate a circuit made of CircBoxes.
Each CircBox contains a sequence of PauliExpBox objects.
"""
Sequences the terms of a :py:class:`QubitPauliOperator` :math:`P` to generate
a circuit approximating :math:`e^{i \\frac{\\pi}{2} P}`. This method
performs Trotterisation on :math:`P` with a single Trotter step.
This method uses a given partitioning strategy and a graph colouring
method for term sequencing.
The resulting Circuit will contain a sequence of CircBoxes. Each CircBox
corresponds to a set of Pauli strings. Each exponentiated Pauli string
in the set is realised as a PauliExpBox.
The ordering of terms prioritises reducing the two qubit gate count of the
circuit when the PauliSimp or GuidedPauliSimp passes are applied rather
than minimising the trotter error.
:param operator: The operator terms to sequence
:type operator: QubitPauliOperator
:param reference_state: reference state to add sequenced terms to.
:type reference_state: Circuit
:param partition_strat: a Partition strategy
:type partition_strat: PauliPartitionStrat, optional
:type partition_strat: PauliPartitionStrat, Optional
:param colour_method: a graph colouring method
:type colour_method: GraphColourMethod, Optional
"""
qps_list = list(operator._dict.keys())
qps_list_list = term_sequence(qps_list, partition_strat, colour_method)
Expand Down
22 changes: 22 additions & 0 deletions pytket/tests/placement_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,27 @@ def test_big_placement() -> None:
assert DefaultMappingPass(arc).apply(c)


def test_large_error_rate_noise_aware() -> None:
nodes = [Node(i) for i in range(3)]
arc = Architecture([(nodes[0], nodes[1]), (nodes[1], nodes[2])])
nap = NoiseAwarePlacement(
arc,
{},
{
(nodes[0], nodes[1]): 0.2,
(nodes[1], nodes[0]): 0.5,
(nodes[1], nodes[2]): 2,
(nodes[2], nodes[1]): 1,
},
)

c = Circuit(2).CX(0, 1)

placement_map = nap.get_placement_map(c)
assert placement_map[Qubit(0)] == Node(0)
assert placement_map[Qubit(1)] == Node(1)


if __name__ == "__main__":
test_placements()
test_placements_serialization()
Expand All @@ -253,3 +274,4 @@ def test_big_placement() -> None:
test_big_placement()
test_place_fully_connected()
test_placement_config()
test_large_error_rate_noise_aware()
2 changes: 1 addition & 1 deletion pytket/tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ pytest-benchmark
py
hypothesis
docker
jsonschema
jsonschema==4.18.0
opt_einsum
2 changes: 1 addition & 1 deletion tket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TketConan(ConanFile):
name = "tket"
version = "1.2.26"
version = "1.2.28"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
7 changes: 5 additions & 2 deletions tket/src/Placement/NoiseAwarePlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ double NoiseAwarePlacement::cost_placement(
this->characterisation_.get_error({node, neighbour});
gate_error_t bck_error =
this->characterisation_.get_error({neighbour, node});
edge_sum += fwd_edge_weighting * (1.0 - fwd_error);
edge_sum += bck_edge_weighting * (1.0 - bck_error);

if (fwd_error < 1.0 && bck_error < 1.0) {
edge_sum += fwd_edge_weighting * (1.0 - fwd_error);
edge_sum += bck_edge_weighting * (1.0 - bck_error);
}
}
// bigger edge sum -> smaller cost
cost += 1.0 / (edge_sum);
Expand Down

0 comments on commit 02ea72c

Please sign in to comment.