modules.applications.qml.generative_modeling.mappings.custom_qiskit_noisy_backend.CustomQiskitNoisyBackend
- class CustomQiskitNoisyBackend
Bases:
LibraryGenerativeThis module maps a library-agnostic gate sequence to a qiskit circuit and creates an artificial noise model.
- __init__()
Constructor method.
Methods
__init__()Constructor method.
add_quantum_errors(noise_model, config_dict)This method adds quantum errors to the respective operations in the noise model based on the provided configuration dictionary.
build_noise_model(config_dict)This method builds a noise model based on the provided configuration dictionary.
decompile_noisy_config(config_dict, num_qubits)This method processes a configuration dictionary.
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_coupling_map(config_dict, num_qubits)This method returns the coupling map based on the provided configuration dictionary and number of qubits.
get_custom_config(config_dict, num_qubits)This method creates a custom backend configuration based on the provided configuration dictionary.
get_default_submodule(option)Returns the default submodule based on the provided option.
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 qiskit circuit implementation and the selected backend and returns a function, that will be called during training.
Returns the configurable settings for the Qiskit Library.
Returns requirements of this module.
get_simulation_method_and_device(device, ...)This method specifies the simulation methode and processing unit.
get_submodule(option)Submodule is instantiated according to the information given in self.sub_options.
get_transpile_routine(transpile_config)This method returns the transpile routine based on the provided configuration.
log_backend_options(backend)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)Maps the gate sequence, that specifies the architecture of a quantum circuit to its Qiskit implementation.
split_string(s)- 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
- add_quantum_errors(noise_model: NoiseModel, config_dict: dict) None
This method adds quantum errors to the respective operations in the noise model based on the provided configuration dictionary.
- Parameters:
noise_model -- Noise model to which quantum errors are added
config_dict -- Contains information about config
- build_noise_model(config_dict: dict) NoiseModel
This method builds a noise model based on the provided configuration dictionary.
- Parameters:
config_dict -- Contains information about config
- Returns:
Constructed noise model
- decompile_noisy_config(config_dict: dict, num_qubits: int) Backend
This method processes a configuration dictionary. If a custom noise configuration is specified, it creates a custom backend configuration; otherwise, it defaults to the 'aer_simulator' backend. It returns the configured backend.
- Parameters:
config_dict -- Contains information about config
num_qubits -- Number of qubits
- Returns:
Configured qiskit backend
- 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
- get_coupling_map(config_dict: dict, num_qubits: int) CouplingMap
This method returns the coupling map based on the provided configuration dictionary and number of qubits.
- Parameters:
config_dict -- Contains information about config
num_qubits -- Number of qubits
- Returns:
Coupling map
- get_custom_config(config_dict: dict, num_qubits: int) Backend
This method creates a custom backend configuration based on the provided configuration dictionary.
- Parameters:
config_dict -- Contains information about config
num_qubits -- Number of qubits
- Returns:
Custom configured qiskit backend
- get_default_submodule(option: str) QCBM | Inference
Returns the default submodule based on the provided option.
- Parameters:
option -- The option to select the submodule
- Returns:
The selected submodule
- Raises:
NotImplemented -- If the provided option is not implemented
- 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
- get_execute_circuit(circuit: QuantumCircuit, backend: Backend, config: str, config_dict: dict) tuple[any, any]
This method combines the qiskit circuit implementation and the selected backend and returns a function, that will be called during training.
- Parameters:
circuit -- Qiskit implementation of the quantum circuit
backend -- Configured qiskit backend
config -- Name of a backend
config_dict -- Contains information about config
- Returns:
Tuple that contains a method that executes the quantum circuit for a given set of parameters and the
transpiled circuit
- get_parameter_options() dict
Returns the configurable settings for the Qiskit Library.
- Returns:
Dictionary with configurable settings
return { "backend": { "values": ["aer_simulator_gpu", "aer_simulator_cpu"], "description": "Which backend do you want to use? " "In the NoisyQiskit module only aer_simulators can be used." }, "simulation_method": { "values": ["automatic", "statevector", "density_matrix", "cpu_mps"], # TODO New names! "description": "What simulation method should be used?" }, "n_shots": { "values": [100, 1000, 10000, 1000000], "description": "How many shots do you want use for estimating the PMF of the model?" # (If 'statevector' was selected as simulation_method, 'n_shots' is only relevant for # studying generalization)" }, "transpile_optimization_level": { "values": [1, 2, 3, 0], "description": "Switch between different optimization levels in the Qiskit transpile" "routine. 1: light optimization, 2: heavy optimization, 3: even heavier optimization," "0: no optimization. Level 1 recommended as standard option." }, "noise_configuration": { "values": ['Custom configurations', 'No noise'], "description": "What noise configuration do you want to use?" }, "custom_readout_error": { "values": [0, 0.005, 0.01, 0.02, 0.05, 0.07, 0.1, 0.2], "description": "Add a custom readout error." }, "two_qubit_depolarizing_errors": { "values": [0, 0.005, 0.01, 0.02, 0.05, 0.07, 0.1, 0.2], "description": "Add a custom 2-qubit gate depolarizing error." }, "one_qubit_depolarizing_errors": { "values": [0, 0.0001, 0.0005, 0.001, 0.005, 0.007, 0.01, 0.02], "description": "Add a 1-qubit gate depolarizing error." }, "qubit_layout": { # "values": [None, 'linear', 'circle', 'fully_connected', 'ibm_brisbane'], "values": [None, 'linear', 'circle', 'fully_connected'], "description": "How should the qubits be connected in the simulated chip: coupling_map " } }
- static get_requirements() list[dict]
Returns requirements of this module.
- Returns:
List of dict with requirements of this module
- get_simulation_method_and_device(device: str, simulation_config: str) tuple[str, str]
This method specifies the simulation methode and processing unit.
- Parameters:
device -- Contains information about processing unit
simulation_config -- Contains information about qiskit simulation method
- Returns:
Tuple containing the simulation method and device
- 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
- get_transpile_routine(transpile_config: int) int
This method returns the transpile routine based on the provided configuration.
- Parameters:
transpile_config -- Configuration for transpile routine
- Returns:
Transpile routine level
- 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
- static select_backend(config: str, n_qubits: int) Backend
This method configures the backend.
- Parameters:
config -- Name of a backend
n_qubits -- Number of qubits
- Returns:
Configured qiskit backend
- sequence_to_circuit(input_data: dict) dict
Maps the gate sequence, that specifies the architecture of a quantum circuit to its Qiskit implementation.
- Parameters:
input_data -- Collected information of the benchmarking process
- Returns:
Same dictionary but the gate sequence is replaced by it Qiskit implementation