Skip to content

Commit

Permalink
Prepare 0.16.0 release (#5142)
Browse files Browse the repository at this point in the history
* Prepare 0.16.0 release

This commit moves the release notes into a 0.16 subdirectory to keep
them separate from development notes post-release. It also adds an
incomplete release note to add the prelude section providing the high
level overview of the release. When this merges it should be the commit
used to to tag the 0.16.0 release.

* Move new notes from rebase

* Move new release notes

* Move new release notes

* Start rewriting release notes

* Add classicalfunction docs

* Fix classicalfunction docs

* Fix circular import issues

* Fix classical function doc formatting

* Remove stray files accidentally commited

* Add LinearAmplitudeFunction to docs

* More release note updates

* Fix template optimization pass docs

* Even more release note rewrites

* Update release notes except for fixes

* Move new release notes and add parameter type checking release notes

* Fix most of the bug fix release notes (5 left)

* Finish bug fix release notes

* Update 0.16.0-release-a06d0e1c3b705bda.yaml

* Fix formatting in prelude

* Preserve whitespace for bulleted list

* Apply suggestions from code review

Co-authored-by: Lauren Capelluto <[email protected]>

* Apply suggestions from code review

Co-authored-by: Lauren Capelluto <[email protected]>

* Update releasenotes/notes/0.16/0.16.0-release-a06d0e1c3b705bda.yaml

Co-authored-by: Lauren Capelluto <[email protected]>

* Apply suggestions from code review

Co-authored-by: Kevin Krsulich <[email protected]>

* Add missing whitespace after highlights bulleted list in prelude

* Apply suggestions from code review

Co-authored-by: Kevin Krsulich <[email protected]>

* Apply suggestions from code review

Co-authored-by: Kevin Krsulich <[email protected]>

* Remove backported release notes

* Remove more backported notes

Co-authored-by: Julien Gacon <[email protected]>
Co-authored-by: Ali Javadi-Abhari <[email protected]>
Co-authored-by: Lauren Capelluto <[email protected]>
Co-authored-by: Kevin Krsulich <[email protected]>
  • Loading branch information
5 people authored Oct 15, 2020
1 parent cf0b039 commit 160574a
Show file tree
Hide file tree
Showing 93 changed files with 801 additions and 623 deletions.
6 changes: 6 additions & 0 deletions docs/apidocs/classicalfunction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _qiskit-circuit-classicalfunction:

.. automodule:: qiskit.circuit.classicalfunction
:no-members:
:no-inherited-members:
:no-special-members:
1 change: 1 addition & 0 deletions docs/apidocs/terra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Qiskit Terra API Reference
compiler
execute
visualization
classicalfunction
converters
assembler
dagcircuit
Expand Down
12 changes: 6 additions & 6 deletions qiskit/circuit/classicalfunction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
=====================================
====================================================================
ClassicalFunction compiler (:mod:`qiskit.circuit.classicalfunction`)
=====================================
====================================================================
.. currentmodule:: qiskit.circuit.classicalfunction
Expand Down Expand Up @@ -67,16 +67,16 @@ def grover_oracle(a: Int1, b: Int1, c: Int1, d: Int1) -> Int1:
ClassicalFunction compiler API
===================
==============================
classical_function
------
------------------
Decorator for a classical function that returns a `ClassicalFunction` object.
ClassicalFunction
------
-----------------
.. autosummary::
:toctree: ../stubs/
Expand All @@ -94,6 +94,7 @@ def grover_oracle(a: Int1, b: Int1, c: Int1, d: Int1) -> Int1:
ClassicalFunctionCompilerTypeError
"""
from .classicalfunction import ClassicalFunction
from .exceptions import (ClassicalFunctionParseError, ClassicalFunctionCompilerError,
ClassicalFunctionCompilerTypeError)

Expand All @@ -111,7 +112,6 @@ def classical_function(func):
method).
"""
import inspect
from .classicalfunction import ClassicalFunction

source = inspect.getsource(func).strip()
return ClassicalFunction(source, name=func.__name__)
25 changes: 14 additions & 11 deletions qiskit/circuit/classicalfunction/classicalfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
HAS_TWEEDLEDUM = True
except Exception: # pylint: disable=broad-except
HAS_TWEEDLEDUM = False
from qiskit.circuit import QuantumCircuit, QuantumRegister
from qiskit.circuit.gate import Gate
from qiskit.circuit import quantumregister
from qiskit.circuit import gate
from qiskit.exceptions import QiskitError
from .utils import tweedledum2qiskit
from .classical_function_visitor import ClassicalFunctionVisitor


class ClassicalFunction(Gate):
"""An ClassicalFunction object represents an classicalfunction function and
its logic network."""
class ClassicalFunction(gate.Gate):
"""Represent a classical function function and its logic network."""

def __init__(self, source, name=None):
"""Creates a ``ClassicalFunction`` from Python source code in ``source``. The code should
be a single function with types.
"""Creates a ``ClassicalFunction`` from Python source code in ``source``.
The code should be a single function with types.
Args:
source (str): Python code with type hints.
Expand Down Expand Up @@ -87,6 +87,7 @@ def args(self):
@property
def types(self):
"""Dumps a list of scopes with their variables and types.
Returns:
list(dict): A list of scopes as dicts, where key is the variable name and
value is its type.
Expand All @@ -100,8 +101,8 @@ def simulate(self):
"""Runs ``tweedledum.simulate`` on the logic network."""
return simulate(self._network)

def synth(self, registerless=True) -> QuantumCircuit:
"""Synthesis the logic network into a ``QuantumCircuit``.
def synth(self, registerless=True):
"""Synthesis the logic network into a :class:`~qiskit.circuit.QuantumCircuit`.
Args:
registerless (bool): Default ``True``. If ``False`` uses the parameter names to create
Expand All @@ -123,8 +124,10 @@ def _define(self):
@property
def qregs(self):
"""The list of qregs used by the classicalfunction"""
qregs = [QuantumRegister(1, name=arg) for arg in self.args if self.types[0][arg] == 'Int1']
qregs = [
quantumregister.QuantumRegister(
1, name=arg) for arg in self.args if self.types[0][arg] == 'Int1']
qregs.reverse()
if self.types[0]['return'] == 'Int1':
qregs.append(QuantumRegister(1, name='return'))
qregs.append(quantumregister.QuantumRegister(1, name='return'))
return qregs
2 changes: 1 addition & 1 deletion qiskit/circuit/classicalfunction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

"""Internal utils for ClassicalFunction Compiler"""

from qiskit import QuantumCircuit
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.circuit.library.standard_gates import ZGate, TGate, SGate, TdgGate, SdgGate, U1Gate, \
XGate, HGate, U3Gate
from qiskit.circuit.classicalfunction.exceptions import ClassicalFunctionCompilerError
Expand Down
8 changes: 8 additions & 0 deletions qiskit/circuit/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@
QuadraticForm
Amplitude Functions
===================
.. autosummary::
:toctree: ../stubs/
LinearAmplitudeFunction
Particular Quantum Circuits
===========================
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/graph_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Union, List

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.circuit.exceptions import CircuitError


Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/hidden_linear_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Union, List

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.circuit.exceptions import CircuitError


Expand Down
3 changes: 2 additions & 1 deletion qiskit/circuit/library/n_local/n_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from itertools import combinations

import numpy
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.circuit.quantumregister import QuantumRegister
from qiskit.circuit import Instruction, Parameter, ParameterVector, ParameterExpression
from qiskit.circuit.parametertable import ParameterTable

Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/n_local/two_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from typing import Union, Optional, List, Callable, Any

from qiskit import QuantumCircuit
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.circuit import Gate, Instruction, Parameter

from .n_local import NLocal
Expand Down
24 changes: 12 additions & 12 deletions qiskit/transpiler/passes/optimization/template_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ def __init__(self, template_list=None,
Args:
template_list (list[QuantumCircuit()]): list of the different template circuit to apply.
heuristics_backward_param (list[int]): [length, survivor] Those are the parameters for
applying heuristics on the backward part of the algorithm. This part of the algorithm
creates a tree of matching scenario. This tree grows exponentially. The heuristics
evaluates which scenarios have the longest match and keep only those. The length is the
interval in the tree for cutting it and surviror is the number of scenarios that are
kept. We advice to use l=3 and s=1 to have serious time advantage. We remind that the
heuristics implies losing a part of the maximal matches. Check reference for more
details.
applying heuristics on the backward part of the algorithm. This part of the
algorithm creates a tree of matching scenario. This tree grows exponentially. The
heuristics evaluates which scenarios have the longest match and keep only those.
The length is the interval in the tree for cutting it and surviror is the number
of scenarios that are kept. We advice to use l=3 and s=1 to have serious time
advantage. We remind that the heuristics implies losing a part of the maximal
matches. Check reference for more details.
heuristics_qubits_param (list[int]): [length] The heuristics for the qubit choice make
guesses from the dag dependency of the circuit in order to limit the number of qubit
configurations to explore. The length is the number of successors or not predecessors
that will be explored in the dag dependency of the circuit, each qubits of the nodes
are added to the set of authorized qubits. We advice to use length=1. Check reference
for more details.
guesses from the dag dependency of the circuit in order to limit the number of
qubit configurations to explore. The length is the number of successors or not
predecessors that will be explored in the dag dependency of the circuit, each
qubits of the nodes are added to the set of authorized qubits. We advice to use
length=1. Check reference for more details.
"""
super().__init__()
# If no template is given; the template are set as x-x, cx-cx, ccx-ccx.
Expand Down
61 changes: 61 additions & 0 deletions releasenotes/notes/0.16/0.16.0-release-a06d0e1c3b705bda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
prelude: |
The 0.16.0 release includes serveral new features and bug fixes. The
major features in this release are the following:
* Introduction of scheduled circuits, where delays can be used to control
the timing and alignment of operations in the circuit.
* Compilation of quantum circuits from classical functions, such as
oracles.
* Ability to compile and optimize single qubit rotations over different
Euler basis as well as the phase + square-root(X) basis (i.e.
``['p', 'sx']``), which will replace the older IBM Quantum basis of
``['u1', 'u2', 'u3']``.
* Tracking of :meth:`~qiskit.circuit.QuantumCircuit.global_phase` on the
:class:`~qiskit.circuit.QuantumCircuit` class has been extended through
the :mod:`~qiskit.transpiler`, :mod:`~qiskit.quantum_info`, and
:mod:`~qiskit.assembler` modules, as well as the BasicAer and Aer
simulators. Unitary and state vector simulations will now return global
phase-correct unitary matrices and state vectors.
Also of particular importance for this release is that Python 3.5 is no
longer supported. If you're are using Qiskit Terra with Python 3.5 the
0.15.2 release is that last version which will work.
upgrade:
- |
Type checking for the ``params`` kwarg of the constructor for the
:class:`~qiskit.circuit.Gate` class and its subclasses has been changed.
Previously all :class:`~qiskit.circuit.Gate` parameters had to be
in a set of allowed types defined in the
:class:`~qiskit.circuit.Instruction` class. Now a new method,
:meth:`~qiskit.circuit.Gate.validate_parameter` is used to determine
if a parameter type is valid or not. The definition of this method in
a subclass will take priority over its parent. For example,
:class:`~qiskit.extensions.UnitaryGate` accepts a parameter of the type
``numpy.ndarray`` and defines a custom
:meth:`~qiskit.extensionst.UnitaryGate.validate_parameter` method that
returns the parameter if it's an ``numpy.ndarray``. This takes priorty
over the function defined in its parent class :class:`~qiskit.circuit.Gate`.
If :class:`~qiskit.extensions.UnitaryGate` were to be used as parent
for a new class, this ``validate_parameter`` method would be used unless
the new child class defines its own method.
deprecations:
- |
The use of a ``numpy.ndarray`` for a parameter in the ``params`` kwarg
for the constructor of the :class:`~qiskit.circuit.Gate` class and
subclasses has been deprecated and will be removed in future releases. This
was done as part of the refactoring of how ``parms`` type checking is
handled for the :class:`~qiskit.circuit.Gate` class. If you have a custom
gate class which is a subclass of :class:`~qiskit.circuit.Gate` directly
(or via a different parent in the hiearchy) that accepts an ``ndarray``
parameter, you should define a custom
:meth:`~qiskit.circuit.Gate.validate_parameter` method for your class
that will return the allowed parameter type. For example::
def validate_parameter(self, parameter):
"""Custom gate parameter has to be an ndarray."""
if isinstance(parameter, numpy.ndarray):
return parameter
else:
raise CircuitError("invalid param type {0} in gate "
"{1}".format(type(parameter), self.name))
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
fixes:
- |
The :class:`~qiskit.result.Result` class's methods
:meth:`~qiskit.result.Result.data`, :meth:`~qiskit.result.Result.get_memory`,
:meth:`~qiskit.result.Result.get_counts`, :meth:`~qiskit.result.Result.get_unitary`,
and :meth:`~qiskit.result.Result.get_statevector ` will now emit a warning
when the ``experiment`` kwarg is specified for attempting to fetch
results using either a :class:`~qiskit.circuit.QuantumCircuit` or
:class:`~qiskit.pulse.Schedule` instance, when more than one entry matching
the instance name is present in the ``Result`` object. Note that only the
first entry matching this name will be returned. Fixes
`#3207 <https://github.com/Qiskit/qiskit-terra/issues/3207>`__
32 changes: 32 additions & 0 deletions releasenotes/notes/0.16/3927-0d94adeac9299540.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
upgrade:
- |
The previously deprecated methods, arguments, and properties named
``n_qubits`` and ``numberofqubits`` have been removed. These were
deprecated in the 0.13.0 release. The full set of changes are:
.. list-table::
:header-rows: 1
* - Class
- Old
- New
* - :class:`~qiskit.circuit.QuantumCircuit`
- ``n_qubits``
- :class:`~qiskit.circuit.QuantumCircuit.num_qubits`
* - :class:`~qiskit.quantum_info.Pauli`
- ``numberofqubits``
- :attr:`~qiskit.quantum_info.Pauli.num_qubits`
.. list-table::
:header-rows: 1
* - Function
- Old Argument
- New Argument
* - :func:`qiskit.circuit.random.random_circuit`
- ``n_qubits``
- ``num_qubits``
* - :class:`qiskit.circuit.library.MSGate`
- ``n_qubits``
- ``num_qubits``
18 changes: 18 additions & 0 deletions releasenotes/notes/0.16/4697-append-method-d4dc03b70257e99b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
fixes:
- |
The :class:`qiskit.circuit.QuantumCircuit` method
:meth:`~qiskit.circuit.QuantumCircuit.append` can now be used to insert one
parameterized gate instance into multiple circuits. This fixes a previous
issue where inserting a single parameterized
:class:`~qiskit.circuit.Gate` object into multiple circuits would
cause failures when one circuit had a parameter assigned.
Fixes `#4697 <https://github.com/Qiskit/qiskit-terra/issues/4697>`__
upgrade:
- |
Inserting a parameterized :class:`~qiskit.circuit.Gate` instance into
a :class:`~qiskit.circuit.QuantumCircuit` now creates a copy of that
gate which is used in the circuit. If changes are made to the instance
inserted into the circuit it will no longer be reflected in the gate in
the circuit. This change was made to fix an issue when inserting a single
parameterized :class:`~qiskit.circuit.Gate` object into multiple circuits.
9 changes: 9 additions & 0 deletions releasenotes/notes/0.16/5037-e73ce50c4ae23445.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
fixes:
- |
Previously the :func:`qiskit.execute.execute` function would incorrectly
disallow both the ``backend`` and ``pass_manager`` kwargs to be
specified at the same time. This has been fixed so that both
``backend`` and ``pass_manager`` can be used together on calls to
:func:`~qiskit.execute.execute`.
Fixes `#5037 <https://github.com/Qiskit/qiskit-terra/issues/5037>`__
32 changes: 32 additions & 0 deletions releasenotes/notes/0.16/add-globalR-gates-13dd2860618e5c3f.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
features:
- |
Global R gates have been added to :mod:`qiskit.circuit.library`. This
includes the global R gate (:class:`~qiskit.circuit.library.GR`),
global Rx (:class:`~qiskit.circuit.library.GRX`) and global Ry
(:class:`~qiskit.circuit.library.GRY`) gates which are derived from the
:class:`~qiskit.circuit.library.GR` gate, and global Rz (
:class:`~qiskit.circuit.library.GRZ`) that is defined in a similar way
to the :class:`~qiskit.circuit.library.GR` gates. The global R gates are
defined on a number of qubits simultaneously, and act as a direct sum of
R gates on each qubit.
For example:
.. code-block :: python
from qiskit import QuantumCircuit, QuantumRegister
import numpy as np
num_qubits = 3
qr = QuantumRegister(num_qubits)
qc = QuantumCircuit(qr)
qc.compose(GR(num_qubits, theta=np.pi/3, phi=2*np.pi/3), inplace=True)
will create a :class:`~qiskit.circuit.QuantumCircuit` on a
:class:`~qiskit.circuit.QuantumRegister` of 3 qubits and perform a
:class:`~qiskit.circuit.library.RGate` of an angle
:math:`\theta = \frac{\pi}{3}` about an axis in the xy-plane of the Bloch
spheres that makes an angle of :math:`\phi = \frac{2\pi}{3}` with the x-axis
on each qubit.
Loading

0 comments on commit 160574a

Please sign in to comment.