qunicorn_core.core.transpiler package

Submodules

qunicorn_core.core.transpiler.preprocessing_manager module

class qunicorn_core.core.transpiler.preprocessing_manager.PreProcessingManager

Bases: object

get_preprocessor(language: AssemblerLanguage) Callable[[str], any]

Either returns the registered preprocessing method or a method that returns the input

register(language: AssemblerLanguage)

decorator that is used to add new preprocessing options, so the methods can be found dynamically from get_preprocessor()

qunicorn_core.core.transpiler.preprocessing_manager.PreProcessor

This Class handles all preprocessing that is needed to transform a circuit string into a circuit object

alias of Callable[[str], any]

qunicorn_core.core.transpiler.preprocessing_manager.preprocess_braket(program: str) Circuit

braket.Circuit needs to be included here as an import here so eval works with the type

qunicorn_core.core.transpiler.preprocessing_manager.preprocess_qiskit(program: str) QuantumCircuit

since the qiskit circuit modifies the circuit object instead of simple returning the object (it returns the QiskitCircuit from the instruction set) the ‘circuit’ is modified from the exec

qunicorn_core.core.transpiler.preprocessing_manager.preprocess_qrisp(program: str) QuantumCircuit

qrisp.QuantumCircuit needs to be included here as an import so eval works with the type

qunicorn_core.core.transpiler.preprocessing_manager.preprocess_quil(program: str) Program

execute the string to retrieve the associated python object

qunicorn_core.core.transpiler.transpiler_manager module

class qunicorn_core.core.transpiler.transpiler_manager.TranspileManager

Bases: object

get_transpiler(src_language: ~qunicorn_core.static.enums.assembler_languages.AssemblerLanguage, dest_languages: [<enum 'AssemblerLanguage'>]) any

Main method of the class that returns the method to be used to transpile to the destination language

register_transpile_method(src_language: AssemblerLanguage, dest_language: AssemblerLanguage)

Decorator to define the transpile method from a Node A (source language) to Node B (destination language)

visualize_transpile_strategy(filename)

Visualisation of the graph of the possible transpile methods between each node

class qunicorn_core.core.transpiler.transpiler_manager.TranspileStrategyStep(src_language: qunicorn_core.static.enums.assembler_languages.AssemblerLanguage, dest_language: qunicorn_core.static.enums.assembler_languages.AssemblerLanguage, transpile_method: Callable[[str], str])

Bases: object

dest_language: AssemblerLanguage
src_language: AssemblerLanguage
transpile_method: Callable[[str], str]
qunicorn_core.core.transpiler.transpiler_manager.braket_to_qasm3(source: Circuit) str
qunicorn_core.core.transpiler.transpiler_manager.digraph_dijkstra_shortest_paths()

Find the shortest path from a node

This function will generate the shortest path from a source node using Dijkstra’s algorithm.

Parameters:
  • graph (PyDiGraph) –

  • source (int) – The node index to find paths from

  • target (int) – An optional target path to find the path

  • weight_fn – An optional weight function for an edge. It will accept a single argument, the edge’s weight object and will return a float which will be used to represent the weight/cost of the edge

  • default_weight (float) – If weight_fn isn’t specified this optional float value will be used for the weight/cost of each edge.

  • as_undirected (bool) – If set to true the graph will be treated as undirected for finding the shortest path.

Returns:

Dictionary of paths. The keys are destination node indices and the dict values are lists of node indices making the path.

Return type:

dict

Raises:

ValueError – when an edge weight with NaN or negative value is provided.

qunicorn_core.core.transpiler.transpiler_manager.qasm2_to_qiskit(source: str) QuantumCircuit
qunicorn_core.core.transpiler.transpiler_manager.qasm2_to_quil(source: str) Program
qunicorn_core.core.transpiler.transpiler_manager.qasm3_to_braket(source: str) Program
qunicorn_core.core.transpiler.transpiler_manager.qasm3_to_qiskit(source: str) QuantumCircuit
qunicorn_core.core.transpiler.transpiler_manager.qiskit_to_qasm2(circuit: QuantumCircuit) str
qunicorn_core.core.transpiler.transpiler_manager.qiskit_to_qasm3(circuit: QuantumCircuit) str
qunicorn_core.core.transpiler.transpiler_manager.qrisp_to_qiskit(circuit: QuantumCircuit) Program

Module contents