Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qiskit Pulse migration to Dynamics #365

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qiskit_dynamics/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

This module contains the :class:`.DynamicsBackend` class, which provides a
:class:`~qiskit.providers.backend.BackendV2` interface for running pulse-level simulations with
Qiskit Dynamics. The :class:`.DynamicsBackend` can directly simulate :class:`~qiskit.pulse.Schedule`
and :class:`~qiskit.pulse.ScheduleBlock` instances, and can also be configured to simulate
Qiskit Dynamics. The :class:`.DynamicsBackend` can directly simulate :class:`~qiskit_dynamics.pulse.Schedule`
and :class:`~qiskit_dynamics.pulse.ScheduleBlock` instances, and can also be configured to simulate
:class:`~qiskit.circuit.QuantumCircuit`\s at the pulse-level via circuit to pulse transpilation.

This module also exposes some functions utilized by :class:`.DynamicsBackend` that may be of use to
Expand Down
10 changes: 5 additions & 5 deletions qiskit_dynamics/backend/dynamics_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import numpy as np
from scipy.integrate._ivp.ivp import OdeResult

from qiskit import pulse
from qiskit_dynamics import pulse
from qiskit.qobj.utils import MeasLevel, MeasReturnType
from qiskit.qobj.common import QobjHeader
from qiskit.transpiler import Target, InstructionProperties
from qiskit.circuit.library import Measure
from qiskit.pulse import Schedule, ScheduleBlock
from qiskit.pulse.transforms.canonicalization import block_to_schedule
from qiskit_dynamics.pulse import Schedule, ScheduleBlock
from qiskit_dynamics.pulse.transforms.canonicalization import block_to_schedule
from qiskit.providers.options import Options
from qiskit.providers.backend import BackendV1, BackendV2
from qiskit.providers.models.pulsedefaults import PulseDefaults
Expand Down Expand Up @@ -86,7 +86,7 @@ class DynamicsBackend(BackendV2):
)

Without further configuration, the above ``backend`` can be used to simulate either
:class:`~qiskit.pulse.Schedule` or :class:`~qiskit.pulse.ScheduleBlock` instances.
:class:`~qiskit_dynamics.pulse.Schedule` or :class:`~qiskit_dynamics.pulse.ScheduleBlock` instances.

Pulse-level simulations defined in terms of :class:`~qiskit.circuit.QuantumCircuit` instances
can also be performed if each gate in the circuit has a corresponding pulse-level definition,
Expand Down Expand Up @@ -351,7 +351,7 @@ def solve(
validate: Optional[bool] = True,
) -> Union[OdeResult, List[OdeResult]]:
"""Simulate a list of :class:`~qiskit.circuit.QuantumCircuit`,
:class:`~qiskit.pulse.Schedule`, or :class:`~qiskit.pulse.ScheduleBlock` instances and
:class:`~qiskit_dynamics.pulse.Schedule`, or :class:`~qiskit_dynamics.pulse.ScheduleBlock` instances and
return the ``OdeResult``.

This method is analogous to :meth:`.Solver.solve`, however it additionally utilizes
Expand Down
165 changes: 165 additions & 0 deletions qiskit_dynamics/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,169 @@

InstructionToSignals
"""

from .pulse_to_signals import InstructionToSignals
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

r"""
===========================
Pulse (:mod:`qiskit.pulse`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not rendered as a module documentation. You also need to update Sphinx API docs configuration.
https://github.com/qiskit-community/qiskit-dynamics/blob/main/docs/apidocs/index.rst

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to proceed for this. I have modified the Python file to make it more coherent as a whole but did not touch the docs yet.

===========================

.. currentmodule:: qiskit.pulse

Qiskit-Pulse is a pulse-level quantum programming kit. This lower level of
programming offers the user more control than programming with
:py:class:`~qiskit.circuit.QuantumCircuit`\ s.

Extracting the greatest performance from quantum hardware requires real-time
pulse-level instructions. Pulse answers that need: it enables the quantum
physicist *user* to specify the exact time dynamics of an experiment.
It is especially powerful for error mitigation techniques.

The input is given as arbitrary, time-ordered signals (see: :ref:`Instructions <pulse-insts>`)
scheduled in parallel over multiple virtual hardware or simulator resources
(see: :ref:`Channels <pulse-channels>`). The system also allows the user to recover the
time dynamics of the measured output.

This is sufficient to allow the quantum physicist to explore and correct for
noise in a quantum system.

.. automodule:: qiskit.pulse.instructions
.. automodule:: qiskit.pulse.library
.. automodule:: qiskit.pulse.channels
.. automodule:: qiskit.pulse.schedule
.. automodule:: qiskit.pulse.transforms
.. automodule:: qiskit.pulse.builder

.. currentmodule:: qiskit.pulse

Configuration
=============

.. autosummary::
:toctree: ../stubs/

InstructionScheduleMap

Exceptions
==========

.. autoexception:: PulseError
.. autoexception:: BackendNotSet
.. autoexception:: NoActiveBuilder
.. autoexception:: UnassignedDurationError
.. autoexception:: UnassignedReferenceError
"""

# Builder imports.
from qiskit_dynamics.pulse.builder import (
# Construction methods.
active_backend,
build,
num_qubits,
qubit_channels,
samples_to_seconds,
seconds_to_samples,
# Instructions.
acquire,
barrier,
call,
delay,
play,
reference,
set_frequency,
set_phase,
shift_frequency,
shift_phase,
snapshot,
# Channels.
acquire_channel,
control_channels,
drive_channel,
measure_channel,
# Contexts.
align_equispaced,
align_func,
align_left,
align_right,
align_sequential,
frequency_offset,
phase_offset,
# Macros.
macro,
measure,
measure_all,
delay_qubits,
)
from qiskit_dynamics.pulse.channels import (
AcquireChannel,
ControlChannel,
DriveChannel,
MeasureChannel,
MemorySlot,
RegisterSlot,
SnapshotChannel,
)
from qiskit_dynamics.pulse.configuration import (
Discriminator,
Kernel,
LoConfig,
LoRange,
)
from qiskit_dynamics.pulse.exceptions import (
PulseError,
BackendNotSet,
NoActiveBuilder,
UnassignedDurationError,
UnassignedReferenceError,
)
from qiskit_dynamics.pulse.instruction_schedule_map import InstructionScheduleMap
from qiskit_dynamics.pulse.instructions import (
Acquire,
Delay,
Instruction,
Play,
SetFrequency,
SetPhase,
ShiftFrequency,
ShiftPhase,
Snapshot,
)
from qiskit_dynamics.pulse.library import (
Constant,
Drag,
Gaussian,
GaussianSquare,
GaussianSquareDrag,
gaussian_square_echo,
Sin,
Cos,
Sawtooth,
Triangle,
Square,
GaussianDeriv,
Sech,
SechDeriv,
SymbolicPulse,
ScalableSymbolicPulse,
Waveform,
)
from qiskit_dynamics.pulse.library.samplers.decorators import functional_pulse
from qiskit_dynamics.pulse.schedule import Schedule, ScheduleBlock
from qiskit_dynamics.scheduler.schedule_circuit import schedule

import update_circuit



Loading
Loading