Skip to content

Conversation

mtreinish
Copy link
Member

Summary

This commit adds a new option to the unitary gate class's constructor, skip_check, which is used to skip the checking on the input unitary. When creating a unitary gates when you know the input is already unitary checking that the input matrix is unitary is wasted CPU time. This new option enables a user to assert the input is unitary and skip this checking (at their own risk). The primary use case for this is the consolidate blocks pass which is creating a large number of UnitaryGate objects and matrix is always going to be unitary. This new flag is used in ConsolidateBlocks to speed up the creation of gate objects.

Details and comments

This commit adds a new option to the unitary gate class's constructor,
skip_check, which is used to skip the checking on the input unitary.
When creating a unitary gates when you know the input is already unitary
checking that the input matrix is unitary is wasted CPU time. This new
option enables a user to assert the input is unitary and skip this
checking (at their own risk). The primary use case for this is the
consolidate blocks pass which is creating a large number of UnitaryGate
objects and matrix is always going to be unitary. This new flag is used
in ConsolidateBlocks to speed up the creation of gate objects.
@mtreinish mtreinish added performance Changelog: New Feature Include in the "Added" section of the changelog labels Aug 17, 2023
@mtreinish mtreinish requested a review from a team as a code owner August 17, 2023 17:49
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5894224571

  • 10 of 11 (90.91%) changed or added relevant lines in 2 files are covered.
  • 10 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.009%) to 87.276%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/extensions/unitary.py 6 7 85.71%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 91.39%
crates/qasm2/src/parse.rs 6 97.6%
Totals Coverage Status
Change from base Build 5893570960: 0.009%
Covered Lines: 74369
Relevant Lines: 85211

💛 - Coveralls

@mtreinish mtreinish changed the title Add skip_check option to UnitaryGate Add check_input option to UnitaryGate Sep 18, 2023
@mtreinish mtreinish requested a review from Cryoris September 18, 2023 15:07
@mtreinish mtreinish added this to the 0.45.0 milestone Sep 18, 2023
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.

This looks easy and sensible - only point is that I think a colon got lost by accident in a docstring.

@jakelishman jakelishman added this pull request to the merge queue Oct 2, 2023
Merged via the queue into Qiskit:main with commit 81e28dc Oct 2, 2023
@mtreinish mtreinish deleted the add-assert-unitary branch October 2, 2023 23:40
rupeshknn pushed a commit to rupeshknn/qiskit that referenced this pull request Oct 9, 2023
* Add skip_check option to UnitaryGate

This commit adds a new option to the unitary gate class's constructor,
skip_check, which is used to skip the checking on the input unitary.
When creating a unitary gates when you know the input is already unitary
checking that the input matrix is unitary is wasted CPU time. This new
option enables a user to assert the input is unitary and skip this
checking (at their own risk). The primary use case for this is the
consolidate blocks pass which is creating a large number of UnitaryGate
objects and matrix is always going to be unitary. This new flag is used
in ConsolidateBlocks to speed up the creation of gate objects.

* Rename argument check_input

* Fix rebase issues

* Update qiskit/circuit/library/generalized_gates/unitary.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants