Repository navigation
Conversation
This reverts commit d1fbfb3.
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.
Context:
This PR migrates the control lowering pass to reference semantics.
Control Lowering for value semantics was implemented in #3089, #3090, #3096.
Description of the Change:
Added method
addControlsin the QuantumGate interface. This function is implemented inUnitaryGate_Op, where the generated functionsgetCtrlQubitsMutableandgetCtrlValuesMutableappend the crtlQubits and ctrlValues. The MLIR typeMutableOperandRangehas a functionappendwhich appends values to a range and also updates the length of theoperandSegment.This allows an operation cast as
dyn_cast<QuantumGate>(op)to calladdControlswhich adds ctrlQubits and ctrlValues to itself.For the
CtrlOpcase, it merges the old (outer) CtrlQubits and ctrlValues to the inner one. Afterwards the greedy pattern matcher gets run for the innerCtrlOpblock and runsCtrlLoweringRewritePattern::matchAndRewriteagain.I then move the entire block outside the ctrlOp op with
inlineBlockBeforeand erase the op.Benefits:
Simplifies the pass makes it more maintainable, scalable, faster, easier to debug, readable, and less prone to bugs.
Possible Drawbacks:
Additional calls to other passes, can increase compilation time. Needs to call
convert-to-reference-semanticsbefore the pass runs, andconvert-to-value-semanticsin the adjointLowering pass which follows this pass.Related GitHub Issues:
#3192
[sc-129851]
Blockers:
This test CtrlTest.mlir fails because of the
scf.execute_regionnot being implemented inconvert-to-reference-semantics. I have the fix for it in #3238.