C API: Burn Optimize1qGatesDecomposition.#14710
Conversation
Optimize1qGateDecomposition.Optimize1qGatesDecomposition.
Pull Request Test Coverage Report for Build 17244313498Details
💛 - Coveralls |
89fdfc0 to
f122074
Compare
|
One or more of the following people are relevant to this code:
|
Optimize1qGatesDecomposition.Optimize1qGatesDecomposition.
- The following commit adds initial access to a standalone C foreign function interface that allows users to run the `Optimize1qGatesDecomposition` transpiler pass. The feature as it stands requires the user to build a target prior to submitting the circuit; This might change in the future. - Added 1 initial testing suite for the pass which converts a sequence of H gates into a different sequences depending on the provided target. More tests will be added with time.
… API. - Add ability of running the pass without passing a `Target`. - Add proper formatting to unit tests with multiple tests inside. - Add tests without target.
42b7c38 to
cfc03cb
Compare
|
This PR is currently blocked on #14777 |
| /// qubit it operates on. | ||
| /// | ||
| /// @param circuit A pointer to the ``QkCircuit`` object to transform. | ||
| /// @param target A pointer to the ``QkTarget`` object. |
There was a problem hiding this comment.
From the code it looks like this is allowed to be a null pointer. What happens in this case? We should document that
There was a problem hiding this comment.
From snippet:
/// In the case a null pointer is provided and gate errors are unknown
/// the pass will choose the sequence with the least amount of gates,
/// and will support all basis gates on its Euler basis set.
- Make tha function call run in-place and modify the pointer to the `QkCircuit` in use. - Remove `h_p_target` from tests. - Use parametric gates in the target with generic parameter expressions instead of fixed ones.
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Cryoris
left a comment
There was a problem hiding this comment.
Overall LGTM, some nits below and then I think there are 2 open comments left: one about renaming this pass (which I still think we should take the chance for) and one about the docs saying that this pass compresses sequences into a single gate (which it doesn't, right?)
| let mut circuit_as_dag = DAGCircuit::from_circuit_data(circuit, false, None, None, None, None) | ||
| .expect("Error while converting the circuit to a dag."); |
There was a problem hiding this comment.
It would be nice if we would have a set of TranspilerErrors which we could return here instead of just panicking... but maybe this would need to be done generally for all passes in a follow-up.
Co-authored-by: Julien Gacon <gaconju@gmail.com>
|
This LGTM up to the two comments above on the documentation (this pass does not merge gates into a single gate, the Python docs are also wrong 🙂) and I still think we should rename this pass 🙂 |
Cryoris
left a comment
There was a problem hiding this comment.
some small comments about memory freeing otherwise I think we can merge 👍🏻
- Rename files from `optimize_1q_decomposition` to `optiize_1q_sequences`. - Fixed previous oversight that counted operations before the pass was ran.
Cryoris
left a comment
There was a problem hiding this comment.
LGTM, I have two optional comments which we can also clean up in a follow up.
- Update release note to include explanation as to what happens if a `Target` is not provided. - Update helper function `compare_gate_counts` to take `counts` by reference.
* Initial: Introduce C-API Access to `Optimize1qGatesDecomposition`. - The following commit adds initial access to a standalone C foreign function interface that allows users to run the `Optimize1qGatesDecomposition` transpiler pass. The feature as it stands requires the user to build a target prior to submitting the circuit; This might change in the future. - Added 1 initial testing suite for the pass which converts a sequence of H gates into a different sequences depending on the provided target. More tests will be added with time. * Fix: Add target identity test. * Chore: Fix docstring and free some pointers. * Add: Support for optional target for `Optimize1qGatesDecomposition` C API. - Add ability of running the pass without passing a `Target`. - Add proper formatting to unit tests with multiple tests inside. - Add tests without target. * Chore: Add release note. * Chore: Fix docstring. * Chore: Fix bug in release note * Chore: Address review comments - Make tha function call run in-place and modify the pointer to the `QkCircuit` in use. - Remove `h_p_target` from tests. - Use parametric gates in the target with generic parameter expressions instead of fixed ones. * Update crates/cext/src/transpiler/passes/optimize_1q_decomposition.rs Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Chore: Fix docstring * Chore: Fix release note * Update test/c/test_optimize_1q_decomposition.c Co-authored-by: Julien Gacon <gaconju@gmail.com> * Chore: Address review comments. * Fix: Review comments * Fix: Address some memory leakage. * Fix: Incorrect function name call * Chore: Address different review items - Rename files from `optimize_1q_decomposition` to `optiize_1q_sequences`. - Fixed previous oversight that counted operations before the pass was ran. * Fix: Replace `QkOpCounts` failures until it is fixed. * Fix: Add final review comments. - Update release note to include explanation as to what happens if a `Target` is not provided. - Update helper function `compare_gate_counts` to take `counts` by reference. * Fix: Cformatting issues. * Fix: More c formatting issues. --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Julien Gacon <gaconju@gmail.com>
* Initial: Introduce C-API Access to `Optimize1qGatesDecomposition`. - The following commit adds initial access to a standalone C foreign function interface that allows users to run the `Optimize1qGatesDecomposition` transpiler pass. The feature as it stands requires the user to build a target prior to submitting the circuit; This might change in the future. - Added 1 initial testing suite for the pass which converts a sequence of H gates into a different sequences depending on the provided target. More tests will be added with time. * Fix: Add target identity test. * Chore: Fix docstring and free some pointers. * Add: Support for optional target for `Optimize1qGatesDecomposition` C API. - Add ability of running the pass without passing a `Target`. - Add proper formatting to unit tests with multiple tests inside. - Add tests without target. * Chore: Add release note. * Chore: Fix docstring. * Chore: Fix bug in release note * Chore: Address review comments - Make tha function call run in-place and modify the pointer to the `QkCircuit` in use. - Remove `h_p_target` from tests. - Use parametric gates in the target with generic parameter expressions instead of fixed ones. * Update crates/cext/src/transpiler/passes/optimize_1q_decomposition.rs Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Chore: Fix docstring * Chore: Fix release note * Update test/c/test_optimize_1q_decomposition.c Co-authored-by: Julien Gacon <gaconju@gmail.com> * Chore: Address review comments. * Fix: Review comments * Fix: Address some memory leakage. * Fix: Incorrect function name call * Chore: Address different review items - Rename files from `optimize_1q_decomposition` to `optiize_1q_sequences`. - Fixed previous oversight that counted operations before the pass was ran. * Fix: Replace `QkOpCounts` failures until it is fixed. * Fix: Add final review comments. - Update release note to include explanation as to what happens if a `Target` is not provided. - Update helper function `compare_gate_counts` to take `counts` by reference. * Fix: Cformatting issues. * Fix: More c formatting issues. --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Julien Gacon <gaconju@gmail.com>
Summary
After oxidizing
Optimize1QGatesDecompositionin #12959 it's time to make a combustion reaction that releases a carbon byproduct (our C API for it). The following commits aim to expose a standalone function that will give access to the rust counterpart.This implementation adds the function
qk_transpiler_standalone_optimize_1q_gates_decompositionwhich accepts aQkCircuitand an optional instance ofQkTargetand calls the Rust counterpart.Details and comments
Closes #14453.
Built on top of #14668 (NEEDS REBASING AFTER IT MERGES).REBASED!