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

[Named Topologies] Add nodes_to_linequbits method to LineTopology #4710

Closed
tanujkhattar opened this issue Nov 24, 2021 · 1 comment · Fixed by #5821
Closed

[Named Topologies] Add nodes_to_linequbits method to LineTopology #4710

tanujkhattar opened this issue Nov 24, 2021 · 1 comment · Fixed by #5821
Labels
area/devices good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@tanujkhattar
Copy link
Collaborator

Routing utilities currently present in cirq contrib expect a networkx graph of device (/target topology) where each node is a cirq.Qid. NamedTopology stores topology graphs where each node is a number / tuple.
TiltedSquareLattice has a nodes_to_gridqubits method which can provide a mapping from the graph nodes to the corresponding grid qubits.

def nodes_to_gridqubits(self, offset=(0, 0)) -> Dict[Tuple[int, int], 'cirq.GridQubit']:

This can be used to quickly get the graph needed for routing circuits from the topology graph as follows:

routing_graph = nx.relabel_nodes(topology.graph, topology.nodes_to_gridqubits())

A similar convenience method, nodes_to_linequbits, should be added to the LineQubit named topology as well.

cc @mpharrigan

@tanujkhattar tanujkhattar added the kind/feature-request Describes new functionality label Nov 24, 2021
@mpharrigan
Copy link
Collaborator

mpharrigan commented Nov 24, 2021

Yeah, I thought about this and almost included it in #4628 but omitted it because I figured it would be less useful for people putting stuff on gridqubit-based devices.

It would be

return {i: q for i, q in enumerate(LineQubit.range(self.n)}

@MichaelBroughton MichaelBroughton added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Dec 1, 2021
@95-martin-orion 95-martin-orion added good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Dec 1, 2021
CirqBot pushed a commit that referenced this issue Aug 11, 2022
Resolves #4710

Co-authored-by: Pavol Juhas <juhas@google.com>
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
Resolves quantumlib#4710

Co-authored-by: Pavol Juhas <juhas@google.com>
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this issue Oct 31, 2024
Resolves quantumlib#4710

Co-authored-by: Pavol Juhas <juhas@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devices good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants