app.processing.merge.connections
Connect input/output by modifying the AST based on IOInfo
.
Module Contents
- class app.processing.merge.connections.SingleQubit
Give a qubit a unique ID in the whole graph.
- Parameters:
section_id – The UUID of the section the qubit occurred in.
id_in_section – The Qubit ID based on the declaration order in the section.
- class app.processing.merge.connections.ApplyConnectionsTransformer(section_id: uuid.UUID, io_info: app.processing.graph.IOInfo, qubit_info: app.processing.graph.QubitInfo, global_reg_name: str, qubit_to_index: dict[SingleQubit, int], classical_input_to_output: dict[str, str])
Replace qubit declarations and classical inputs with aliases.
- Parameters:
section_id (uuid.UUID) – The UUID of the currently visited section.
io_info (app.processing.graph.IOInfo) – The IOInfo for the current section.
qubit_info (app.processing.graph.QubitInfo) – The QubitInfo for the current section.
global_reg_name (str) – The name to use for the global qubit register.
qubit_to_index (dict[SingleQubit, int]) – Map qubits to the indexes in the global reg.
classical_input_to_output (dict[str, str]) – Map classical declaration names to aliases to use.
- id_to_qubit(id: int) SingleQubit
Create a
SingleQubit
for the encountered ID.- Parameters:
id (int)
- Return type:
- visit_QubitDeclaration(node: openqasm3.ast.QubitDeclaration) openqasm3.ast.QASMNode
Replace qubit declaration with alias to leqo_reg.
- Parameters:
- Return type:
- visit_ClassicalDeclaration(node: openqasm3.ast.ClassicalDeclaration) openqasm3.ast.QASMNode
Replace classical declaration with alias to output if it is an input.
- Parameters:
- Return type:
- app.processing.merge.connections.connect_qubits(graph: app.processing.graph.ProgramGraph, global_reg_name: str, input: app.processing.graph.ProcessedProgramNode | None = None) int
Apply connections to the graph.
- Parameters:
graph (app.processing.graph.ProgramGraph) – The graph to modify in place.
global_reg_name (str) – The name of the qubit reg to use in aliases.
input (app.processing.graph.ProcessedProgramNode | None) – Optional input node: don’t modify it + IDs in the order of the declarations in this node.
- Returns:
The size of the global qubit register.
- Return type: