-
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
Implement a capacity-allocated constructor for DAGCircuit
in Rust.
#12975
Conversation
Pull Request Test Coverage Report for Build 10690338962Warning: 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
💛 - Coveralls |
2533f4b
to
66c3c0e
Compare
#12812 might be useful for you on this. This was me adding basically the same interface to the python space constructor for |
66c3c0e
to
c5152d8
Compare
78ab11b
to
c86aa6b
Compare
One or more of the following people are relevant to this code:
|
DAGCircuit
in Rust.DAGCircuit
in Rust.
c86aa6b
to
9b9f124
Compare
- Implement `DAGCircuit` with `with_capacity` to create an initially allocated instance, for rust only. - Implement `with_capacity` for `BitData` and `IndexInterner` that creates an initally allocated instance of each type. - Other small tweaks and fixes. - Add num_edges optional argument. If known, use `num_edges` argument to create a `DAGCircuit` with the exact number of edges. - Leverage usage of new method in `copy_empty_like`. - Use `..Default::default()` for `op_names` and `calibrations` fields in `DAGCircuit::with_capacity()`
9b9f124
to
4d12377
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this LGTM it's a straightforward addition to the rust api for DAGCircuit
. Just one inline comment where I think one argument is in the wrong position.
- The order now follows: qubits, clbits, vars, num_ops, edges. As per [Matthew's comment](Qiskit#12975 (comment)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the quick update
…iskit#12975) * Initial: implement fixed capacity constructor for DAGCircuit - Implement `DAGCircuit` with `with_capacity` to create an initially allocated instance, for rust only. - Implement `with_capacity` for `BitData` and `IndexInterner` that creates an initally allocated instance of each type. - Other small tweaks and fixes. - Add num_edges optional argument. If known, use `num_edges` argument to create a `DAGCircuit` with the exact number of edges. - Leverage usage of new method in `copy_empty_like`. - Use `..Default::default()` for `op_names` and `calibrations` fields in `DAGCircuit::with_capacity()` * Fix: Adapt to Qiskit#13033 * Fix: Re-arrange the function arguments as per @mtreinish's review. - The order now follows: qubits, clbits, vars, num_ops, edges. As per [Matthew's comment](Qiskit#12975 (comment)).
Summary
Resolves #13002
After #12550 merges, the following commits aim to provide a
with_capacity
alternative initializer for theDAGCircuit
in Rust.Details and comments
Will be rebased after #12550 merges
These commits add the
DAGCircuit::with_capacity
constructor to the rust representation ofDAGCircuit
. This would allow us to allocate an approximation of the necessary space to successfully create aDAGCircuit
with certain properties to avoid re-allocating space in memory.This constructor takes the following arguments:
num_qubits
for the number of qubits in the specific circuit.num_clbits
for the number of clbits in the circuit.num_ops
for the number of operations in the circuit (Optional).num_vars
for the number of variables in the circuit (Optional).Questions
num_ops
?DAGCircuit
, there can be 100op_nodes
of just the same operation or 100 different operations occurring just once.num_ops
but if a different opinion exists, let me know in a comment.Blockers
DAGCircuit
to Rust #12550