[PROTOTYPE] Custom PatternRewriter for quantum transforms
#2212
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.
Duplicate of PennyLaneAI/pennylane#8638
Methods available through the
PLPatternRewriterclass:PatternRewriterget_qnode: Given a starting point, finds the QNode module (or function) containing that operation, if it exists.get_qreg: Given an insertion point, finds the latest quantum register, if it exists.get_idx_from_qubit: Given a qubit, get the index into the quantum register that it corresponds to.get_active_qubits: Given an insertion point, return a bidirectional map between all live qubits and their corresponding indices.insert_active_qubits: Given an insertion point, insert all active qubits into the latest quantum register. The active qubit map and the latest quantum register can optionally be given as arguments, if known.insert_constant: Insert a scalar constant into the IR and return it.get_num_qubits: Given an insertion point, get an SSA value corresponding to the number of currently allocated qubits.get_num_shots: Get the number of shots as an SSA value. If requested, and the number of shots is static, can be returned as a Python interase_gate: Erase the provided quantum gate operationinsert_mid_measure: Insert a PennyLane mid-circuit measurement at the given insertion point. Postselection and reset are supported. The wire must be an SSA qubit.insert_gate: Insert a quantum gate at the given insertion point. If parameters are SSA values already in the IR, they can be provided. Otherwise, the static parameters of the gate will be inserted as constants into the IR. Wires must be SSA qubits.insert_observable: Insert a PennyLane observable at the given insertion point. If parameters are SSA values already in the IR, they can be provided. Otherwise, the static parameters of the observable will be inserted as constants into the IR. Wires must be SSA qubits.insert_measurement: Insert a PennyLane measurement process at the given insertion point. If parameters are SSA values already in the IR, they can be provided. Otherwise, the static parameters of the measurement process will be inserted as constants into the IR. Wires must be SSA qubits.swap_gates: (TODO) Swap two provided gate operations. There must be at least one overlapping wire between the gates, but not all wires need to overlap.Note:
Everything is untested 😅 . If anyone would like to test out the prototype and something doesn't work, please let me know.
[sc-103609]