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 13 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
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
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include LICENSE
include README.md
include VERSION.txt
include requirements.txt
include dev_requirements.txt
include requirements/*.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
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,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://qiskit.org/) | [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
6 changes: 2 additions & 4 deletions docs/CONTRIBUTING_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +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.
cosenal marked this conversation as resolved.
Show resolved Hide resolved

### Sphinx extensions used to build the docs
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
3 changes: 3 additions & 0 deletions requirements/requirements-cirq.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is redundant, since the internal representation of choice is Cirq.
cosenal marked this conversation as resolved.
Show resolved Hide resolved
# Keeping it 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