diff --git a/qiskit/providers/aer/backends/pulse_simulator.py b/qiskit/providers/aer/backends/pulse_simulator.py index 12e803522b..8f7cf13b45 100644 --- a/qiskit/providers/aer/backends/pulse_simulator.py +++ b/qiskit/providers/aer/backends/pulse_simulator.py @@ -24,7 +24,6 @@ from qiskit.providers.models import BackendConfiguration, PulseDefaults from .aerbackend import AerBackend from ..aerjob import AerJob -from ..aererror import AerError from ..version import __version__ from ..openpulse.qobj.digest import digest_pulse_obj from ..openpulse.solver.opsolve import opsolve @@ -67,27 +66,25 @@ def __init__(self, configuration=None, provider=None): def run(self, qobj, system_model, backend_options=None, - noise_model=None, validate=False): """Run a qobj on the backend.""" # Submit job job_id = str(uuid.uuid4()) aer_job = AerJob(self, job_id, self._run_job, qobj, system_model, - backend_options, noise_model, validate) + backend_options, validate) aer_job.submit() return aer_job def _run_job(self, job_id, qobj, system_model, backend_options, - noise_model, validate): """Run a qobj job""" start = time.time() if validate: - self._validate(qobj, backend_options, noise_model) + self._validate(qobj, backend_options, noise_model=None) # Send to solver - openpulse_system = digest_pulse_obj(qobj, system_model, backend_options, noise_model) + openpulse_system = digest_pulse_obj(qobj, system_model, backend_options) results = opsolve(openpulse_system) end = time.time() return self._format_results(job_id, results, end - start, qobj.qobj_id) @@ -106,17 +103,6 @@ def _format_results(self, job_id, results, time_taken, qobj_id): output["time_taken"] = time_taken return Result.from_dict(output) - def _validate(self, qobj, backend_options, noise_model): - """Validate the pulse object. Make sure a - config has been attached in the proper location""" - - # Check to make sure a sim_config has been added - if not hasattr(qobj.config, 'sim_config'): - raise AerError('The pulse simulator qobj must have a sim_config ' - 'entry to configure the simulator') - - super()._validate(qobj, backend_options, noise_model) - def defaults(self): """Return defaults. diff --git a/qiskit/providers/aer/openpulse/qobj/digest.py b/qiskit/providers/aer/openpulse/qobj/digest.py index 9bfdf16daa..f8115fc1a4 100644 --- a/qiskit/providers/aer/openpulse/qobj/digest.py +++ b/qiskit/providers/aer/openpulse/qobj/digest.py @@ -20,6 +20,7 @@ from warnings import warn from collections import OrderedDict import numpy as np +from qiskit.providers.aer.aererror import AerError from .op_system import OPSystem from .opparse import NoiseParser from .operators import qubit_occ_oper_dressed @@ -29,7 +30,7 @@ from . import op_qobj as op -def digest_pulse_obj(qobj, system_model, backend_options=None, noise_model=None): +def digest_pulse_obj(qobj, system_model, backend_options=None): """Convert specification of a simulation in the pulse language into the format accepted by the simulator. @@ -37,7 +38,6 @@ def digest_pulse_obj(qobj, system_model, backend_options=None, noise_model=None) qobj (PulseQobj): experiment specification system_model (PulseSystemModel): object representing system model backend_options (dict): dictionary of simulation options - noise_model (dict): noise model specification Returns: out (OPSystem): object understandable by the pulse simulator Raises: @@ -53,11 +53,7 @@ def digest_pulse_obj(qobj, system_model, backend_options=None, noise_model=None) if backend_options is None: backend_options = {} - # Temp backwards compatibility - if 'sim_config' in qobj_config: - for key, val in qobj_config['sim_config'].items(): - backend_options[key] = val - qobj_config.pop('sim_config') + noise_model = backend_options.get('noise_model', None) # post warnings for unsupported features _unsupported_warnings(qobj_dict, noise_model) @@ -76,7 +72,8 @@ def digest_pulse_obj(qobj, system_model, backend_options=None, noise_model=None) if 'qubit_lo_freq' not in qobj_config: raise ValueError('qubit_lo_freq must be specified in qobj.') - qubit_lo_freq = qobj_config['qubit_lo_freq'] + # qobj frequencies are divided by 1e9, so multiply back + qubit_lo_freq = [freq * 1e9 for freq in qobj_config['qubit_lo_freq']] # Build pulse arrays *************************************************************** pulses, pulses_idx, pulse_dict = build_pulse_arrays(qobj_dict['experiments'], @@ -212,6 +209,7 @@ def _unsupported_warnings(qobj_dict, noise_model): noise_model (dict): backend_options for simulation Returns: Raises: + AerError: for unsupported features """ # Warnings that don't stop execution @@ -219,7 +217,7 @@ def _unsupported_warnings(qobj_dict, noise_model): if noise_model is not None: warn(warning_str.format('Noise models')) if _contains_pv_instruction(qobj_dict['experiments']): - warn(warning_str.format('PersistentValue instructions')) + raise AerError(warning_str.format('PersistentValue instructions')) def _contains_pv_instruction(experiments):