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 all 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
60 changes: 29 additions & 31 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,46 @@

# General options:

project = 'Qiskit Dynamics'
copyright = '2020, Qiskit Development Team' # pylint: disable=redefined-builtin
author = 'Qiskit Development Team'
project = "Qiskit Dynamics"
copyright = "2020, Qiskit Development Team" # pylint: disable=redefined-builtin
author = "Qiskit Development Team"

# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = '0.6.0'
release = "0.6.0"

extensions = [
'sphinx.ext.napoleon',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.extlinks',
'jupyter_sphinx',
'sphinx_autodoc_typehints',
'reno.sphinxext',
'sphinx.ext.intersphinx',
'nbsphinx',
'sphinxcontrib.bibtex',
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.extlinks",
"jupyter_sphinx",
"sphinx_autodoc_typehints",
"reno.sphinxext",
"sphinx.ext.intersphinx",
"nbsphinx",
"sphinxcontrib.bibtex",
"qiskit_sphinx_theme",
]
templates_path = ["_templates"]

numfig = True
numfig_format = {
'table': 'Table %s'
}
language = 'en'
pygments_style = 'colorful'
numfig_format = {"table": "Table %s"}
language = "en"
pygments_style = "colorful"
add_module_names = False
modindex_common_prefix = ['qiskit_dynamics.']
bibtex_default_style = 'unsrt'
bibtex_bibfiles = ['refs.bib']
modindex_common_prefix = ["qiskit_dynamics."]
bibtex_default_style = "unsrt"
bibtex_bibfiles = ["refs.bib"]
bibtex_bibliography_header = ".. rubric:: References"
bibtex_footbibliography_header = bibtex_bibliography_header

# html theme options
html_theme = 'qiskit-ecosystem'
html_last_updated_fmt = '%Y/%m/%d'
html_theme = "qiskit-ecosystem"
html_last_updated_fmt = "%Y/%m/%d"

docs_url_prefix = "qiskit-dynamics"

Expand All @@ -72,14 +70,14 @@
intersphinx_mapping = {
"qiskit": ("https://docs.quantum.ibm.com/api/qiskit", None),
"qiskit_experiments": ("https://qiskit-community.github.io/qiskit-experiments/", None),
"arraylias": ("https://qiskit-community.github.io/arraylias/", None)
"arraylias": ("https://qiskit-community.github.io/arraylias/", None),
}

# nbsphinx options (for tutorials)
nbsphinx_timeout = 180
# TODO: swap this with always if tutorial execution is too slow for ci and needs
# a separate job
# nbsphinx_execute = os.getenv('QISKIT_DOCS_BUILD_TUTORIALS', 'never')
nbsphinx_execute = 'always'
nbsphinx_widgets_path = ''
exclude_patterns = ['_build', '**.ipynb_checkpoints']
nbsphinx_execute = "always"
nbsphinx_widgets_path = ""
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
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
146 changes: 145 additions & 1 deletion qiskit_dynamics/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,50 @@

.. currentmodule:: qiskit_dynamics.pulse

This module contains tools to interface :mod:`qiskit.pulse` with Qiskit Dynamics. Qiskit Dynamics
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

This module also contains tools to interface :mod:`qiskit.pulse` with Qiskit Dynamics. Qiskit Dynamics
simulates time evolution using the :class:`Signal` class, however :mod:`qiskit.pulse` specifies
pulse instructions using a :class:`~qiskit.pulse.Schedule` or :class:`~qiskit.pulse.ScheduleBlock`.
This module contains the required converters to convert from a :mod:`qiskit.pulse` control
Expand Down Expand Up @@ -81,4 +124,105 @@

InstructionToSignals
"""

from .pulse_to_signals import InstructionToSignals


# 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