Graph decomposition for device and stopping_condition#2472
Graph decomposition for device and stopping_condition#2472lazypanda10117 wants to merge 51 commits intomainfrom
Conversation
|
Hello. You may have forgotten to update the changelog!
|
There was a problem hiding this comment.
Thanks @lazypanda10117! The main remaining TODO is to report/fix the edge cases:
-
CountsNot Implemented with Capture <- this issue is a program capture limitation and doesn't have anything to do with decomposition -
Almost all xDSL / PPR parse errors are related to producing a different IR as of applying decomposition! We can fix most of them by updating the MLIR output to be compatible with the checks.
-
HybridOp decomp assertion <-- we should be able to fix all these issues by ensureing that HybridOps are in the stopping _condition OR excluded from decomposition.
-
Ops missing from device gateset <- Lightning/null devices support more gates than Catalyst can represent! You need to take the intersection of these ops and decompose the remaining ones in PLxPR.
KeyError: 'StatePrep'KeyError: 'BasisState'KeyError: 'QubitUnitary'KeyError: 'QFT'
-
_OperatorNode Can't Be Captured Without Wire Count<- the graph decomposition produces_OperatorNodeobjects that require a wire count to be captured/lowered into MLIR, but the wire count isn't available at graph construction time. cc: @astralcai -
In specs/pass counting/circuit drawing tests: the current pipeline adds extra
decompose-loweringpass to the compiled module. We need to update the logic (and maybe tests) to avoid this. -
there are some other errors such as
DID NOT RAISE/WARNorCannot resolve wire for SliceOporTracerBoolConversionError; let's get back to them after fixing the above as some of them are tied with those edge cases.
| consts = args[shots_len : n_consts + shots_len] | ||
| non_const_args = args[shots_len + n_consts :] | ||
|
|
||
| closed_jaxpr = ( |
There was a problem hiding this comment.
The new handle_qnode supports the following cases:
- User defined
stopping_conditioninqml.decompose: Use PLxPR decompose with user stopping condition! - No user decomposition (default): Load device capabilities --> device-specific gate set --> Use graph and
decompose-lowering - User specified
gate_set: Graph-based decomposition on user gate set (the current support)
cc: @astralcai @isaacdevlugt if you guys have any comments or suggestions
There was a problem hiding this comment.
If a user applies a @qml.decompose on top of a qnode, it would be applied in addition to the decomposition to the device gate set right? That is the current behaviour at least. Whether the user has a @qml.decompose or not does not change the fact that a decomposition to the device gate set is always going to happen. Is that not the case here?
There was a problem hiding this comment.
If a user applies a @qml.decompose on top of a qnode, it would be applied in addition to the decomposition to the device gate set right?
My understanding is that when a user specifies a transform, we will only use that user-specified gateset. We only do device-level decomposition when no such user-defined transform is provided.
|
|
||
| def calculate_diff_method(device, closed_jaxpr): | ||
| """Calculate the diff method for the device.""" | ||
| return _calculate_diff_method(device, closed_jaxpr) |
There was a problem hiding this comment.
is this correct? 🤔
We don't have any logic to deal with "diff" ops in the decomposition system
There was a problem hiding this comment.
This is used in catalyst acceptance. I am just porting over the function.
There was a problem hiding this comment.
Could we merge the util methods with the one in ./catalyst/device or add these methods to from_plxpr/decompose.py ?
There was a problem hiding this comment.
Yes we can, I just think this is cleaner since this is the subset of functions (with slight modifications) that are needed from device capabilities.
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
I think the issue with (4) is actually due to |
As discussed offline with @lazypanda10117, the issue with this type of errors comes from operators like |
|
@maliasadi Point 3,4,5,6 are mostly addressed. |
**Context:** Fix failing test after PennyLaneAI/pennylane#9001 **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:**
**Context:** We are about to start the audit of tests. For convenience, a tiny nice fixture to automatically apply the two values of `capture` kwarg locally is good. **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** [sc-111330] --------- Co-authored-by: Andrija Paurevic <46359773+andrijapau@users.noreply.github.com>
**Context:** The PPR/PPM lowering passes (`lower-qec-init-ops`, `unroll-conditional-ppr-ppm`) are now run as part of the main quantum compilation pipeline. When using `to-ppr` and `ppr-to-ppm` transforms, these passes are applied automatically during compilation; we no longer need to stack them explicitly. [[sc-109665]] --------- Co-authored-by: Paul <79805239+paul0403@users.noreply.github.com> Co-authored-by: Hong-Sheng Zheng <mathan0203@gmail.com>
Context: Supporting `stopping_condition` when user supplies it in `qml.decompose` with capture enabled. This will use the plxpr transform to handle the decomposition with stopping condition. This PR is a subset of #2472. See that PR for a more detailed discussion. [[sc-110276]] --------- Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
Context:
Supporting device-specific gateset decomposition in the program capture flow. This is enabled by extending the
handle_qnodefunction. As stated in Ali's comment, the newhandle_qnodesupports the following cases:[sc-110277]
[sc-110276]
[sc-107559]