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 use of deprecated objects in BasicSimulator #13743

Merged
merged 9 commits into from
Feb 4, 2025

Conversation

ElePT
Copy link
Contributor

@ElePT ElePT commented Jan 27, 2025

Summary

This PR refactors BasicSimulator not to rely on deprecated objects such as:

  • _assemble
  • qobj
  • BackendConfiguration

Only the last removal is considered user facing.

Details and comments

Note that because of the removal of c_if (documented in #13506), there is currently no support for control flow operations in BasicSimulator. The "new" control flow operations were never supported in BasicSimulator, and this PR removes the outdated c_if support. The potential implementation of proper control flow is left as a future improvement as users can always resort to AerSimulator for this.

Similarly, as a side effect of the detanglement of assemble, the BasicSimulator class no longer supports providing parameter bounds to its run method. This functionality was not explicitly documented and is likely not expected by users, as it has not been part of the "standard" backend.run workflow for a while. However, a few legacy tests made use of it together with assemble. The tests are removed as part of the PR.

TODO:

  • clean up code
  • reno

… for c_if (deprecated) and providing parameter bounds to the "run" method.
@coveralls
Copy link

coveralls commented Jan 27, 2025

Pull Request Test Coverage Report for Build 13132223627

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 71 of 72 (98.61%) changed or added relevant lines in 2 files are covered.
  • 28 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.01%) to 88.837%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/providers/basic_provider/basic_simulator.py 69 70 98.57%
Files with Coverage Reduction New Missed Lines %
qiskit/providers/basic_provider/basic_provider_tools.py 1 83.33%
crates/circuit/src/operations.rs 1 89.61%
qiskit/result/result.py 3 83.74%
crates/accelerate/src/sparse_observable.rs 3 94.33%
qiskit/providers/models/backendconfiguration.py 3 85.76%
crates/qasm2/src/lex.rs 5 92.23%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 13055798857: 0.01%
Covered Lines: 79717
Relevant Lines: 89734

💛 - Coveralls

@ElePT ElePT marked this pull request as ready for review January 28, 2025 10:37
@ElePT ElePT requested review from jyu00 and a team as code owners January 28, 2025 10:37
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@ElePT ElePT added the Changelog: Removal Include in the Removed section of the changelog label Jan 28, 2025
@ElePT ElePT added this to the 2.0.0 milestone Jan 28, 2025
Copy link
Contributor

@eliarbel eliarbel left a comment

Choose a reason for hiding this comment

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

Overall seems good, thanks @ElePT!

I've left some minor line comments which need addressing.

The only concern I have is the possibe impact of removing support for the legacy c_if on projects which for some reason still use it. I guess we'll just have to rely on testing against main before the 2.0 release to reveal that, if at all.

qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
ElePT and others added 3 commits January 30, 2025 09:47
… Add unit tests. Rename kwargs to unify use of options with aer simulator and update documentation to reflect actual usage.
Comment on lines -284 to -287
chop_threshold=1e-15,
allow_sample_measuring=True,
seed_simulator=None,
parameter_binds=None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realized that these options weren't used anywhere so I removed the fields.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe extend the reno with these removals? Should they be deprecated in 1.4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are not part of the documented API, they were actually not even documented informally, so the deprecation isn't needed. I added the "surviving" options to the docstring of the run method to have them documented somewhere. I could add that to the reno, but I don't think it's required.

@ElePT ElePT requested a review from eliarbel January 30, 2025 17:26
@1ucian0
Copy link
Member

1ucian0 commented Feb 3, 2025

This PR is blocking #13748. It would be great to merge it this week.

Copy link
Contributor

@eliarbel eliarbel left a comment

Choose a reason for hiding this comment

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

Thanks @ElePT for the fixes and adding the tests. Just a few tiny doc touches and a clean and this should be ready to go.

qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
qiskit/providers/basic_provider/basic_simulator.py Outdated Show resolved Hide resolved
@ElePT ElePT requested a review from eliarbel February 4, 2025 10:35
Copy link
Contributor

@eliarbel eliarbel left a comment

Choose a reason for hiding this comment

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

Cheers!

@eliarbel eliarbel added this pull request to the merge queue Feb 4, 2025
Merged via the queue into Qiskit:main with commit 4347eb8 Feb 4, 2025
17 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants