question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cirq routing is hanging again for some circuits

See original GitHub issue

Hi guys,

I have a concern similar to the one from issue #2282. The problem was fixed later and when running from 6d81ddbb commit everything works just fine. However, there were further changes in apply_next_swaps(…) function, in particular a new parameter max_num_empty_steps was introduced.

In the last version of code when running routing via route_circuit_greedily(…) and with parameters max_search_radius=1, max_num_empty_steps=1 everything also works well. However, when choosing different values for these two parameters (e.g. max_search_radius=2, max_num_empty_steps=1) routing hangs on some circuit instances.

Should there be any constraint on how to choose values for the parameters max_search_radius and max_num_empty_steps? Or maybe there is some bug in the routing code?

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
yourballcommented, Sep 24, 2020

I think I managed to fix the issue by modifying function apply_next_swaps(…) in greedy router. In fact these changes were implemented earlier to fix such a problem and then for some reason were reverted.

See this screenshot: image

After partially reverting these changes in apply_next_swaps(…) in Cirq. 0.8.2 the greedy router works fine! Should I create a pool request with the changes?

This is the modified version of apply_next_swaps(…) function:

def apply_next_swaps(self, require_frontier_adjacency: bool = False):
        """Applies a few SWAPs to get the mapping closer to one in which the
        next logical gates can be applied.

        See route_circuit_greedily for more details.
        """

        time_slices = get_time_slices(self.remaining_dag)

        if require_frontier_adjacency:
            frontier_edges = sorted(time_slices[0].edges)
            self.bring_farthest_pair_together(frontier_edges)
            return

        for k in range(1, self.max_search_radius + 1):
            candidate_swap_sets = list(self.get_edge_sets(k))
            for time_slice in time_slices:
                edges = sorted(time_slice.edges)
                distance_vectors = list(
                    self.get_distance_vector(edges, swap_set)
                    for swap_set in candidate_swap_sets)
                dominated_indices = _get_dominated_indices(distance_vectors)
                candidate_swap_sets = [
                    S for i, S in enumerate(candidate_swap_sets)
                    if i not in dominated_indices
                ]
                if len(candidate_swap_sets) == 1:
                    self.apply_swap(*candidate_swap_sets[0])
                    if list(
                            self.remaining_dag.findall_nodes_until_blocked(
                                self.acts_on_nonadjacent_qubits)):
                        return
                    else:
                        break

        self.apply_next_swaps(True)

These are the lines I added:

                    if list(
                            self.remaining_dag.findall_nodes_until_blocked(
                                self.acts_on_nonadjacent_qubits)):
                        return
                    else:
                        break
1reaction
yourballcommented, Sep 24, 2020

Submitted PR #3360

Read more comments on GitHub >

github_iconTop Results From Across the Web

Routing with t|ket> | Cirq - Google Quantum AI
We'll route a 3-regular circuit to Sycamore23. To try to clear up some of the confusion about which indices are which, we'll construct...
Read more >
User guide — Cirq on IQM 8.1 documentation - GitHub Pages
Under the hood, route_circuit() leverages the routing algorithm in cirq.contrib.routing.router . It works on single- and two-qubit gates, and measurement ...
Read more >
10 Essential Tricks to Shorten Your Next Delivery Routes
Reduce your delivery costs by 20% with Circuit for TeamsDownload ... Don't hang around that long – take the delivery back to the...
Read more >
Duco: Autonomous Large-Scale Direct-Circuit-Writing (DCW ...
In this paper, we present Duco, a large-scale electronics fabrication robot that enables room-scale & building-scale circuitry to add interactivity to vertical ...
Read more >
Multiclass classification using TensorFlow Quantum
However, this method increases massively the size of the circuit. So what I want to do is to pass to TFQ only 2...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found