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

Introduce requirement setup for integrations #2303

Merged
merged 15 commits into from
Apr 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ conda activate myenv
```
5. Install the dependencies. First, to get an updated version of [`pip`](https://pypi.org/project/pip/) inside the virtual environment run `conda install pip` followed by
```
pip install -e ".[development]"
make install
```
6. You should now have a development environment set up to work on Mitiq! 🎉 To go forward with making the desired changes, please consult the ["Making changes" section](https://www.asmeurer.com/git-workflow/#making-changes) of the `git` workflow article. If you've encountered any problems thus far, please let us know by opening an issue! More information about workflow can be found below in the [lifecycle](#lifecycle) section.

Expand Down
6 changes: 6 additions & 0 deletions INTEGRATIONS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
braket
cirq
pennylane
pyquil
qibo
qiskit
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include LICENSE
include README.md
include VERSION.txt
include requirements.txt
include dev_requirements.txt
include requirements/*.txt
include INTEGRATIONS.txt
recursive-include docs/ *.ini
recursive-include docs/ README-docs.md
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ install-hooks:
@echo "Git hooks installed."

.PHONY: requirements
requirements: requirements.txt
pip install -r requirements.txt
requirements: requirements/requirements.txt
pip install -r requirements/requirements.txt

.PHONY: test
test:
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,23 @@ We refer to any programming language you can write quantum circuits in as a _fro
#### Supported frontends


| [Cirq](https://quantumai.google/cirq) | [Qiskit](https://www.ibm.com/quantum/qiskit) | [pyQuil](https://github.com/rigetti/pyquil) | [Braket](https://github.com/aws/amazon-braket-sdk-python) | [PennyLane](https://pennylane.ai/) |[Qibo](https://qibo.science/) |
|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|
| [Cirq](https://quantumai.google/cirq) | [Qiskit](https://www.ibm.com/quantum/qiskit) | [pyQuil](https://github.com/rigetti/pyquil) | [Braket](https://github.com/aws/amazon-braket-sdk-python) | [PennyLane](https://pennylane.ai/) | [Qibo](https://qibo.science/) |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <a href="https://quantumai.google/cirq"><img src="https://raw.githubusercontent.com/quantumlib/Cirq/main/docs/images/Cirq_logo_color.png" alt="Cirq logo" width="65"/></a> | <a href="https://qiskit.org/"><img src="https://qiskit.org/images/qiskit-logo.png" alt="Qiskit logo" width="40"/></a> | <a href="https://github.com/rigetti/pyquil"><img src="https://www.rigetti.com/uploads/Logos/logo-rigetti-gray.jpg" alt="Rigetti logo" width="75"/></a> | <a href="https://github.com/aws/amazon-braket-sdk-python"><img src="https://a0.awsstatic.com/libra-css/images/logos/aws_logo_smile_1200x630.png" alt="AWS logo" width="75"/></a> | <a href="https://pennylane.ai/"><img src="https://raw.githubusercontent.com/PennyLaneAI/pennylane/c2f96705efd4570e8755e829b11cc869b4c2287d/doc/_static/logo.png" alt="PennyLane logo" width="30"/></a> | <a href="https://qibo.science/"><img src="https://raw.githubusercontent.com/qiboteam/qibo/master/doc/source/_static/qibo_logo_dark.svg" alt="Qibo logo" width="60"/></a> |

Note: Cirq is a core requirement of Mitiq and is installed when you `pip install mitiq`.
You can install Mitiq support for these frontends by specifying them during installation,
as optional extras, along with the main package.
To install Mitiq with one or more frontends, you can specify each frontend in square brackets as part of the installation command.

For example,
to install Mitiq with support for Qiskit and Qibo:
```bash
pip install mitiq[qiskit,qibo]
cosenal marked this conversation as resolved.
Show resolved Hide resolved
```

[Here](https://github.com/unitaryfund/mitiq/blob/main/INTEGRATIONS.txt) is an up-to-date list of supported frontends.

Note: Currently, Cirq is a core requirement of Mitiq and is installed when you `pip install mitiq` (even without the optional `[cirq]`)

#### Supported backends

Expand Down
7 changes: 2 additions & 5 deletions docs/CONTRIBUTING_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ the Python toolkit for implementing error mitigation on quantum computers.
## Requirements
Our documentation is generated with
[Sphinx](https://www.sphinx-doc.org/en/master/usage/installation.html).
The necessary packages can be installed, from the root Mitiq directory
The necessary packages can be installed, from the root Mitiq directory with the command
```bash
pip install -e .
pip install -r dev_requirements.txt
make install
```
as they are included in the `dev_requirements.txt` file.
Alternately, you can use the docker image provided in the repo and all requirements for working with the docs are already installed there.

### Sphinx extensions used to build the docs
- [`myst-nb`](https://myst-nb.readthedocs.io/en/latest/) and [`myst-parser`](https://myst-parser.readthedocs.io/en/latest/) allow both markdown and jupyter notebooks to be included and run by the Sphinx build. Also adds support for [MyST markdown](https://myst-parser.readthedocs.io/en/latest/using/syntax.html) spec.
Expand Down
2 changes: 2 additions & 0 deletions mitiq/_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ def about() -> None:
from pyquil import __version__ as pyquil_version
except ImportError:
pyquil_version = "Not installed"

try:
from qiskit import __qiskit_version__ # pragma: no cover

qiskit_version = __qiskit_version__["qiskit"] # pragma: no cover
except ImportError:
qiskit_version = "Not installed"

try:
from braket._sdk import __version__ as braket_version
except ImportError:
Expand Down
11 changes: 11 additions & 0 deletions mitiq/tests/test_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os

from mitiq.typing import SUPPORTED_PROGRAM_TYPES


def test_supported_program_types_definition():
directory_of_this_file = os.path.dirname(os.path.abspath(__file__))
with open(f"{directory_of_this_file}/../../INTEGRATIONS.txt", "r") as file:
integrations_from_setup = file.read().splitlines()

assert list(SUPPORTED_PROGRAM_TYPES.keys()) == integrations_from_setup
6 changes: 3 additions & 3 deletions mitiq/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def keys(cls) -> Iterable[str]:

# Supported quantum programs.
class SUPPORTED_PROGRAM_TYPES(EnhancedEnum):
CIRQ = "cirq"
PYQUIL = "pyquil"
QISKIT = "qiskit"
BRAKET = "braket"
CIRQ = "cirq"
PENNYLANE = "pennylane"
PYQUIL = "pyquil"
QIBO = "qibo"
QISKIT = "qiskit"


try:
Expand Down
2 changes: 2 additions & 0 deletions requirements/requirements-braket.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
amazon-braket-sdk~=1.69.0
cirq-ionq>=1.0.0,<1.4.0
cosenal marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions requirements/requirements-cirq.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is redundant, since Cirq is the core internal representation
# for quantum circuits in Mitiq.
# Keeping this file anyway for consistency with other integrations.
cirq-core>=1.0.0,<1.4.0
12 changes: 0 additions & 12 deletions dev_requirements.txt → requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# Third-party integration.
qiskit~=1.0.2
qiskit-aer~=0.14.0.1
qiskit-ibm-provider~=0.10.0
qiskit-ibm-runtime~=0.20.0
ply==3.11
pyquil~=3.5.4
pennylane-qiskit~=0.35.1
pennylane~=0.35.1
amazon-braket-sdk~=1.69.0
qibo==0.2.7 # TODO: unpin this

# Unit tests, coverage, and formatting/style.
pytest==8.0.0
pytest-xdist[psutil]==3.0.2
Expand Down
2 changes: 2 additions & 0 deletions requirements/requirements-pennylane.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pennylane-qiskit~=0.35.1
pennylane~=0.35.1
2 changes: 2 additions & 0 deletions requirements/requirements-pyquil.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyquil~=3.5.4
cirq-rigetti>=1.0.0,<1.4.0
1 change: 1 addition & 0 deletions requirements/requirements-qibo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qibo==0.2.7 # TODO: unpin this
cosenal marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions requirements/requirements-qiskit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
qiskit~=1.0.2
qiskit-aer~=0.14.0.1
qiskit-ibm-provider~=0.10.0
qiskit-ibm-runtime~=0.20.0
ply==3.11
2 changes: 1 addition & 1 deletion requirements.txt → requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.22.0
scipy>=1.10.1,<=1.13.0
cirq>=1.0.0,<1.4.0
cirq-core>=1.0.0,<1.4.0
cosenal marked this conversation as resolved.
Show resolved Hide resolved
tabulate
29 changes: 20 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@

from setuptools import find_packages, setup

with open("VERSION.txt", "r") as f:
__version__ = f.read().strip()

with open("requirements.txt") as f:
requirements = f.read().splitlines()
def load_requirements(filename):
with open(f"requirements/{filename}", "r") as file:
return file.read().splitlines()


with open("INTEGRATIONS.txt", "r") as f:
integrations = f.read().splitlines()

with open("dev_requirements.txt") as f:
dev_requirements = f.read().splitlines()
with open("VERSION.txt", "r") as f:
__version__ = f.read().strip()

# save the source code in _version.py
with open("mitiq/_version.py", "r") as f:
Expand All @@ -22,13 +25,21 @@
with open("mitiq/_version.py", "w") as f:
f.write(f"__version__ = '{__version__}'\n")

third_party_integration_requirements = {
cosenal marked this conversation as resolved.
Show resolved Hide resolved
k: load_requirements(f"requirements-{k}.txt") for k in integrations
}

setup(
name="mitiq",
version=__version__,
install_requires=requirements,
install_requires=load_requirements("requirements.txt"),
extras_require={
"development": set(dev_requirements),
},
"development": set().union(
*third_party_integration_requirements.values(),
load_requirements("requirements-dev.txt"),
)
}
| third_party_integration_requirements,
packages=find_packages(),
include_package_data=True,
description="Mitiq is an open source toolkit for implementing error "
Expand Down
Loading