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

Remove legacy qasm2 parser #11308

Merged
merged 10 commits into from
Nov 29, 2023
Merged

Conversation

mtreinish
Copy link
Member

Summary

This commit removes the legacy qasm2 parser. This was the original qasm parser in qiskit dating back to the very beginning of the project, but it has been superseded in recent releases by the faster more correct/strict rust parser. We no longer need to keep around two parsers for qasm2. This commit removes the legacy one and it's associated functions (like the ast converter).

Details and comments

This commit removes the legacy qasm2 parser. This was the original
qasm parser in qiskit dating back to the very beginning of the project,
but it has been superseded in recent releases by the faster more
correct/strict rust parser. We no longer need to keep around two parsers
for qasm2. This commit removes the legacy one and it's associated
functions (like the ast converter).
@mtreinish mtreinish added Changelog: Removal Include in the Removed section of the changelog mod: qasm2 Relating to OpenQASM 2 import or export labels Nov 23, 2023
@mtreinish mtreinish added this to the 1.0.0 milestone Nov 23, 2023
@mtreinish mtreinish requested a review from a team as a code owner November 23, 2023 12:57
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Nov 23, 2023

Pull Request Test Coverage Report for Build 7026617853

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 17 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.4%) to 87.442%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/tools/jupyter/library.py 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
qiskit/circuit/instruction.py 2 94.83%
crates/qasm2/src/lex.rs 4 92.17%
qiskit/circuit/classical/expr/expr.py 11 90.6%
Totals Coverage Status
Change from base Build 7004497279: 0.4%
Covered Lines: 59758
Relevant Lines: 68340

💛 - Coveralls

@mtreinish
Copy link
Member Author

The open question for me here is what we want to do about the pygments formatter? (Which is the source of the lint failures). Do we remove the argument from the exporter or do we add openqasm-pygments to the optionals list. Personally I would be in favor of just removing the argument I think.

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

My intent about pygments had been to solve the problem by entirely removing QuantumCircuit.qasm. qiskit.qasm2.dumps never had the formatted option, so there's nothing to deprecate.

@jakelishman
Copy link
Member

The other choice about Pygments in the near term is to change it to look up qasm2 by lexer alias, and fallback to unformatted text if there's not one present. That way, if openqasm-pygments is installed, it'll all just work (because it registers with the Pygments entry points), but doesn't mean that Qiskit has a dependency on any particular lexer.

@mtreinish
Copy link
Member Author

I'll just drop QuantumCircuit.qasm as part of this PR, it seems the simplest.

This commit removes the QuantumCircuit.qasm() method as part of the
legacy parser removal. The exporter method was tied to some of the
internals in the now removed `qiskit.qasm` module. The qasm() method was
already queued up for eventual removal, this commit just pushes that
forward so we don't have to add more comptaibility code into it to
keep it working as is without the qiskit.qasm module existing anymore.
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Thanks for this - good to get this all cleaned up. We unified the terminology around OQ2 in #9351, so we probably should match that in the release note.

Comment on lines -1622 to -1627
def qasm(
self,
formatted: bool = False,
filename: str | None = None,
encoding: str | None = None,
) -> str | None:
Copy link
Member

Choose a reason for hiding this comment

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

We need to remember to follow up this removal with a 0.46 deprecation if we're going ahead with it for 1.0 (which I think we should).

@@ -1,6 +1,5 @@
rustworkx>=0.13.0
numpy>=1.17,<2
ply>=3.10
Copy link
Member

Choose a reason for hiding this comment

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

Very pleased to see this going, especially since it's not been maintained as an actual Python package since 2020.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was actually my motivation for this PR, I was looking at the requirements list and forgot this was in there.

Co-authored-by: Jake Lishman <jake@binhbar.com>
@jakelishman jakelishman added this pull request to the merge queue Nov 29, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 29, 2023
@jakelishman jakelishman added this pull request to the merge queue Nov 29, 2023
Merged via the queue into Qiskit:main with commit 2e640b2 Nov 29, 2023
14 checks passed
@1ucian0
Copy link
Member

1ucian0 commented Nov 30, 2023

The removal broke Randomized tests #2645 (comment) . Probably an easy fix.

@jakelishman
Copy link
Member

Yeah, the randomised tests just need to switch to using qasm2.dumps instead.

mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Nov 30, 2023
The legacy qasm2 parser was remvoed on the main branch already
in Qiskit#11308 for the 1.0.0 release. To ensure that users of the 0.x release
series are warned of this API change this commit marks the functionality
removed in Qiskit#11308 as deprecated for the 0.46.0 release.
github-merge-queue bot pushed a commit that referenced this pull request Jan 2, 2024
* Deprecate legacy qasm2 parser for 0.46

The legacy qasm2 parser was remvoed on the main branch already
in #11308 for the 1.0.0 release. To ensure that users of the 0.x release
series are warned of this API change this commit marks the functionality
removed in #11308 as deprecated for the 0.46.0 release.

* Update qiskit/converters/ast_to_dag.py

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
@mtreinish mtreinish deleted the remove-legacy-qasm2 branch January 2, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Removal Include in the Removed section of the changelog mod: qasm2 Relating to OpenQASM 2 import or export
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants