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
mtreinish
left a comment
There was a problem hiding this comment.
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)).
mtreinish
left a comment
There was a problem hiding this comment.
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_capacityalternative initializer for theDAGCircuitin Rust.Details and comments
Will be rebased after #12550 merges
These commits add the
DAGCircuit::with_capacityconstructor to the rust representation ofDAGCircuit. This would allow us to allocate an approximation of the necessary space to successfully create aDAGCircuitwith certain properties to avoid re-allocating space in memory.This constructor takes the following arguments:
num_qubitsfor the number of qubits in the specific circuit.num_clbitsfor the number of clbits in the circuit.num_opsfor the number of operations in the circuit (Optional).num_varsfor the number of variables in the circuit (Optional).Questions
num_ops?DAGCircuit, there can be 100op_nodesof just the same operation or 100 different operations occurring just once.num_opsbut if a different opinion exists, let me know in a comment.Blockers
DAGCircuitto Rust #12550