modules.applications.qml.generative_modeling.mappings.library_generative.LibraryGenerative
- class LibraryGenerative(name: str)
-
This class is an abstract base class for mapping a library-agnostic gate sequence to a library such as Qiskit. It provides no concrete implementations of abstract methods and is intended to be extended by specific libraries.
- __init__(name: str)
Constructor method.
- Parameters:
name -- Name of the model
Methods
__init__(name)Constructor method.
Gets the list of available options.
get_available_submodules(option)If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.
get_default_submodule(option)Given an option string by the user, this returns a submodule.
get_depending_parameters(option, config)If the module has parameters depending on certain options, this method should return the parameters for the given option.
get_execute_circuit(circuit, backend, ...)This method combines the circuit implementation and the selected backend and returns a function that will be called during training.
Returns the parameters for a given module.
Returns the required pip packages for this module.
get_submodule(option)Submodule is instantiated according to the information given in self.sub_options.
postprocess(input_data, config, **kwargs)This method corresponds to the identity and passes the information of the subsequent module back to the preceding module in the benchmarking process.
preprocess(input_data, config, **kwargs)Base class for mapping the gate sequence to a library such as Qiskit.
select_backend(config, n_qubits)This method configures the backend.
sequence_to_circuit(input_data)Abstract method to convert a sequence into a quantum circuit.
- class Config
Bases:
TypedDictAttributes of a valid config.
backend: str n_shots: int
- clear() None. Remove all items from D.
- copy() a shallow copy of D
- fromkeys(value=None, /)
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- pop(k[, d]) v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values
- get_available_submodule_options() list
Gets the list of available options.
- Returns:
List of module options
- get_available_submodules(option: list) list
If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.
- Parameters:
option -- List of chosen options
- Returns:
List of available submodules
- abstract get_default_submodule(option: str) Core
Given an option string by the user, this returns a submodule.
- Parameters:
option -- String with the chosen submodule
- Returns:
Module of type Core
- get_depending_parameters(option: str, config: dict) dict
If the module has parameters depending on certain options, this method should return the parameters for the given option.
- Parameters:
option -- The chosen option
config -- Current config dictionary
- Returns:
The parameters for the given option
- abstract static get_execute_circuit(circuit: any, backend: any, config: str, config_dict: dict) tuple[any, any]
This method combines the circuit implementation and the selected backend and returns a function that will be called during training.
- Parameters:
circuit -- Implementation of the quantum circuit
backend -- Configured qiskit backend
config -- Name of a backend
config_dict -- Dictionary including the number of shots
- Returns:
Tuple that contains a method that executes the quantum circuit for a given set of parameters and the
transpiled circuit
- abstract get_parameter_options() dict
Returns the parameters for a given module.
Should always be in this format:
{ "parameter_name":{ "values":[1, 2, 3], "description":"How many nodes do you need?" }, "parameter_name_2":{ "values":["x", "y"], "description":"Which type of problem do you want?" } }
- Returns:
Available settings for this application
- static get_requirements() list
Returns the required pip packages for this module. Optionally, version requirements can be added.
- Returns:
List of dictionaries
- get_submodule(option: str) Core
Submodule is instantiated according to the information given in self.sub_options. If self.sub_options is None, get_default_submodule is called as a fallback.
- Parameters:
option -- String with the options
- Returns:
Instance of a module
- postprocess(input_data: dict, config: dict, **kwargs) tuple[dict, float]
This method corresponds to the identity and passes the information of the subsequent module back to the preceding module in the benchmarking process.
- Parameters:
input_data -- Collected information of the benchmarking procesS
config -- Config specifying the number of qubits of the circuit
kwargs -- Optional keyword arguments
- Returns:
Tuple with input dictionary and the computation time of the function
- preprocess(input_data: dict, config: Config, **kwargs) tuple[dict, float]
Base class for mapping the gate sequence to a library such as Qiskit.
- Parameters:
input_data -- Collection of information from the previous modules
config -- Config specifying the number of qubits of the circuit
kwargs -- Optional keyword arguments
- Returns:
Tuple including dictionary with the function to execute the quantum circuit on a simulator or quantum hardware and the computation time of the function
- abstract static select_backend(config: str, n_qubits: int) any
This method configures the backend.
- Parameters:
config -- Name of a backend
n_qubits -- Number of qubits
- Returns:
Configured backend
- abstract sequence_to_circuit(input_data: dict) dict
Abstract method to convert a sequence into a quantum circuit.
- Parameters:
input_data -- Input data representing the gate sequence
- Returns:
A dictionary representing the quantum circuit