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

Introduce requirement setup for integrations #2303

merged 15 commits into from
Apr 30, 2024

Conversation

cosenal
Copy link
Contributor

@cosenal cosenal commented Apr 17, 2024

Description

At the moment, we don't pin the version of integration packages (Braket, Qiskit, etc.) in the Mitiq package that we ship to users. This causes incompatibility issues, e.g, #2208.

This PR introduces integration packages as extra dependencies.

Example: if a user wants to use Mitiq with Qiskit, they can run

pip install mitiq[qiskit]

in their enviroment, and similarly for all other integrations we support. This will guarantee that the version of the integration packages we support are compatible with the ones in the user's environment.

🎪 One important bonus is that now the main Mitiq package only depends on cirq-core as opposed to the full cirq package 🎪


This fixes #1201 (see Issue description)

Docs

Readme has been updated.

Note: There will be a lapse of time between merging this PR and the next release, when the README will not be synced with reality of the package. We may consider split the Readme change and ship that along with the release PR. (cc @FarLab as milestone manager.)

Testing

I tested that:

  1. for Mitiq developers, everything works just like before with pip install -e .[development]
  2. the code snippet from the README works with pip install mitiq (without any extra)
  3. the different extra installations for the supported frontend also works (tested started from empty Conda environments)

@cosenal cosenal requested a review from natestemen April 17, 2024 21:32
Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.22%. Comparing base (44f7c91) to head (d924a34).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2303   +/-   ##
=======================================
  Coverage   98.22%   98.22%           
=======================================
  Files          87       87           
  Lines        4056     4056           
=======================================
  Hits         3984     3984           
  Misses         72       72           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jordandsullivan
Copy link
Contributor

Good idea. I've already hit this issue several times.

Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a high level this looks great. I like this structure a lot! 👍🏻

cosenal and others added 12 commits April 22, 2024 11:41
* Add link to public agenda for community call to README

* remove anchor to the heading for agenda

Co-authored-by: nate stemen <[email protected]>

---------

Co-authored-by: nate stemen <[email protected]>
* updates dev_requirements for Qiskit 1.0.2

* updates qiskit_utils to not use execute

* updates conversions to use qasm2.dumps

* updates I gate

* adds TransformationPass to _transform_registers

* updates test

* updates zne tests

* fixes ddd tests

* fixes pec tests

* fixes zne scaling tests

* adds tests for transpiler

* updates aer version

* updates docs examples

* slightly refactors qiskit transpilations

* updates mitiq paper codeblock

* pin myst-parser dependency

* fixes docstring and adds tests for multi-register circuit

* applies suggestions from comments

---------

Co-authored-by: Alessandro Cosentino <[email protected]>
@cosenal cosenal marked this pull request as ready for review April 23, 2024 08:11
@cosenal
Copy link
Contributor Author

cosenal commented Apr 23, 2024

@natestemen @jordandsullivan This is now ready to review. Please take a look.

@cosenal cosenal added this to the v0.36.0 milestone Apr 23, 2024
@natestemen natestemen self-requested a review April 23, 2024 15:56
Copy link
Contributor

@jordandsullivan jordandsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have updated make install to include all these requirements, can we also update this line in the main CONTRIBUTING guide to say make install rather than pip install -e ".[development]"?

docs/CONTRIBUTING_DOCS.md Outdated Show resolved Hide resolved
requirements/requirements.txt Show resolved Hide resolved
requirements/requirements-qibo.txt Show resolved Hide resolved
setup.py Show resolved Hide resolved
README.md Show resolved Hide resolved
requirements/requirements-braket.txt Show resolved Hide resolved
requirements/requirements-cirq.txt Outdated Show resolved Hide resolved
@cosenal
Copy link
Contributor Author

cosenal commented Apr 23, 2024

@jordandsullivan Thanks for the thorough review. I addressed / replied to all your comments. PTAL

Copy link
Contributor

@jordandsullivan jordandsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me!

Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alessandro!

Looking forward to this helping users use Mitiq with less dependency issues.

I was brainstorming potential issues that could still arise, and I came up with the following scenario.

  1. User gets set up in their desired frontend (not cirq), writing ciruits and running them
  2. They learn about Mitiq
  3. They run pip install mitiq without looking through the docs too much
  4. They hit compatibility issues

If this users then come to us, it should be easy to help solve their problem, as we can ask them to run pip install mitiq[frontend].

This is not a blocker, but I just wanted to write this down both for my understanding1, and so we all know there are still some potential issues this does not solve. I don't think there's any magic bullet for this problem, however.

Footnotes

  1. If I'm misunderstanding something, let me know!

@cosenal
Copy link
Contributor Author

cosenal commented Apr 25, 2024

@natestemen You're right, that's a valid scenario. One way to mitigate it would be to use the tools from pkg_resources to check at runtime (as early as possible) for the dependencies installed in the user environment. Example:

pkg_resources.working_set.require('qiskit~=2.0.0')

VersionConflict: (qiskit 1.0.2 (/opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages), Requirement.parse('qiskit~=2.0.2')) 

vs.

pkg_resources.working_set.require('qiskit~=1.0.2')

[qiskit 1.0.2 (/opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages)
...
]

Perhaps something for a follow-up PR, subject to prioritization, in case we get more dependency issues reported.

@natestemen
Copy link
Member

Yup agreed, lets only pursue further ideas if we get more complaints. Thanks for jotting down a potential next step :)

@cosenal cosenal merged commit a20e6bd into main Apr 30, 2024
18 checks passed
@cosenal cosenal deleted the setup-integrations branch April 30, 2024 15:27
@cosenal
Copy link
Contributor Author

cosenal commented Apr 30, 2024

Merged this. After the two reviewers approvals, I have only merged main into the branch and solved the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update about() and document latest package support
5 participants