-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
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:
|
Pull Request Test Coverage Report for Build 4504655680
💛 - 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.
c3eab9f
to
cb3e5cc
Compare
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.
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.
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.
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.
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.
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.
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