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

Add option to skip deepcopy on circuit_to_dag #9848

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

mtreinish
Copy link
Member

Summary

Just as was done for #9825 for dag_to_circuit(), this commit adds a new option, copy_operations, which allows to disable the deepcopy on circuit_to_dag(). Previously, the circuit to dag converter would always deep copy every operation, however we don't need this extra overhead in every case; where the input QuantumCircuit is discarded after conversion. This new flag lets us avoid the copy overhead in these situations, however in general the converter still needs to default to copying.

Details and comments

@mtreinish mtreinish added performance Changelog: New Feature Include in the "Added" section of the changelog labels Mar 23, 2023
@mtreinish mtreinish added this to the 0.24.0 milestone Mar 23, 2023
@mtreinish mtreinish requested a review from Cryoris March 23, 2023 17:53
@mtreinish mtreinish requested a review from a team as a code owner March 23, 2023 17:53
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Mar 23, 2023

Pull Request Test Coverage Report for Build 4504655680

  • 6 of 6 (100.0%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.03%) to 85.039%

Files with Coverage Reduction New Missed Lines %
qiskit/circuit/tools/pi_check.py 1 91.23%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 1 94.68%
qiskit/pulse/library/waveform.py 3 91.67%
Totals Coverage Status
Change from base Build 4502882383: -0.03%
Covered Lines: 67613
Relevant Lines: 79508

💛 - Coveralls

Just as was done for Qiskit#9825 for dag_to_circuit(), this commit adds a new
option, copy_operations, which allows to disable the deepcopy on
circuit_to_dag(). Previously, the circuit to dag converter would always
deep copy every operation, however we don't need this extra overhead
in every case; where the input QuantumCircuit is discarded after
conversion. This new flag lets us avoid the copy overhead in these
situations, however in general the converter still needs to default to
copying.
@mtreinish mtreinish force-pushed the skip-deepcopy-circuit-to-dag branch from c3eab9f to cb3e5cc Compare March 23, 2023 19:53
@Cryoris Cryoris added this pull request to the merge queue Mar 31, 2023
Merged via the queue into Qiskit:main with commit 51cbe1f Mar 31, 2023
ElePT pushed a commit to ElePT/qiskit that referenced this pull request Apr 5, 2023
Just as was done for Qiskit#9825 for dag_to_circuit(), this commit adds a new
option, copy_operations, which allows to disable the deepcopy on
circuit_to_dag(). Previously, the circuit to dag converter would always
deep copy every operation, however we don't need this extra overhead
in every case; where the input QuantumCircuit is discarded after
conversion. This new flag lets us avoid the copy overhead in these
situations, however in general the converter still needs to default to
copying.
giacomoRanieri pushed a commit to giacomoRanieri/qiskit-terra that referenced this pull request Apr 16, 2023
Just as was done for Qiskit#9825 for dag_to_circuit(), this commit adds a new
option, copy_operations, which allows to disable the deepcopy on
circuit_to_dag(). Previously, the circuit to dag converter would always
deep copy every operation, however we don't need this extra overhead
in every case; where the input QuantumCircuit is discarded after
conversion. This new flag lets us avoid the copy overhead in these
situations, however in general the converter still needs to default to
copying.
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
Just as was done for Qiskit#9825 for dag_to_circuit(), this commit adds a new
option, copy_operations, which allows to disable the deepcopy on
circuit_to_dag(). Previously, the circuit to dag converter would always
deep copy every operation, however we don't need this extra overhead
in every case; where the input QuantumCircuit is discarded after
conversion. This new flag lets us avoid the copy overhead in these
situations, however in general the converter still needs to default to
copying.
@mtreinish mtreinish deleted the skip-deepcopy-circuit-to-dag branch August 23, 2023 19:47
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Aug 23, 2023
In the Unroll3qOrMore pass internally is quite simple it iterates over
every operation in the circuit and for any operation that uses >= 3
qubits and recursively decompsing it into all 1 and 2 qubit operations,
converting it to a DAGCircuit and substituting the >=3 qubit gates with
the equivalent circuit. However, during this DAGCircuit conversion step
we're spending a large amount deep copying the operation objects.
However, we don't need to do this because nothing in the circuit will be
reused with shared references so we can skip the copying and just pass
the operation objects by reference onto the DAG (as that's all we need).
This commit makes that change by using the `copy_operations` flag we
introduced in Qiskit#9848 on circuit_to_dag() to disable the internal copying.
github-merge-queue bot pushed a commit that referenced this pull request Aug 25, 2023
In the Unroll3qOrMore pass internally is quite simple it iterates over
every operation in the circuit and for any operation that uses >= 3
qubits and recursively decompsing it into all 1 and 2 qubit operations,
converting it to a DAGCircuit and substituting the >=3 qubit gates with
the equivalent circuit. However, during this DAGCircuit conversion step
we're spending a large amount deep copying the operation objects.
However, we don't need to do this because nothing in the circuit will be
reused with shared references so we can skip the copying and just pass
the operation objects by reference onto the DAG (as that's all we need).
This commit makes that change by using the `copy_operations` flag we
introduced in #9848 on circuit_to_dag() to disable the internal copying.
SamD-1998 pushed a commit to SamD-1998/qiskit-terra that referenced this pull request Sep 7, 2023
In the Unroll3qOrMore pass internally is quite simple it iterates over
every operation in the circuit and for any operation that uses >= 3
qubits and recursively decompsing it into all 1 and 2 qubit operations,
converting it to a DAGCircuit and substituting the >=3 qubit gates with
the equivalent circuit. However, during this DAGCircuit conversion step
we're spending a large amount deep copying the operation objects.
However, we don't need to do this because nothing in the circuit will be
reused with shared references so we can skip the copying and just pass
the operation objects by reference onto the DAG (as that's all we need).
This commit makes that change by using the `copy_operations` flag we
introduced in Qiskit#9848 on circuit_to_dag() to disable the internal copying.
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