transpiler
¶
DefaultTranspilerLibAlreadyRegisteredError
¶
Raised when a default transpiler_lib is already registered.
OuquTpTranspiler
¶
OuquTpTranspiler(program_lib: str)
Transpile quantum circuits using ouqu-tp.
It optimizes quantum circuits using ouqu-tp's transpilation function.
program_lib
property
¶
program_lib: str
Returns the program format that this transpiler handles.
Returns:
-
str(str) –The program format identifier (e.g., "qiskit", "tket").
transpile
¶
transpile(program: str, options: dict | None = None, device: str | None = None) -> TranspileResult
Transpile the specified quantum circuit and return a TranspileResult.
Parameters:
-
program(str) –The quantum circuit to transpile.
-
options(dict, default:None) –Transpilation options. Defaults to an empty dictionary.
-
device(Any, default:None) –The target device for transpilation. Defaults to None.
Returns:
-
TranspileResult(TranspileResult) –An object containing the transpilation result, including the transpiled quantum circuit, statistics, and the mapping of virtual qubits to physical qubits.
QiskitTranspiler
¶
QiskitTranspiler(program_lib: str)
Transpile quantum circuits using Qiskit.
It optimizes quantum circuits using Qiskit's transpile() function.
program_lib
property
¶
program_lib: str
Returns the program format that this transpiler handles.
Returns:
-
str(str) –The program format identifier (e.g., "qiskit", "tket").
transpile
¶
transpile(program: QuantumCircuit, options: dict | None = None, device: BackendV2 | None = None) -> TranspileResult
Transpile the specified quantum circuit and return a TranspileResult.
Parameters:
-
program(QuantumCircuit) –The quantum circuit to transpile.
-
options(dict, default:None) –Transpilation options. Defaults to an empty dictionary.
-
device(BackendV2, default:None) –The target device for transpilation. Defaults to None.
Returns:
-
TranspileResult(TranspileResult) –An object containing the transpilation result, including the transpiled quantum circuit, statistics, and the mapping of virtual qubits to physical qubits.
TketTranspiler
¶
TketTranspiler(program_lib: str)
Transpile quantum circuits using t|ket>.
program_lib
property
¶
program_lib: str
Returns the program format that this transpiler handles.
Returns:
-
str(str) –The program format identifier (e.g., "qiskit", "tket").
transpile
¶
transpile(program: Circuit, options: dict[str, Any] | None = None, device: Backend | None = None) -> TranspileResult
Transpile the program using tket.
Parameters:
-
program(Circuit) –Program to transpile.
-
options(dict[str, Any] | None, default:None) –Options for transpilation.
-
device(Backend | None, default:None) –Device information.
Returns:
-
TranspileResult(TranspileResult) –Result of transpilation.
Raises:
-
ValueError–If optimization_level is not 0, 1, or 2.
Transpiler
¶
Transpiler(program_lib: str)
Abstract base class for transpiling specified quantum circuits.
This class provides an abstract method to transpile a given quantum circuit and
return a TranspileResult.
The specific implementation of the transpiler must be defined in subclasses.
Parameters:
-
program_lib(str) –The program format that this transpiler handles.
program_lib
property
¶
program_lib: str
Returns the program format that this transpiler handles.
Returns:
-
str(str) –The program format identifier (e.g., "qiskit", "tket").
transpile
abstractmethod
¶
transpile(program: Any, options: dict | None = None, device: Any | None = None) -> TranspileResult
Abstract method to transpile the specified quantum circuit.
This method transpiles the given quantum circuit and
returns a TranspileResult.
The specific implementation of the transpilation must be defined in subclasses.
Parameters:
-
program(Any) –The circuit object or code converted to the transpiler's target (e.g., Qiskit, Tket, OpenQASM3, etc.).
-
options(dict | None, default:None) –Transpilation options. Defaults to an empty dictionary.
-
device(Any | None, default:None) –The target device for transpilation. Defaults to None.
Returns:
-
TranspileResult(TranspileResult) –The result of the transpilation, including the transpiled quantum circuit, statistical information, and mapping between virtual and physical quantum bits.
TranspilerAlreadyRegisteredError
¶
Raised when attempting to register a transpiler that already exists.
TranspilerManager
¶
TranspilerManager()
Manages the registration and retrieval of transpilers.
This class allows for the registration of different transpiler instances and provides methods to fetch them by their library names.
fetch_transpiler
¶
fetch_transpiler(transpiler_lib: str) -> Any
Fetch a registered transpiler by its library name.
Parameters:
-
transpiler_lib(str) –The name of the transpiler library to fetch.
Returns:
-
Any(Any) –An instance of the requested transpiler.
Raises:
-
TranspilerNotFoundError–If no transpiler with the given name is found.
get_default_transpiler_lib
¶
get_default_transpiler_lib() -> str | None
Get the default transpiler library.
Returns:
-
str(str | None) –The default transpiler library.
register_default_transpiler_lib
¶
register_default_transpiler_lib(default_transpiler_lib: str, *, allow_override: bool = False) -> None
Register the default transpiler library.
Parameters:
-
default_transpiler_lib(str) –The name of the default transpiler library to register.
-
allow_override(bool, default:False) –When False, prevents overwriting existing registrations. Defaults to False.
Raises:
-
DefaultTranspilerLibAlreadyRegisteredError–If a transpiler with the same name is already registered and allow_override is False.
register_transpiler
¶
register_transpiler(transpiler_lib: str, transpiler: Any, *, allow_override: bool = False) -> None
Register a new transpiler.
Parameters:
-
transpiler_lib(str) –The name of the transpiler library to register.
-
transpiler(Any) –An instance of the Transpiler to register.
-
allow_override(bool, default:False) –When False, prevents overwriting existing registrations. Defaults to False.
Raises:
-
TranspilerAlreadyRegisteredError–If a transpiler with the same name is already registered and allow_override is False.
TranspilerNotFoundError
¶
Raised when the requested transpiler is not found.