Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NoiseAwarePlacement::cost_placement to cost errors appropriately #944

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading