Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Add dynamical decoupling pass #367

Merged
merged 73 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
450922b
Fix lint for Qiskit main branch.
taalexander Jul 6, 2022
5c61448
Fix sphinx language configuration.
taalexander Jul 6, 2022
0658c7a
Add initial scaffolding for dynamic_circuits module.
taalexander Jun 17, 2022
4dbe92a
Add a dummy test.
taalexander Jun 17, 2022
44a7afb
Add reno.
taalexander Jun 17, 2022
8aa3365
Add initial qiskit DynamicalDecoupling scheduling scaffolding and tests.
taalexander Jun 17, 2022
06f9d86
Refactor scheduler with visitor pattern.
taalexander Jun 19, 2022
a518281
Refactor nodes to no longer return. Remove special handling for class…
taalexander Jun 19, 2022
bfcfe2e
Add block based scheduling and updated tests for dynamic circuits typ…
taalexander Jun 27, 2022
9a0955c
Refactor padder class.
taalexander Jul 5, 2022
1744ae4
Base padding is working.
taalexander Jul 5, 2022
4340be0
Remove debug statements.
taalexander Jul 5, 2022
9e2d5ae
Update non conditional tests to pass.
taalexander Jul 5, 2022
3cd3859
c_if scheduling tests are working.
taalexander Jul 5, 2022
b48951d
All tests passing.
taalexander Jul 5, 2022
3efa7da
All dynamic circuits tests passing.
taalexander Jul 6, 2022
96e02fb
Black formatting.
taalexander Jul 6, 2022
9dddf1e
Move the dynamic_circuits module to a generic transpiler module.
taalexander Jul 6, 2022
2442d1e
Blackify
taalexander Jul 6, 2022
7e144e9
Linting.
taalexander Jul 6, 2022
42c8bc8
Blackify.
taalexander Jul 6, 2022
615f03c
Reach black and pylint fixed point.
taalexander Jul 6, 2022
70ae09d
Mypyify the code.
taalexander Jul 6, 2022
36c611e
Merge branch 'main' into add-scheduling-pass
rathishcholarajan Jul 6, 2022
b4f8f9b
Add initial scaffolding for dynamic_circuits module.
taalexander Jun 17, 2022
af86472
Add a dummy test.
taalexander Jun 17, 2022
b42cf0c
Add reno.
taalexander Jun 17, 2022
0bef47b
Add initial qiskit DynamicalDecoupling scheduling scaffolding and tests.
taalexander Jun 17, 2022
f97fa79
Refactor scheduler with visitor pattern.
taalexander Jun 19, 2022
e9db084
Refactor nodes to no longer return. Remove special handling for class…
taalexander Jun 19, 2022
eab1fdb
Add block based scheduling and updated tests for dynamic circuits typ…
taalexander Jun 27, 2022
dc4ea34
Refactor padder class.
taalexander Jul 5, 2022
6e173a5
Base padding is working.
taalexander Jul 5, 2022
f490053
Remove debug statements.
taalexander Jul 5, 2022
ccbad76
Update non conditional tests to pass.
taalexander Jul 5, 2022
25bba97
c_if scheduling tests are working.
taalexander Jul 5, 2022
65760f3
All tests passing.
taalexander Jul 5, 2022
d7cbdd5
All dynamic circuits tests passing.
taalexander Jul 6, 2022
2be8de8
Black formatting.
taalexander Jul 6, 2022
eb33397
Move the dynamic_circuits module to a generic transpiler module.
taalexander Jul 6, 2022
8deed38
Blackify
taalexander Jul 6, 2022
bf0807b
Linting.
taalexander Jul 6, 2022
8b4a602
Blackify.
taalexander Jul 6, 2022
5ac8693
Reach black and pylint fixed point.
taalexander Jul 6, 2022
8f49cb1
Mypyify the code.
taalexander Jul 6, 2022
53ad4b4
Merge remote-tracking branch 'origin/add-scheduling-pass' into add-sc…
taalexander Jul 6, 2022
209cc8e
Rename BasePadding to BlockBasePadder.
taalexander Jul 6, 2022
89e7fba
Fix broken tests by Qiskit upgrade.
taalexander Jul 6, 2022
ee823a5
Move tests into unit.
taalexander Jul 6, 2022
4c33ca7
linting.
taalexander Jul 6, 2022
aea5473
Update documentation.
taalexander Jul 6, 2022
ea37d66
Fix requirements dev for matplotlib drawer./
taalexander Jul 6, 2022
69cbab4
Chain qargs and cargs.
taalexander Jul 6, 2022
b1943a6
Update pulse block comment.
taalexander Jul 6, 2022
2b971b3
Update measurement comment.
taalexander Jul 6, 2022
44a1905
Add t0 comment.
taalexander Jul 6, 2022
2d995df
Move scheduler unit tests.
taalexander Jul 6, 2022
931fe00
Make scheduler idempotent.
taalexander Jul 7, 2022
783d608
Operations on qubits already measured trigger block termination.
taalexander Jul 7, 2022
b777249
Black.
taalexander Jul 7, 2022
81596b1
Update comment on _visit_measure qargs.
taalexander Aug 11, 2022
d50b28b
Update comment typo.
taalexander Aug 11, 2022
97e5bcd
Update comment on neighbor ordering.
taalexander Aug 11, 2022
b5d9e31
Add comments.
taalexander Aug 11, 2022
be11a0b
Update docs.
taalexander Jul 6, 2022
e2f7f2c
Ported dynamical decoupling pass and all tests to the dynamic circuit…
taalexander Jul 6, 2022
9c4d476
Tests passing outside of scheduling fixes required.
taalexander Jul 6, 2022
8e7b4c4
Dynamical decoupling tests passing.
taalexander Jul 7, 2022
2d15470
Add dynamical decoupling c_if test.
taalexander Jul 7, 2022
f9be274
Add working documentation.
taalexander Jul 7, 2022
8f1ac4f
Reno added.
taalexander Jul 7, 2022
065b71d
Add quick comment.
taalexander Aug 11, 2022
3c27aeb
Merge remote-tracking branch 'upstream/main' into add-dynamical-decou…
taalexander Aug 24, 2022
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
1 change: 1 addition & 0 deletions docs/apidocs/ibm-provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ qiskit-ibm-provider API Reference
ibm_visualization
ibm_jupyter
ibm_utils
ibm_transpiler
6 changes: 6 additions & 0 deletions docs/apidocs/ibm_transpiler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _qiskit_ibm_provider-utils:

.. automodule:: qiskit_ibm_provider.transpiler
:no-members:
:no-inherited-members:
:no-special-members:
31 changes: 31 additions & 0 deletions qiskit_ibm_provider/transpiler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# 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.

"""
====================================================================
IBM Backend Transpiler Tools (:mod:`qiskit_ibm_provider.transpiler`)
====================================================================

A collection of transpiler tools for working with IBM Quantum's
next-generation backends that support advanced "dynamic circuit"
capabilities. Ie., circuits with support for classical
compute and control-flow/feedback based off of measurement results.

Transpiler Passes
==================

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

passes

"""
33 changes: 33 additions & 0 deletions qiskit_ibm_provider/transpiler/passes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# 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.

"""
================================================================
Transpiler Passes (:mod:`qiskit_ibm_provider.transpiler.passes`)
================================================================

.. currentmodule:: qiskit_ibm_provider.transpiler.passes

A collection of transpiler passes for IBM backends.

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

scheduling


"""

# circuit scheduling
from .scheduling import DynamicCircuitScheduleAnalysis
from .scheduling import PadDynamicalDecoupling
from .scheduling import PadDelay
110 changes: 110 additions & 0 deletions qiskit_ibm_provider/transpiler/passes/scheduling/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# 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.

"""
====================================================================
Scheduling (:mod:`qiskit_ibm_provider.transpiler.passes.scheduling`)
====================================================================

.. currentmodule:: qiskit_ibm_provider.transpiler.passes.scheduling

A collection of scheduling passes for working with IBM Quantum's next-generation
backends that support advanced "dynamic circuit" capabilities. Ie.,
circuits with support for classical control-flow/feedback based off
of measurement results.


Below we demonstrate how to schedule and pad a teleportation circuit with delays
for a dynamic circuit backend's execution model:

.. jupyter-execute::

from qiskit import transpile
from qiskit.circuit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.transpiler.instruction_durations import InstructionDurations
from qiskit.transpiler.passmanager import PassManager

from qiskit_ibm_provider.transpiler.passes.scheduling import DynamicCircuitScheduleAnalysis, PadDelay
from qiskit.providers.fake_provider.backends.jakarta.fake_jakarta import FakeJakarta


backend = FakeJakarta()

durations = InstructionDurations.from_backend(backend)
pm = PassManager([DynamicCircuitScheduleAnalysis(durations), PadDelay()])

qr = QuantumRegister(3)
crz = ClassicalRegister(1, name="crz")
crx = ClassicalRegister(1, name="crx")
result = ClassicalRegister(1, name="result")

teleport = QuantumCircuit(qr, crz, crx, result, name="Teleport")

teleport.h(qr[1])
teleport.cx(qr[1], qr[2])
teleport.cx(qr[0], qr[1])
teleport.h(qr[0])
teleport.measure(qr[0], crz)
teleport.measure(qr[1], crx)
teleport.z(qr[2]).c_if(crz, 1)
teleport.x(qr[2]).c_if(crx, 1)
teleport.measure(qr[2], result)

teleport = transpile(teleport, backend)

scheduled_teleport = pm.run(teleport)

scheduled_teleport.draw(output="mpl")


Instead of padding with delays we may also insert a dynamical decoupling sequence
using the :class:`PadDynamicalDecoupling` pass as shown below:

.. jupyter-execute::

from qiskit.circuit.library import XGate

from qiskit_ibm_provider.transpiler.passes.scheduling import PadDynamicalDecoupling


dd_sequence = [XGate(), XGate()]

pm = PassManager(
[
DynamicCircuitScheduleAnalysis(durations),
PadDynamicalDecoupling(durations, dd_sequence),
]
)

dd_teleport = pm.run(teleport)

dd_teleport.draw(output="mpl")


Scheduling & Dynamical Decoupling
=================================
.. autosummary::
:toctree: ../stubs/

BlockBasePadder
DynamicCircuitScheduleAnalysis
PadDelay
PadDynamicalDecoupling



"""

from .block_base_padder import BlockBasePadder
from .dynamical_decoupling import PadDynamicalDecoupling
from .pad_delay import PadDelay
from .scheduler import DynamicCircuitScheduleAnalysis
Loading