Ejemplo n.º 1
0
 def setUp(self):
     self.backend = FakeOpenPulse2Q()
     self.device = pulse.PulseChannelSpec.from_backend(self.backend)
     self.config = self.backend.configuration()
     self.defaults = self.backend.defaults()
     self.cmd_def = CmdDef.from_defaults(self.defaults.cmd_def,
                                         self.defaults.pulse_library)
     self.short_pulse = pulse.SamplePulse(samples=np.array([0.02739068], dtype=np.complex128),
                                          name='p0')
Ejemplo n.º 2
0
 def setUp(self):
     self.backend = FakeOpenPulse2Q()
     self.device = pulse.PulseChannelSpec.from_backend(self.backend)
     self.config = self.backend.configuration()
     self.defaults = self.backend.defaults()
     self.cmd_def = CmdDef.from_defaults(self.defaults.cmd_def,
                                         self.defaults.pulse_library)
     self.short_pulse = pulse.SamplePulse(samples=np.array([0.02739068], dtype=np.complex128),
                                          name='p0')
     acquire = pulse.Acquire(5)
     sched = pulse.Schedule(name='fake_experiment')
     sched = sched.insert(0, self.short_pulse(self.device.drives[0]))
     self.sched = sched.insert(5, acquire(self.device.acquires, self.device.memoryslots))
Ejemplo n.º 3
0
 def setUp(self):
     self.backend = FakeOpenPulse2Q()
     self.device = pulse.DeviceSpecification.create_from(self.backend)
     self.config = self.backend.configuration()
     self.defaults = self.backend.defaults()
     self.cmd_def = CmdDef.from_defaults(self.defaults.cmd_def,
                                         self.defaults.pulse_library)
     self.short_pulse = pulse.SamplePulse(samples=np.array([0.02739068], dtype=np.complex128),
                                          name='p0')
     acquire = pulse.Acquire(5)
     sched = pulse.Schedule(name='fake_experiment')
     sched = sched.insert(0, self.short_pulse(self.device.q[0].drive))
     self.sched = sched.insert(5, acquire(self.device.q, self.device.mem))
Ejemplo n.º 4
0
 def setUp(self):
     self.backend = FakeOpenPulse2Q()
     self.config = self.backend.configuration()
     self.defaults = self.backend.defaults()
     self.cmd_def = CmdDef.from_defaults(self.defaults.cmd_def,
                                         self.defaults.pulse_library)
     self.short_pulse = pulse.SamplePulse(samples=np.array([0.02739068], dtype=np.complex128),
                                          name='p0')
     acquire = pulse.Acquire(5)
     sched = pulse.Schedule(name='fake_experiment')
     sched = sched.insert(0, self.short_pulse(self.config.drive(0)))
     self.sched = sched.insert(5, acquire([self.config.acquire(0), self.config.acquire(1)],
                                          [MemorySlot(0), MemorySlot(1)]))
Ejemplo n.º 5
0
def schedule(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
             backend: Optional['BaseBackend'] = None,
             cmd_def: Optional[CmdDef] = None,
             meas_map: Optional[List[List[int]]] = None,
             method: Optional[Union[str, List[str]]] = None) -> Union[Schedule, List[Schedule]]:
    """
    Schedule a circuit to a pulse Schedule, using the backend, according to any specified methods.
    Supported methods are documented in
    :py:func:`qiskit.pulse.scheduler.schedule_circuit.schedule_circuit`.

    Args:
        circuits: The quantum circuit or circuits to translate
        backend: A backend instance, which contains hardware specific data required for scheduling
        cmd_def: Mapping of circuit operations to pulse schedules. If None, defaults to the
                 `backend` `cmd_def`
        meas_map: List of sets of qubits that must be measured together. If `None` defaults to
                  the `backend` `meas_map`
        method: Optionally specify a particular scheduling method
    Returns:
        A pulse `Schedule` that implements the input circuit
    Raises:
        QiskitError: If `cmd_def` and `meas_map` are not passed and `backend` is not passed
    """
    if cmd_def is None:
        if backend is None:
            raise QiskitError("Must supply either a backend or CmdDef for scheduling passes.")
        defaults = backend.defaults()
        cmd_def = CmdDef.from_defaults(defaults.cmd_def, defaults.pulse_library)
    if meas_map is None:
        if backend is None:
            raise QiskitError("Must supply either a backend or a meas_map for scheduling passes.")
        meas_map = backend.configuration().meas_map

    schedule_config = ScheduleConfig(cmd_def=cmd_def, meas_map=meas_map)
    circuits = circuits if isinstance(circuits, list) else [circuits]
    schedules = [schedule_circuit(circuit, schedule_config, method) for circuit in circuits]
    return schedules[0] if len(schedules) == 1 else schedules