Skip to content

Commit

Permalink
Merge pull request #747 from unitaryfund/patch-release-0.9.1
Browse files Browse the repository at this point in the history
Patch release 0.9.1
  • Loading branch information
andreamari authored Jun 24, 2021
2 parents 75b89ca + bc432f8 commit 704ba56
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 111 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
% # " - [Bug Fix]"
% # " - Fix the bug."

## Version 0.9.1 (June 23rd, 2021)

This is a patch release to fix two bugs (gh-736, gh-737) related to the integration with optional packages.
It also fixes other minor problems (see the list of changes below).

### All Changes

- Patch 0.9.0 (@rmlarose, gh-739).
- Make readthedocs succeed in building the pdf with pdflatex (@andreamari, gh-743).
- Update energy landscape example in docs (@andreamari, gh-742).
- Remove old deprecation warnings (@rmlarose, gh-744).

## Version 0.9.0 (June 17th, 2021)

### Summary
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.1
21 changes: 12 additions & 9 deletions docs/source/examples/simple_landscape.myst
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ kernelspec:
This tutorial shows an example in which the energy landscape for a two-qubit variational
circuit is explored with and without error mitigation.


```{code-cell} ipython3
import matplotlib.pyplot as plt
import numpy as np
from cirq import Circuit, H, rx, CNOT, DensityMatrixSimulator, LineQubit, depolarize
import mitiq
from cirq import Circuit, rx, CNOT, DensityMatrixSimulator, LineQubit, depolarize

from mitiq.zne import mitigate_executor
from mitiq.zne.inference import RichardsonFactory

SIMULATOR = DensityMatrixSimulator()
```

## Defining the ideal variational circuit
We define a function which returns a two-qubit circuit at a specified variational angle $\gamma$.
We define a function which returns a simple two-qubit variational circuit depending on a single parameter $\gamma$.

```{code-cell} ipython3
def variational_circuit(gamma: float) -> Circuit:
Expand All @@ -45,7 +45,7 @@ def variational_circuit(gamma: float) -> Circuit:

q0, q1 = LineQubit.range(2)

return Circuit([CNOT(q0, q1), rx(gamma)(q1), CNOT(q0, q1)])
return Circuit([rx(gamma)(q0), CNOT(q0, q1), rx(gamma)(q1), CNOT(q0, q1), rx(gamma)(q0)])

```

Expand All @@ -66,7 +66,7 @@ z = np.diag([1, -1])
hamiltonian = np.kron(z, z)

# Strength of noise channel
p = 0.1
p = 0.04

def executor(circ: Circuit) -> float:
"""Simulates the execution of a circuit with depolarizing noise.
Expand Down Expand Up @@ -99,7 +99,7 @@ We now compute the unmitigated energy landscape $\langle H \rangle(\gamma) =\lan
in the following code block.

```{code-cell} ipython3
gammas = np.linspace(-2 * np.pi, 2 * np.pi, 50)
gammas = np.linspace(0, 2 * np.pi, 50)
expectations = [executor(variational_circuit(g)) for g in gammas]
```

Expand All @@ -118,10 +118,11 @@ plt.show()

## Computing the mitigated landscape
We now repeat the same task but use Mitiq to mitigate errors.
We do so by first getting a mitigated executor as follows.
We initialize a RichardsonFactory with scale factors `[1, 3, 5]` and we get a mitigated executor as follows.

```{code-cell} ipython3
mitigated_executor = mitigate_executor(executor)
fac = RichardsonFactory(scale_factors=[1, 3, 5])
mitigated_executor = mitigate_executor(executor, factory=fac)
```

We then run the same code above to compute the energy landscape, but this time use the ``mitigated_executor`` instead of just the executor.
Expand Down Expand Up @@ -151,6 +152,8 @@ which is required in most variational algorithms such as VQE or QAOA.
We also observe that the minimum of mitigated energy approximates well the theoretical ground state which is equal to $-1$. Indeed:

```{code-cell} ipython3
print(f"Minimum of the noisy landscape: {round(min(expectations), 3)}")
print(f"Minimum of the mitigated landscape: {round(min(mitigated_expectations), 3)}")
print(f"Theoretical groud state energy: {min(np.linalg.eigvals(hamiltonian))}")
```

Expand Down
5 changes: 0 additions & 5 deletions mitiq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@
from mitiq._typing import QPROGRAM
from mitiq._version import __version__
from mitiq.collector import generate_collected_executor
from mitiq._deprecations import (
execute_with_zne,
mitigate_executor,
zne_decorator,
)
16 changes: 6 additions & 10 deletions mitiq/_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ def about() -> None:
from qiskit import __qiskit_version__ # pragma: no cover

qiskit_version = __qiskit_version__["qiskit"] # pragma: no cover
terra_version = __qiskit_version__["qiskit-terra"] # pragma: no cover
aer_version = __qiskit_version__["qiskit-aer"] # pragma: no cover
ibmq_provider_version = __qiskit_version__[
"qiskit-ibmq-provider"
] # pragma: no cover
except ImportError:
qiskit_version = "Not installed"
try:
from braket._sdk import __version__ as braket_version
except ImportError:
braket_version = "Not installed"

about_str = f"""
Mitiq: A Python toolkit for implementing error mitigation on quantum computers
Expand All @@ -68,11 +67,8 @@ def about() -> None:
Optional Dependencies
---------------------
PyQuil Version:\t{pyquil_version}
Qiskit Version: {qiskit_version}
Qiskit Elements:
Terra : {terra_version}
Aer : {aer_version}
IBMQ-Provider : {ibmq_provider_version}
Qiskit Version:\t{qiskit_version}
Braket Version:\t{braket_version}
Python Version:\t{PYTHON_VERSION[0]}.{PYTHON_VERSION[1]}.{PYTHON_VERSION[2]}
Platform Info:\t{platform.system()} ({platform.machine()})"""
Expand Down
44 changes: 0 additions & 44 deletions mitiq/_deprecations.py

This file was deleted.

4 changes: 2 additions & 2 deletions mitiq/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
_QuantumCircuit = _Circuit

try:
from braket import Circuit as _BKCircuit
except ImportError:
from braket.circuits import Circuit as _BKCircuit
except ImportError: # pragma: no cover
_BKCircuit = _Circuit

QPROGRAM = Union[_Circuit, _Program, _QuantumCircuit, _BKCircuit]
Expand Down
6 changes: 0 additions & 6 deletions mitiq/interface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from mitiq.interface import (
mitiq_braket,
mitiq_cirq,
mitiq_pyquil,
mitiq_qiskit,
)
from mitiq.interface.conversions import (
accept_any_qprogram_as_input,
atomic_converter,
Expand Down
2 changes: 2 additions & 0 deletions mitiq/pec/representations/optimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def minimize_one_norm(
the following representation of the input ``ideal_matrix`` holds:
.. math::
:nowrap:
\text{ideal_matrix} = x_0 A_0 + x_1 A_1 + ...,
where :math:`\{A_j\}` are the basis matrices, i.e., the elements of
Expand Down
34 changes: 0 additions & 34 deletions mitiq/tests/test_errors.py

This file was deleted.

0 comments on commit 704ba56

Please sign in to comment.