|
17 | 17 | from typing import Any, Dict, List, Tuple
|
18 | 18 |
|
19 | 19 | from qiskit.exceptions import QiskitError
|
20 |
| -from qiskit.pulse import Schedule, Delay, Acquire |
| 20 | +from qiskit.pulse import Schedule, Acquire, Delay, Play |
| 21 | +from qiskit.pulse.pulse_lib import ParametricPulse, SamplePulse |
21 | 22 | from qiskit.pulse.commands import (Command, PulseInstruction, AcquireInstruction,
|
22 |
| - DelayInstruction, SamplePulse, ParametricInstruction) |
| 23 | + DelayInstruction, ParametricInstruction) |
23 | 24 | from qiskit.qobj import (PulseQobj, QobjHeader, QobjExperimentHeader,
|
24 | 25 | PulseQobjInstruction, PulseQobjExperimentConfig,
|
25 | 26 | PulseQobjExperiment, PulseQobjConfig, PulseLibraryItem)
|
@@ -170,15 +171,31 @@ def _assemble_instructions(
|
170 | 171 | acquire_instruction_map = defaultdict(list)
|
171 | 172 | for time, instruction in schedule.instructions:
|
172 | 173 |
|
173 |
| - if isinstance(instruction, ParametricInstruction): |
| 174 | + if isinstance(instruction, Play) and isinstance(instruction.pulse, ParametricPulse): |
| 175 | + pulse_shape = ParametricPulseShapes(type(instruction.pulse)).name |
| 176 | + if pulse_shape not in run_config.parametric_pulses: |
| 177 | + instruction = Play(instruction.pulse.get_sample_pulse(), |
| 178 | + instruction.channel, |
| 179 | + name=instruction.name) |
| 180 | + |
| 181 | + if isinstance(instruction, ParametricInstruction): # deprecated |
174 | 182 | pulse_shape = ParametricPulseShapes(type(instruction.command)).name
|
175 | 183 | if pulse_shape not in run_config.parametric_pulses:
|
176 | 184 | # Convert to SamplePulse if the backend does not support it
|
177 | 185 | instruction = PulseInstruction(instruction.command.get_sample_pulse(),
|
178 | 186 | instruction.channels[0],
|
179 | 187 | name=instruction.name)
|
180 | 188 |
|
181 |
| - if isinstance(instruction, PulseInstruction): |
| 189 | + if isinstance(instruction, Play) and isinstance(instruction.pulse, SamplePulse): |
| 190 | + name = instruction.pulse.name |
| 191 | + if instruction.pulse != user_pulselib.get(name): |
| 192 | + name = "{0}-{1:x}".format(name, hash(instruction.pulse.samples.tostring())) |
| 193 | + instruction = Play(SamplePulse(name=name, samples=instruction.pulse.samples), |
| 194 | + channel=instruction.channel, |
| 195 | + name=instruction.name) |
| 196 | + user_pulselib[name] = instruction.pulse |
| 197 | + |
| 198 | + if isinstance(instruction, PulseInstruction): # deprecated |
182 | 199 | name = instruction.command.name
|
183 | 200 | if name in user_pulselib and instruction.command != user_pulselib[name]:
|
184 | 201 | name = "{0}-{1:x}".format(name, hash(instruction.command.samples.tostring()))
|
|
0 commit comments