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

Upgrade Qiskit to 1.0.2 #2269

Merged

Conversation

andre-a-alves
Copy link
Contributor

@andre-a-alves andre-a-alves commented Apr 7, 2024

Description

Closes #2208 #2204 #1422

Upgrades Qiskit to 1.0.2 and introduces a TransformationPass for transforming QuantumRegisters.

Out of Scope

Docs have not been updated to Qiskit 1.0. Some examples from the docs use qiskit.execute() and remain incompatible with Qiskit 1.0.


License

  • I license this contribution under the terms of the GNU GPL, version 3 and grant Unitary Fund the right to provide additional permissions as described in section 7 of the GNU GPL, version 3.

Before opening the PR, please ensure you have completed the following where appropriate.

@andre-a-alves
Copy link
Contributor Author

This morning I took a look at the failing job. The Python 3.9 failures all relate to a dependency conflict involving Sphinx, the Sphinx theme, and nbsphinx, which is unrelated to this PR. Later this week I can look into why the docs are failing. I did not update the examples that use qiskit.execute(), so that could be it, in which case I can update them in the troubleshooting.

@andre-a-alves
Copy link
Contributor Author

Also, the 3.11 failure seems to be an issue with Codecov:
Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}

@cosenal
Copy link
Contributor

cosenal commented Apr 11, 2024

Also, the 3.11 failure seems to be an issue with Codecov: Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}

This was resolved by #2271. If you rebase main into your branch, and restart the test build, it should be fixed.

@cosenal
Copy link
Contributor

cosenal commented Apr 11, 2024

This morning I took a look at the failing job. The Python 3.9 failures all relate to a dependency conflict involving Sphinx, the Sphinx theme, and nbsphinx, which is unrelated to this PR. Later this week I can look into why the docs are failing. I did not update the examples that use qiskit.execute(), so that could be it, in which case I can update them in the troubleshooting.

The docs build is failing, as you suspected, because the qiskit notebooks from the examples haven't been updated.

Copy link

codecov bot commented Apr 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.32%. Comparing base (37a202b) to head (27a7fd2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2269      +/-   ##
==========================================
+ Coverage   98.29%   98.32%   +0.03%     
==========================================
  Files          90       91       +1     
  Lines        4274     4308      +34     
==========================================
+ Hits         4201     4236      +35     
+ Misses         73       72       -1     

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

@andre-a-alves andre-a-alves added priority/high Needs to be fixed ASAP & no later than the next milestone. interface-and-conversions How Mitiq interfaces with quantum software packages. labels Apr 14, 2024
@andre-a-alves
Copy link
Contributor Author

main was merged into the branch, and I updated the docs. The only remaining failures seem to be unrelated to this PR and have to do with incompatible depends in Python 3.9.

@cosenal
Copy link
Contributor

cosenal commented Apr 14, 2024

Thanks, @andre-a-alves.

The only remaining failures seem to be unrelated to this PR and have to do with incompatible depends in Python 3.9.

They are technically related to this PR in the sense that the conflicts are caused by the new dependencies introduced in this PR. In fact a clean build from the main branch on Python 3.9 is still working. I am not sure why in this PR it's trying to install myst-parser 1.0.0 on Python 3.9 🤷‍♂️ I pushed a commit to pin myst-parser to >= 2.0.0, let's see if it works.

Also note the plan for Mitiq to drop support for Python 3.9 soon, see #2215.

@andre-a-alves
Copy link
Contributor Author

I did not realize. If it doesn't pass with the myst-parser pin, this evening I'll look for a combination of dependencies that work.

mitiq/interface/mitiq_qiskit/conversions.py Show resolved Hide resolved
# Modification made by: André Alves on 07 Apr 2024
#
# For the original code and license, see
# https://github.com/Qiskit/qiskit/blob/stable/1.0/qiskit/transpiler/passes/layout/apply_layout.py
Copy link
Contributor

@cosenal cosenal Apr 15, 2024

Choose a reason for hiding this comment

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

License-wise, it's all good. My concern about having this file in mitiq is that it's going to be hard to keep it synced with the upstream qiskit file. Can't we just use the imported functions as they are, and wrap them where needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is not to keep them in sync. I used a lot of the original ApplyLayout, but I made substantive changes that are different from the original. The original class applies a QuantumRegister with the name q. We initialize the class with our own registers, and we use their names. From what I understand, maintaining the names is one of the purposes of the _transform function. But with probably half the class identical to the original, I thought it appropriate to include the license statement.

Copy link
Contributor

@cosenal cosenal left a comment

Choose a reason for hiding this comment

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

LGTM 🚀
Since it's quite a big change, let's wait for a second review before merging.

@nathanshammah
Copy link
Member

Nice work @andre-a-alves!!

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.

Awesome work Andre! Thanks for the help on this 💪🏻.

I've left a few small comments, but all the major stuff is there. Qiskit users will be very grateful!

docs/source/examples/mitiq-paper/mitiq-paper-codeblocks.md Outdated Show resolved Hide resolved
docs/source/examples/ibmq-backends.md Outdated Show resolved Hide resolved
mitiq/interface/mitiq_qiskit/qiskit_utils.py Outdated Show resolved Hide resolved
mitiq/interface/mitiq_qiskit/tests/test_transpiler.py Outdated Show resolved Hide resolved
mitiq/interface/mitiq_qiskit/transpiler.py Outdated Show resolved Hide resolved
mitiq/interface/mitiq_qiskit/transpiler.py Outdated Show resolved Hide resolved
@andre-a-alves
Copy link
Contributor Author

Awesome work Andre! Thanks for the help on this 💪🏻.

I've left a few small comments, but all the major stuff is there. Qiskit users will be very grateful!

All comments addressed in latest commit. Good catches! Thank you for the review!

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.

:shipit:

@FarLab FarLab merged commit 5365e7a into unitaryfund:main Apr 19, 2024
16 checks passed
cosenal added a commit that referenced this pull request Apr 22, 2024
* 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 <alessandro@unitary.fund>
@cosenal cosenal mentioned this pull request Apr 23, 2024
cosenal added a commit that referenced this pull request Jun 26, 2024
* 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 <alessandro@unitary.fund>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interface-and-conversions How Mitiq interfaces with quantum software packages. priority/high Needs to be fixed ASAP & no later than the next milestone.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any qiskit circuit that requires conversion to qasm breaks as of qiskit 1.0.1
5 participants