Skip to content

Commit

Permalink
Update NoiseAwarePlacement::cost_placement to cost errors appropria…
Browse files Browse the repository at this point in the history
…tely (#944)

* only add errors if error rate is reasonable

* Bump
  • Loading branch information
sjdilkes authored Jul 21, 2023
1 parent 8beb11a commit 1b25d79
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
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.27@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
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 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.27"
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 1b25d79

Please sign in to comment.