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 v1 primitive implementations #13877

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mtreinish
Copy link
Member

Summary

This commit removes the deprecated implementation of the v1 primitives interface. These were deprecated in the 1.2 release and have been superseded by the implementation of the v2 primtives interface.

Details and comments

This commit removes the deprecated implementation of the v1 primitives
interface. These were deprecated in the 1.2 release and have been
superseded by the implementation of the v2 primtives interface.
@mtreinish mtreinish added the Changelog: Removal Include in the Removed section of the changelog label Feb 18, 2025
@mtreinish mtreinish added this to the 2.0.0 milestone Feb 18, 2025
@mtreinish mtreinish requested review from a team as code owners February 18, 2025 23:06
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @ajavadia
  • @levbishop
  • @t-imamichi

@mtreinish mtreinish closed this Feb 18, 2025
@mtreinish mtreinish reopened this Feb 20, 2025
@ElePT ElePT self-assigned this Feb 21, 2025
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Feb 24, 2025
Two primitives tests were returning incorrect results after being
rewritten to use IfElseOp instead of c_if. This is likely pointing to a
bug in the primitive implementation or an aer bug. But since those
classes are deprecated and the tests will be removed as part of the
larger backend v1 primitive implementation removal in Qiskit#13877 anyway this
commit opts to just delete these tests now.
@mtreinish mtreinish added the mod: primitives Related to the Primitives module label Feb 24, 2025
@coveralls
Copy link

coveralls commented Feb 24, 2025

Pull Request Test Coverage Report for Build 13549367482

Details

  • 51 of 52 (98.08%) changed or added relevant lines in 3 files are covered.
  • 76 unchanged lines in 10 files lost coverage.
  • Overall coverage decreased (-0.1%) to 87.76%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/primitives/backend_estimator_v2.py 48 49 97.96%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
qiskit/result/distributions/quasi.py 1 97.96%
crates/accelerate/src/unitary_synthesis.rs 2 94.29%
crates/qasm2/src/lex.rs 4 91.73%
qiskit/primitives/base/base_estimator.py 5 78.57%
qiskit/primitives/base/base_primitive.py 5 61.54%
qiskit/primitives/base/base_sampler.py 5 79.17%
qiskit/primitives/utils.py 9 76.92%
crates/qasm2/src/parse.rs 12 97.15%
qiskit/primitives/base/validation.py 32 59.77%
Totals Coverage Status
Change from base Build 13544415862: -0.1%
Covered Lines: 77051
Relevant Lines: 87797

💛 - Coveralls

@1ucian0 1ucian0 linked an issue Feb 24, 2025 that may be closed by this pull request
github-merge-queue bot pushed a commit that referenced this pull request Feb 24, 2025
* Remove condition/c_if, duration, and unit from instructions

This commit removes the per instruction attributes for condition,
duration, and unit. These attributes were deprecated in 1.3.0. Besides
the label these attributes were the only mutable state for singleton
instructions and removing them simplifies what needs to be tracked for
instructions in both Python and rust. The associated methods and classes
that were previously dependent on these attributes are also removed as
they no longer serve a purpose. The removal of condition in particular
removes a lot of logic from Qiskit especially from the transpiler
because it was a something that needed to be checked outside of the
normal data model for every operation.

This PR simplifies the representation of this extra mutable state in
Rust by removing the `ExtraInstructionAttributes` struct and replacing
it with a `Option<Box<String>>`. The `Option<Box<String>>` is used
instead of the simpler `Option<String>` because this this reduces the
size of the label field from 24 bytes for `Option<String>` to 8 bytes
for `Option<Box<String>>` with an extra layer of pointer indirection
and a second heap allocation. This will have runtime overhead when
labels are set, but because the vast majority of operations don't set
labels the tradeoff for optimizing for the None case makes more sense.
Another option would have been to use `Box<str>` here which is the
equivalent of `Box<[u8]>` (where `String` is the equivalent to
`Vec<u8>`) and from a runtime memory tradeoff would be a better
choice for this application if labels were commonly used as labels
aren't growable. But that requires 16 bytes instead of 8 and we'd be
wasting an additional 8 bytes for each instruction in the circuit which
isn't worth the cost.

* Update random_circuit

* Update more tests

* Fix new scheduling pass implementation

* Fix clippy::redundant_closure

* Add release note for new args

* Remove unused ExtraAttributes struct

* Remove unused propagate_condition argument

* Update legacy scheduling pass

* Remove AlignMeasures which was deprecated and can not work without per gate duration

* Fix lint

* Remove deleted pass from init modules

* Update qasm2 import to use IfElse instead of c_if

* Use if_test instead of c_if for backwards compat qpy tests

* Update more tests

* More test updates

* Fix handling of lack of dt

* More test upgrades

* Update more tests

* Fix DAGCircuit::compose() panic

* Fix more tests

* Fix lint

* Fix clippy

* Fix MARS pass tests

* Fix timeline drawer core

* Update last c_if usage in tests

* Adjust qpy tests to use c_if in old versions

* Fix typo in qpy backwards compat test changes

* Fix register capture test

* Fix the worst test to debug in the world

* Update release notes

* Fix qpy hard failures

The tests fail because of a circuit equality issue, form experience it's
differing bit lists in the if state blocks.

* Fix rust tests

* Fix rust tests

* Fix scheduled circuit tests

* Fix lint

* Remove visual tests that are no longer valid

* More test fixes

* Time unit conversion only applies to delay now

With the removal of per instruction durations the time unit conversion
pass only should work with delays, because all the instructions have
fixed unit durations in the target (seconds).

* Fix lint

* Update reference images with removed c_if

* Try to fix equality failure in qpy tests

* Fix small oversight in qpy tests

* More qpy test tweaks

* Add missing arg to qpy tests

* Remove c_if references in docs

* Remove unused imports

* Update docs

* Add target to legacy dd pass docs

* Restore propagate_condition arg for compatibility

* More docs updates

* Add back test lift legacy condition

* Remove unnecessary controlflow builder method

* Code simplification

* Add warning to qpy load about condition in payload becoming if_else

* Remove unused import

* Apply suggestions from code review

Co-authored-by: Elena Peña Tapia <[email protected]>

* Handle delay duration in legacy scheduler

* Document no control-flow basic simulator

* Apply suggestions from code review

Co-authored-by: Elena Peña Tapia <[email protected]>

* Fix errant commas

* Remove dead condition check

* Clarify reason for exception suppression

* Simplify time-unit conversions

* Restore overly eager test removal from test_circuit_operations

* Restore dag dep drawer test

* Restore text drawer tests

* Restore removed tests in test_circuit_drawer

* Control fold in restored test for variable terminal width in CI

* Remove bugged tests in backend v1 primitives implementation

Two primitives tests were returning incorrect results after being
rewritten to use IfElseOp instead of c_if. This is likely pointing to a
bug in the primitive implementation or an aer bug. But since those
classes are deprecated and the tests will be removed as part of the
larger backend v1 primitive implementation removal in #13877 anyway this
commit opts to just delete these tests now.

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
Co-authored-by: Jake Lishman <[email protected]>
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: primitives Related to the Primitives module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove PrimitiveV1, deprecated 1.2
4 participants