We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Scheduler should be supported in execute pipeline
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?
It should be configurable to schedule your circuit into pulses during execute.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `qiskit/execute.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # This code is part of Qiskit.
4 #
5 # (C) Copyright IBM 2017, 2019.
6 #
7 # This code is licensed under the Apache License, Version 2.0. You may
8 # obtain a copy of this license in the LICENSE.txt file in the root directory
9 # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
10 #
11 # Any modifications or derivative works of this code must retain this
12 # copyright notice, and modified files need to carry a notice indicating
13 # that they have been altered from the originals.
14 
15 """
16 =============================================
17 Executing Experiments (:mod:`qiskit.execute`)
18 =============================================
19 
20 .. currentmodule:: qiskit.execute
21 
22 .. autofunction:: execute
23 """
24 from qiskit.compiler import transpile, assemble
25 from qiskit.qobj.utils import MeasLevel, MeasReturnType
26 
27 
28 def execute(experiments, backend,
29             basis_gates=None, coupling_map=None,  # circuit transpile options
30             backend_properties=None, initial_layout=None,
31             seed_transpiler=None, optimization_level=None, pass_manager=None,
32             qobj_id=None, qobj_header=None, shots=1024,  # common run options
33             memory=False, max_credits=10, seed_simulator=None,
34             default_qubit_los=None, default_meas_los=None,  # schedule run options
35             schedule_los=None, meas_level=MeasLevel.CLASSIFIED,
36             meas_return=MeasReturnType.AVERAGE,
37             memory_slots=None, memory_slot_size=100, rep_time=None, parameter_binds=None,
38             **run_config):
39     """Execute a list of :class:`qiskit.circuit.QuantumCircuit` or
40     :class:`qiskit.pulse.Schedule` on a backend.
41 
42     The execution is asynchronous, and a handle to a job instance is returned.
43 
44     Args:
45         experiments (QuantumCircuit or list[QuantumCircuit] or Schedule or list[Schedule]):
46             Circuit(s) or pulse schedule(s) to execute
47 
48         backend (BaseBackend):
49             Backend to execute circuits on.
50             Transpiler options are automatically grabbed from
51             backend.configuration() and backend.properties().
52             If any other option is explicitly set (e.g. coupling_map), it
53             will override the backend's.
54 
55         basis_gates (list[str]):
56             List of basis gate names to unroll to.
57             e.g:
58                 ['u1', 'u2', 'u3', 'cx']
59             If None, do not unroll.
60 
61         coupling_map (CouplingMap or list):
62             Coupling map (perhaps custom) to target in mapping.
63             Multiple formats are supported:
64             a. CouplingMap instance
65 
66             b. list
67                 Must be given as an adjacency matrix, where each entry
68                 specifies all two-qubit interactions supported by backend
69                 e.g:
70                     [[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]
71 
72         backend_properties (BackendProperties):
73             Properties returned by a backend, including information on gate
74             errors, readout errors, qubit coherence times, etc. Find a backend
75             that provides this information with:
76             ``backend.properties()``
77 
78         initial_layout (Layout or dict or list):
79             Initial position of virtual qubits on physical qubits.
80             If this layout makes the circuit compatible with the coupling_map
81             constraints, it will be used.
82             The final layout is not guaranteed to be the same, as the transpiler
83             may permute qubits through swaps or other means.
84 
85             Multiple formats are supported:
86             a. Layout instance
87 
88             b. dict
89                 virtual to physical:
90                     {qr[0]: 0,
91                      qr[1]: 3,
92                      qr[2]: 5}
93 
94                 physical to virtual:
95                     {0: qr[0],
96                      3: qr[1],
97                      5: qr[2]}
98 
99             c. list
100                 virtual to physical:
101                     [0, 3, 5]  # virtual qubits are ordered (in addition to named)
102 
103                 physical to virtual:
104                     [qr[0], None, None, qr[1], None, qr[2]]
105 
106         seed_transpiler (int):
107             Sets random seed for the stochastic parts of the transpiler
108 
109         optimization_level (int):
110             How much optimization to perform on the circuits.
111             Higher levels generate more optimized circuits,
112             at the expense of longer transpilation time.
113                 0: No optimization
114                 1: Light optimization
115                 2: Heavy optimization
116                 3: Highest optimization
117             If None, level 1 will be chosen as default.
118 
119         pass_manager (PassManager):
120             The pass manager to use during transpilation. If this arg is present,
121             auto-selection of pass manager based on the transpile options will be
122             turned off and this pass manager will be used directly.
123 
124         qobj_id (str):
125             String identifier to annotate the Qobj
126 
127         qobj_header (QobjHeader or dict):
128             User input that will be inserted in Qobj header, and will also be
129             copied to the corresponding Result header. Headers do not affect the run.
130 
131         shots (int):
132             Number of repetitions of each circuit, for sampling. Default: 1024
133 
134         memory (bool):
135             If True, per-shot measurement bitstrings are returned as well
136             (provided the backend supports it). For OpenPulse jobs, only
137             measurement level 2 supports this option. Default: False
138 
139         max_credits (int):
140             Maximum credits to spend on job. Default: 10
141 
142         seed_simulator (int):
143             Random seed to control sampling, for when backend is a simulator
144 
145         default_qubit_los (list):
146             List of default qubit LO frequencies in Hz
147 
148         default_meas_los (list):
149             List of default meas LO frequencies in Hz
150 
151         schedule_los (None or list[Union[Dict[PulseChannel, float], LoConfig]] or \
152                       Union[Dict[PulseChannel, float], LoConfig]):
153             Experiment LO configurations
154 
155         meas_level (int or MeasLevel):
156             Set the appropriate level of the measurement output for pulse experiments.
157 
158         meas_return (str or MeasReturn):
159             Level of measurement data for the backend to return
160             For `meas_level` 0 and 1:
161                 "single" returns information from every shot.
162                 "avg" returns average measurement output (averaged over number of shots).
163 
164         memory_slots (int):
165             Number of classical memory slots used in this job.
166 
167         memory_slot_size (int):
168             Size of each memory slot if the output is Level 0.
169 
170         rep_time (int): repetition time of the experiment in μs.
171             The delay between experiments will be rep_time.
172             Must be from the list provided by the device.
173 
174         parameter_binds (list[dict]):
175             List of Parameter bindings over which the set of experiments will be
176             executed. Each list element (bind) should be of the form
177             {Parameter1: value1, Parameter2: value2, ...}. All binds will be
178             executed across all experiments, e.g. if parameter_binds is a
179             length-n list, and there are m experiments, a total of m x n
180             experiments will be run (one for each experiment/bind pair).
181 
182         run_config (dict):
183             Extra arguments used to configure the run (e.g. for Aer configurable backends).
184             Refer to the backend documentation for details on these arguments.
185             Note: for now, these keyword arguments will both be copied to the
186             Qobj config, and passed to backend.run()
187 
188     Returns:
189         BaseJob: returns job instance derived from BaseJob
190 
191     Raises:
192         QiskitError: if the execution cannot be interpreted as either circuits or schedules
193 
194     Example:
195         Construct a 5-qubit GHZ circuit and execute 4321 shots on a backend.
196 
197         .. jupyter-execute::
198 
199             from qiskit import QuantumCircuit, execute, BasicAer
200 
201             backend = BasicAer.get_backend('qasm_simulator')
202 
203             qc = QuantumCircuit(5, 5)
204             qc.h(0)
205             qc.cx(0, range(1, 5))
206             qc.measure_all()
207 
208             job = execute(qc, backend, shots=4321)
209     """
210 
211     # transpiling the circuits using given transpile options
212     experiments = transpile(experiments,
213                             basis_gates=basis_gates,
214                             coupling_map=coupling_map,
215                             backend_properties=backend_properties,
216                             initial_layout=initial_layout,
217                             seed_transpiler=seed_transpiler,
218                             optimization_level=optimization_level,
219                             backend=backend,
220                             pass_manager=pass_manager,
221                             )
222 
223     # assembling the circuits into a qobj to be run on the backend
224     qobj = assemble(experiments,
225                     qobj_id=qobj_id,
226                     qobj_header=qobj_header,
227                     shots=shots,
228                     memory=memory,
229                     max_credits=max_credits,
230                     seed_simulator=seed_simulator,
231                     default_qubit_los=default_qubit_los,
232                     default_meas_los=default_meas_los,
233                     schedule_los=schedule_los,
234                     meas_level=meas_level,
235                     meas_return=meas_return,
236                     memory_slots=memory_slots,
237                     memory_slot_size=memory_slot_size,
238                     rep_time=rep_time,
239                     parameter_binds=parameter_binds,
240                     backend=backend,
241                     **run_config
242                     )
243 
244     # executing the circuits on the backend and returning the job
245     return backend.run(qobj, **run_config)
246
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/qiskit/execute.py b/qiskit/execute.py
--- a/qiskit/execute.py
+++ b/qiskit/execute.py
@@ -21,8 +21,10 @@
 
 .. autofunction:: execute
 """
-from qiskit.compiler import transpile, assemble
+from qiskit.compiler import transpile, assemble, schedule
 from qiskit.qobj.utils import MeasLevel, MeasReturnType
+from qiskit.pulse import Schedule
+from qiskit.exceptions import QiskitError
 
 
 def execute(experiments, backend,
@@ -35,6 +37,7 @@
             schedule_los=None, meas_level=MeasLevel.CLASSIFIED,
             meas_return=MeasReturnType.AVERAGE,
             memory_slots=None, memory_slot_size=100, rep_time=None, parameter_binds=None,
+            schedule_circuit=False, inst_map=None, meas_map=None, scheduling_method=None,
             **run_config):
     """Execute a list of :class:`qiskit.circuit.QuantumCircuit` or
     :class:`qiskit.pulse.Schedule` on a backend.
@@ -179,6 +182,21 @@
             length-n list, and there are m experiments, a total of m x n
             experiments will be run (one for each experiment/bind pair).
 
+        schedule_circuit (bool):
+            If ``True``, ``experiments`` will be converted to ``Schedule``s prior to
+            execution.
+
+        inst_map (InstructionScheduleMap):
+            Mapping of circuit operations to pulse schedules. If None, defaults to the
+            ``instruction_schedule_map`` of ``backend``.
+
+        meas_map (list(list(int))):
+            List of sets of qubits that must be measured together. If None, defaults to
+            the ``meas_map`` of ``backend``.
+
+        scheduling_method (str or list(str)):
+            Optionally specify a particular scheduling method.
+
         run_config (dict):
             Extra arguments used to configure the run (e.g. for Aer configurable backends).
             Refer to the backend documentation for details on these arguments.
@@ -220,6 +238,16 @@
                             pass_manager=pass_manager,
                             )
 
+    if schedule_circuit:
+        if isinstance(experiments, Schedule) or isinstance(experiments[0], Schedule):
+            raise QiskitError("Must supply QuantumCircuit to schedule circuit.")
+        experiments = schedule(circuits=experiments,
+                               backend=backend,
+                               inst_map=inst_map,
+                               meas_map=meas_map,
+                               method=scheduling_method
+                               )
+
     # assembling the circuits into a qobj to be run on the backend
     qobj = assemble(experiments,
                     qobj_id=qobj_id,

{"golden_diff": "diff --git a/qiskit/execute.py b/qiskit/execute.py\n--- a/qiskit/execute.py\n+++ b/qiskit/execute.py\n@@ -21,8 +21,10 @@\n \n .. autofunction:: execute\n \"\"\"\n-from qiskit.compiler import transpile, assemble\n+from qiskit.compiler import transpile, assemble, schedule\n from qiskit.qobj.utils import MeasLevel, MeasReturnType\n+from qiskit.pulse import Schedule\n+from qiskit.exceptions import QiskitError\n \n \n def execute(experiments, backend,\n@@ -35,6 +37,7 @@\n             schedule_los=None, meas_level=MeasLevel.CLASSIFIED,\n             meas_return=MeasReturnType.AVERAGE,\n             memory_slots=None, memory_slot_size=100, rep_time=None, parameter_binds=None,\n+            schedule_circuit=False, inst_map=None, meas_map=None, scheduling_method=None,\n             **run_config):\n     \"\"\"Execute a list of :class:`qiskit.circuit.QuantumCircuit` or\n     :class:`qiskit.pulse.Schedule` on a backend.\n@@ -179,6 +182,21 @@\n             length-n list, and there are m experiments, a total of m x n\n             experiments will be run (one for each experiment/bind pair).\n \n+        schedule_circuit (bool):\n+            If ``True``, ``experiments`` will be converted to ``Schedule``s prior to\n+            execution.\n+\n+        inst_map (InstructionScheduleMap):\n+            Mapping of circuit operations to pulse schedules. If None, defaults to the\n+            ``instruction_schedule_map`` of ``backend``.\n+\n+        meas_map (list(list(int))):\n+            List of sets of qubits that must be measured together. If None, defaults to\n+            the ``meas_map`` of ``backend``.\n+\n+        scheduling_method (str or list(str)):\n+            Optionally specify a particular scheduling method.\n+\n         run_config (dict):\n             Extra arguments used to configure the run (e.g. for Aer configurable backends).\n             Refer to the backend documentation for details on these arguments.\n@@ -220,6 +238,16 @@\n                             pass_manager=pass_manager,\n                             )\n \n+    if schedule_circuit:\n+        if isinstance(experiments, Schedule) or isinstance(experiments[0], Schedule):\n+            raise QiskitError(\"Must supply QuantumCircuit to schedule circuit.\")\n+        experiments = schedule(circuits=experiments,\n+                               backend=backend,\n+                               inst_map=inst_map,\n+                               meas_map=meas_map,\n+                               method=scheduling_method\n+                               )\n+\n     # assembling the circuits into a qobj to be run on the backend\n     qobj = assemble(experiments,\n                     qobj_id=qobj_id,\n", "issue": "Scheduler should be supported in execute pipeline\n<!-- \u26a0\ufe0f If you do not respect this template, your issue will be closed -->\r\n<!-- \u26a0\ufe0f Make sure to browse the opened and closed issues to confirm this idea does not exist. -->\r\n\r\n### What is the expected enhancement?\r\nIt should be configurable to schedule your circuit into pulses during execute.\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017, 2019.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n\"\"\"\n=============================================\nExecuting Experiments (:mod:`qiskit.execute`)\n=============================================\n\n.. currentmodule:: qiskit.execute\n\n.. autofunction:: execute\n\"\"\"\nfrom qiskit.compiler import transpile, assemble\nfrom qiskit.qobj.utils import MeasLevel, MeasReturnType\n\n\ndef execute(experiments, backend,\n            basis_gates=None, coupling_map=None,  # circuit transpile options\n            backend_properties=None, initial_layout=None,\n            seed_transpiler=None, optimization_level=None, pass_manager=None,\n            qobj_id=None, qobj_header=None, shots=1024,  # common run options\n            memory=False, max_credits=10, seed_simulator=None,\n            default_qubit_los=None, default_meas_los=None,  # schedule run options\n            schedule_los=None, meas_level=MeasLevel.CLASSIFIED,\n            meas_return=MeasReturnType.AVERAGE,\n            memory_slots=None, memory_slot_size=100, rep_time=None, parameter_binds=None,\n            **run_config):\n    \"\"\"Execute a list of :class:`qiskit.circuit.QuantumCircuit` or\n    :class:`qiskit.pulse.Schedule` on a backend.\n\n    The execution is asynchronous, and a handle to a job instance is returned.\n\n    Args:\n        experiments (QuantumCircuit or list[QuantumCircuit] or Schedule or list[Schedule]):\n            Circuit(s) or pulse schedule(s) to execute\n\n        backend (BaseBackend):\n            Backend to execute circuits on.\n            Transpiler options are automatically grabbed from\n            backend.configuration() and backend.properties().\n            If any other option is explicitly set (e.g. coupling_map), it\n            will override the backend's.\n\n        basis_gates (list[str]):\n            List of basis gate names to unroll to.\n            e.g:\n                ['u1', 'u2', 'u3', 'cx']\n            If None, do not unroll.\n\n        coupling_map (CouplingMap or list):\n            Coupling map (perhaps custom) to target in mapping.\n            Multiple formats are supported:\n            a. CouplingMap instance\n\n            b. list\n                Must be given as an adjacency matrix, where each entry\n                specifies all two-qubit interactions supported by backend\n                e.g:\n                    [[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]\n\n        backend_properties (BackendProperties):\n            Properties returned by a backend, including information on gate\n            errors, readout errors, qubit coherence times, etc. Find a backend\n            that provides this information with:\n            ``backend.properties()``\n\n        initial_layout (Layout or dict or list):\n            Initial position of virtual qubits on physical qubits.\n            If this layout makes the circuit compatible with the coupling_map\n            constraints, it will be used.\n            The final layout is not guaranteed to be the same, as the transpiler\n            may permute qubits through swaps or other means.\n\n            Multiple formats are supported:\n            a. Layout instance\n\n            b. dict\n                virtual to physical:\n                    {qr[0]: 0,\n                     qr[1]: 3,\n                     qr[2]: 5}\n\n                physical to virtual:\n                    {0: qr[0],\n                     3: qr[1],\n                     5: qr[2]}\n\n            c. list\n                virtual to physical:\n                    [0, 3, 5]  # virtual qubits are ordered (in addition to named)\n\n                physical to virtual:\n                    [qr[0], None, None, qr[1], None, qr[2]]\n\n        seed_transpiler (int):\n            Sets random seed for the stochastic parts of the transpiler\n\n        optimization_level (int):\n            How much optimization to perform on the circuits.\n            Higher levels generate more optimized circuits,\n            at the expense of longer transpilation time.\n                0: No optimization\n                1: Light optimization\n                2: Heavy optimization\n                3: Highest optimization\n            If None, level 1 will be chosen as default.\n\n        pass_manager (PassManager):\n            The pass manager to use during transpilation. If this arg is present,\n            auto-selection of pass manager based on the transpile options will be\n            turned off and this pass manager will be used directly.\n\n        qobj_id (str):\n            String identifier to annotate the Qobj\n\n        qobj_header (QobjHeader or dict):\n            User input that will be inserted in Qobj header, and will also be\n            copied to the corresponding Result header. Headers do not affect the run.\n\n        shots (int):\n            Number of repetitions of each circuit, for sampling. Default: 1024\n\n        memory (bool):\n            If True, per-shot measurement bitstrings are returned as well\n            (provided the backend supports it). For OpenPulse jobs, only\n            measurement level 2 supports this option. Default: False\n\n        max_credits (int):\n            Maximum credits to spend on job. Default: 10\n\n        seed_simulator (int):\n            Random seed to control sampling, for when backend is a simulator\n\n        default_qubit_los (list):\n            List of default qubit LO frequencies in Hz\n\n        default_meas_los (list):\n            List of default meas LO frequencies in Hz\n\n        schedule_los (None or list[Union[Dict[PulseChannel, float], LoConfig]] or \\\n                      Union[Dict[PulseChannel, float], LoConfig]):\n            Experiment LO configurations\n\n        meas_level (int or MeasLevel):\n            Set the appropriate level of the measurement output for pulse experiments.\n\n        meas_return (str or MeasReturn):\n            Level of measurement data for the backend to return\n            For `meas_level` 0 and 1:\n                \"single\" returns information from every shot.\n                \"avg\" returns average measurement output (averaged over number of shots).\n\n        memory_slots (int):\n            Number of classical memory slots used in this job.\n\n        memory_slot_size (int):\n            Size of each memory slot if the output is Level 0.\n\n        rep_time (int): repetition time of the experiment in \u03bcs.\n            The delay between experiments will be rep_time.\n            Must be from the list provided by the device.\n\n        parameter_binds (list[dict]):\n            List of Parameter bindings over which the set of experiments will be\n            executed. Each list element (bind) should be of the form\n            {Parameter1: value1, Parameter2: value2, ...}. All binds will be\n            executed across all experiments, e.g. if parameter_binds is a\n            length-n list, and there are m experiments, a total of m x n\n            experiments will be run (one for each experiment/bind pair).\n\n        run_config (dict):\n            Extra arguments used to configure the run (e.g. for Aer configurable backends).\n            Refer to the backend documentation for details on these arguments.\n            Note: for now, these keyword arguments will both be copied to the\n            Qobj config, and passed to backend.run()\n\n    Returns:\n        BaseJob: returns job instance derived from BaseJob\n\n    Raises:\n        QiskitError: if the execution cannot be interpreted as either circuits or schedules\n\n    Example:\n        Construct a 5-qubit GHZ circuit and execute 4321 shots on a backend.\n\n        .. jupyter-execute::\n\n            from qiskit import QuantumCircuit, execute, BasicAer\n\n            backend = BasicAer.get_backend('qasm_simulator')\n\n            qc = QuantumCircuit(5, 5)\n            qc.h(0)\n            qc.cx(0, range(1, 5))\n            qc.measure_all()\n\n            job = execute(qc, backend, shots=4321)\n    \"\"\"\n\n    # transpiling the circuits using given transpile options\n    experiments = transpile(experiments,\n                            basis_gates=basis_gates,\n                            coupling_map=coupling_map,\n                            backend_properties=backend_properties,\n                            initial_layout=initial_layout,\n                            seed_transpiler=seed_transpiler,\n                            optimization_level=optimization_level,\n                            backend=backend,\n                            pass_manager=pass_manager,\n                            )\n\n    # assembling the circuits into a qobj to be run on the backend\n    qobj = assemble(experiments,\n                    qobj_id=qobj_id,\n                    qobj_header=qobj_header,\n                    shots=shots,\n                    memory=memory,\n                    max_credits=max_credits,\n                    seed_simulator=seed_simulator,\n                    default_qubit_los=default_qubit_los,\n                    default_meas_los=default_meas_los,\n                    schedule_los=schedule_los,\n                    meas_level=meas_level,\n                    meas_return=meas_return,\n                    memory_slots=memory_slots,\n                    memory_slot_size=memory_slot_size,\n                    rep_time=rep_time,\n                    parameter_binds=parameter_binds,\n                    backend=backend,\n                    **run_config\n                    )\n\n    # executing the circuits on the backend and returning the job\n    return backend.run(qobj, **run_config)\n", "path": "qiskit/execute.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017, 2019.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n\"\"\"\n=============================================\nExecuting Experiments (:mod:`qiskit.execute`)\n=============================================\n\n.. currentmodule:: qiskit.execute\n\n.. autofunction:: execute\n\"\"\"\nfrom qiskit.compiler import transpile, assemble, schedule\nfrom qiskit.qobj.utils import MeasLevel, MeasReturnType\nfrom qiskit.pulse import Schedule\nfrom qiskit.exceptions import QiskitError\n\n\ndef execute(experiments, backend,\n            basis_gates=None, coupling_map=None,  # circuit transpile options\n            backend_properties=None, initial_layout=None,\n            seed_transpiler=None, optimization_level=None, pass_manager=None,\n            qobj_id=None, qobj_header=None, shots=1024,  # common run options\n            memory=False, max_credits=10, seed_simulator=None,\n            default_qubit_los=None, default_meas_los=None,  # schedule run options\n            schedule_los=None, meas_level=MeasLevel.CLASSIFIED,\n            meas_return=MeasReturnType.AVERAGE,\n            memory_slots=None, memory_slot_size=100, rep_time=None, parameter_binds=None,\n            schedule_circuit=False, inst_map=None, meas_map=None, scheduling_method=None,\n            **run_config):\n    \"\"\"Execute a list of :class:`qiskit.circuit.QuantumCircuit` or\n    :class:`qiskit.pulse.Schedule` on a backend.\n\n    The execution is asynchronous, and a handle to a job instance is returned.\n\n    Args:\n        experiments (QuantumCircuit or list[QuantumCircuit] or Schedule or list[Schedule]):\n            Circuit(s) or pulse schedule(s) to execute\n\n        backend (BaseBackend):\n            Backend to execute circuits on.\n            Transpiler options are automatically grabbed from\n            backend.configuration() and backend.properties().\n            If any other option is explicitly set (e.g. coupling_map), it\n            will override the backend's.\n\n        basis_gates (list[str]):\n            List of basis gate names to unroll to.\n            e.g:\n                ['u1', 'u2', 'u3', 'cx']\n            If None, do not unroll.\n\n        coupling_map (CouplingMap or list):\n            Coupling map (perhaps custom) to target in mapping.\n            Multiple formats are supported:\n            a. CouplingMap instance\n\n            b. list\n                Must be given as an adjacency matrix, where each entry\n                specifies all two-qubit interactions supported by backend\n                e.g:\n                    [[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]\n\n        backend_properties (BackendProperties):\n            Properties returned by a backend, including information on gate\n            errors, readout errors, qubit coherence times, etc. Find a backend\n            that provides this information with:\n            ``backend.properties()``\n\n        initial_layout (Layout or dict or list):\n            Initial position of virtual qubits on physical qubits.\n            If this layout makes the circuit compatible with the coupling_map\n            constraints, it will be used.\n            The final layout is not guaranteed to be the same, as the transpiler\n            may permute qubits through swaps or other means.\n\n            Multiple formats are supported:\n            a. Layout instance\n\n            b. dict\n                virtual to physical:\n                    {qr[0]: 0,\n                     qr[1]: 3,\n                     qr[2]: 5}\n\n                physical to virtual:\n                    {0: qr[0],\n                     3: qr[1],\n                     5: qr[2]}\n\n            c. list\n                virtual to physical:\n                    [0, 3, 5]  # virtual qubits are ordered (in addition to named)\n\n                physical to virtual:\n                    [qr[0], None, None, qr[1], None, qr[2]]\n\n        seed_transpiler (int):\n            Sets random seed for the stochastic parts of the transpiler\n\n        optimization_level (int):\n            How much optimization to perform on the circuits.\n            Higher levels generate more optimized circuits,\n            at the expense of longer transpilation time.\n                0: No optimization\n                1: Light optimization\n                2: Heavy optimization\n                3: Highest optimization\n            If None, level 1 will be chosen as default.\n\n        pass_manager (PassManager):\n            The pass manager to use during transpilation. If this arg is present,\n            auto-selection of pass manager based on the transpile options will be\n            turned off and this pass manager will be used directly.\n\n        qobj_id (str):\n            String identifier to annotate the Qobj\n\n        qobj_header (QobjHeader or dict):\n            User input that will be inserted in Qobj header, and will also be\n            copied to the corresponding Result header. Headers do not affect the run.\n\n        shots (int):\n            Number of repetitions of each circuit, for sampling. Default: 1024\n\n        memory (bool):\n            If True, per-shot measurement bitstrings are returned as well\n            (provided the backend supports it). For OpenPulse jobs, only\n            measurement level 2 supports this option. Default: False\n\n        max_credits (int):\n            Maximum credits to spend on job. Default: 10\n\n        seed_simulator (int):\n            Random seed to control sampling, for when backend is a simulator\n\n        default_qubit_los (list):\n            List of default qubit LO frequencies in Hz\n\n        default_meas_los (list):\n            List of default meas LO frequencies in Hz\n\n        schedule_los (None or list[Union[Dict[PulseChannel, float], LoConfig]] or \\\n                      Union[Dict[PulseChannel, float], LoConfig]):\n            Experiment LO configurations\n\n        meas_level (int or MeasLevel):\n            Set the appropriate level of the measurement output for pulse experiments.\n\n        meas_return (str or MeasReturn):\n            Level of measurement data for the backend to return\n            For `meas_level` 0 and 1:\n                \"single\" returns information from every shot.\n                \"avg\" returns average measurement output (averaged over number of shots).\n\n        memory_slots (int):\n            Number of classical memory slots used in this job.\n\n        memory_slot_size (int):\n            Size of each memory slot if the output is Level 0.\n\n        rep_time (int): repetition time of the experiment in \u03bcs.\n            The delay between experiments will be rep_time.\n            Must be from the list provided by the device.\n\n        parameter_binds (list[dict]):\n            List of Parameter bindings over which the set of experiments will be\n            executed. Each list element (bind) should be of the form\n            {Parameter1: value1, Parameter2: value2, ...}. All binds will be\n            executed across all experiments, e.g. if parameter_binds is a\n            length-n list, and there are m experiments, a total of m x n\n            experiments will be run (one for each experiment/bind pair).\n\n        schedule_circuit (bool):\n            If ``True``, ``experiments`` will be converted to ``Schedule``s prior to\n            execution.\n\n        inst_map (InstructionScheduleMap):\n            Mapping of circuit operations to pulse schedules. If None, defaults to the\n            ``instruction_schedule_map`` of ``backend``.\n\n        meas_map (list(list(int))):\n            List of sets of qubits that must be measured together. If None, defaults to\n            the ``meas_map`` of ``backend``.\n\n        scheduling_method (str or list(str)):\n            Optionally specify a particular scheduling method.\n\n        run_config (dict):\n            Extra arguments used to configure the run (e.g. for Aer configurable backends).\n            Refer to the backend documentation for details on these arguments.\n            Note: for now, these keyword arguments will both be copied to the\n            Qobj config, and passed to backend.run()\n\n    Returns:\n        BaseJob: returns job instance derived from BaseJob\n\n    Raises:\n        QiskitError: if the execution cannot be interpreted as either circuits or schedules\n\n    Example:\n        Construct a 5-qubit GHZ circuit and execute 4321 shots on a backend.\n\n        .. jupyter-execute::\n\n            from qiskit import QuantumCircuit, execute, BasicAer\n\n            backend = BasicAer.get_backend('qasm_simulator')\n\n            qc = QuantumCircuit(5, 5)\n            qc.h(0)\n            qc.cx(0, range(1, 5))\n            qc.measure_all()\n\n            job = execute(qc, backend, shots=4321)\n    \"\"\"\n\n    # transpiling the circuits using given transpile options\n    experiments = transpile(experiments,\n                            basis_gates=basis_gates,\n                            coupling_map=coupling_map,\n                            backend_properties=backend_properties,\n                            initial_layout=initial_layout,\n                            seed_transpiler=seed_transpiler,\n                            optimization_level=optimization_level,\n                            backend=backend,\n                            pass_manager=pass_manager,\n                            )\n\n    if schedule_circuit:\n        if isinstance(experiments, Schedule) or isinstance(experiments[0], Schedule):\n            raise QiskitError(\"Must supply QuantumCircuit to schedule circuit.\")\n        experiments = schedule(circuits=experiments,\n                               backend=backend,\n                               inst_map=inst_map,\n                               meas_map=meas_map,\n                               method=scheduling_method\n                               )\n\n    # assembling the circuits into a qobj to be run on the backend\n    qobj = assemble(experiments,\n                    qobj_id=qobj_id,\n                    qobj_header=qobj_header,\n                    shots=shots,\n                    memory=memory,\n                    max_credits=max_credits,\n                    seed_simulator=seed_simulator,\n                    default_qubit_los=default_qubit_los,\n                    default_meas_los=default_meas_los,\n                    schedule_los=schedule_los,\n                    meas_level=meas_level,\n                    meas_return=meas_return,\n                    memory_slots=memory_slots,\n                    memory_slot_size=memory_slot_size,\n                    rep_time=rep_time,\n                    parameter_binds=parameter_binds,\n                    backend=backend,\n                    **run_config\n                    )\n\n    # executing the circuits on the backend and returning the job\n    return backend.run(qobj, **run_config)\n", "path": "qiskit/execute.py"}]}