Use rust-native error for CommutationCancellation#16196
Open
raynelfss wants to merge 3 commits into
Open
Conversation
Use rust-native errors in `DAGCircuit` This should be step 1 for splitting `PyDAGCircuit` from `DAGCircuit`. The following commits assure that any rust accessible method for `DAGCircuit` that: 1. Does not take a `py` token; 2. Is a public method. does not need to depend on `PyErr` to process any errors. It is ensured that these errors: - Maintain the level of detail that the previous ones did. - Correctly map to the same Python exceptions as before. The enumeration for these errors is called `DAGCircuitInnerError` (subject to change) and is implemented with `thiserror`. I chose this over `anyhow` because it is better for specifying where the error comes from based on its variant rather than the message it contains. Lint: Use names instead of underscores Add: `anyhow!` usage for `DAGCircuitError - Use `anyhow!` for any error types that don't require tracking of any variables coming from the `DAG` or that are part of the function arguments. - Consolidate the amount of `DAG` error variants down from 40+ to 21. Can be consolidated further. Fix: Existing error formatting - Use `this_error` to fix the formatting of current errors causing conflicts with their messages. - Add `is_var` argument to differentiate Variables and Stretches in `VariableNotInlined`. Fix: consolidate `RegistryAbsentObject` error. Add: errors for `size` and `depth`.
The following commits modify `CommutationAnalysis` to use rust-native errors throughout its pipeline. This is done mostly by implementing `DAGCircuitInnerError` based on Qiskit#16134 as a possible error in `CommutationError`.
The following commits modify `CommutationCancellation` to use rust-native errors throughout its pipeline. We implement the `CommutationCancelError` enumeration which derives from both `DAGCircuitError` and `CommutationError` as well as adding two new variants for operations with parameter expressions or undefined angles.
Collaborator
|
One or more of the following people are relevant to this code:
|
Coverage Report for CI Build 25965198003Coverage decreased (-0.02%) to 87.694%Details
Uncovered Changes
Coverage Regressions40 previously-covered lines in 7 files lost coverage.
Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following commits modify
CommutationCancellationto use rust-native errors throughout its pipeline.We implement the
CommutationCancelErrorenumeration which derives from bothDAGCircuitErrorandCommutationErroras well as adding two new variants for operations with parameter expressions or undefined angles.Pre-requisites
DAGCircuit#16134CommutationAnalysis#16193AI/LLM disclosure