[docs]14classAerBackend(QiskitBackend):15"""16 QiskitBackend utilizing the qiskit_aer library. Runs local simulations only, utilizing CUDA capable gpus if available.17 """1819def__init__(20self,21name:Literal['local_simulator','backendv1v2'],22options:Options|None=None,23backendv1v2:BackendV1|BackendV2|None=None,24auto_transpile_level:Literal[0,1,2,3]|None=None,25simulation_method:str='automatic',26simulation_device:Literal['CPU','GPU']='CPU',27)->None:28self.method=simulation_method29self.device=simulation_device30super().__init__(name,options,backendv1v2,auto_transpile_level)3132def_set_primitives_on_backend_name(self):33ifself.name=='local_simulator':34self.simulator=AerSimulator(method=self.method,device=self.device)35elifself.name=='backendv1v2':36ifself.backendv1v2isNone:37raiseAttributeError(38'Please indicate a backend when in backendv1v2 mode.')39noise_model=NoiseModel.from_backend(self.backendv1v2)40self.simulator=AerSimulator(method=self.method,device=self.device,noise_model=noise_model)41else:42raiseValueError(43f"Unsupported mode for this backend:'{self.name}'. Please use one of the following: ['local_simulator', 'backendv1v2']")4445self.sampler=BackendSamplerV2(backend=self.simulator)46self.estimator=BackendEstimatorV2(backend=self.simulator)47self.optimizer=COBYLA()4849self._configure_auto_behavior()50
[docs]51defset_options(self,**fields):52"""Set additional options for the instance AerSimulator"""53self.simulator.set_options(**fields)