-
Notifications
You must be signed in to change notification settings - Fork 47
🚧 Python Compiler #1677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚧 Python Compiler #1677
Conversation
fbb545b
to
e5d1469
Compare
|
||
class DeepCancelInversesSingleQubitPattern(pattern_rewriter.RewritePattern): | ||
@pattern_rewriter.op_type_rewrite_pattern | ||
def match_and_rewrite(self, funcOp: func.FuncOp, rewriter: pattern_rewriter.PatternRewriter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the implementation a bit better by replacing recursion with a while loop. cancel_ops
is not needed anymore:
@pattern_rewriter.op_type_rewrite_pattern
def match_and_rewrite(self, funcOp: func.FuncOp, rewriter: pattern_rewriter.PatternRewriter):
"""Deep Cancel for Self Inverses"""
for op in funcOp.body.walk():
while isinstance(op, CustomOp) and op.gate_name.data in self_inverses:
next_user = None
for use in op.results[0].uses:
user = use.operation
if isinstance(user, CustomOp) and user.gate_name.data == op.gate_name.data:
next_user = user
break
if next_user is None:
break
rewriter._replace_all_uses_with(next_user.results[0], op.in_qubits[0])
rewriter.erase_op(next_user)
rewriter.erase_op(op)
op = op.in_qubits[0].owner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello. You may have forgotten to update the changelog!
|
a.py
Outdated
return qml.state() | ||
|
||
|
||
qml.capture.disable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that if capture is disabled before executing, the tracing will happen without the plxpr pipeline. I'll share more details on Slack.
Dropped in favour of #1715 and PennyLaneAI/pennylane#7367 |
Context:
Description of the Change: Initial design:
will denote that we are running pass-name to the
func
qnode and the pass comes from xDSL.apply-transform-sequence
pass that we currently use in MLIR. This pass is the one that uses the transform dialect and applies already named passes.apply-transform-sequence
pass in xDSL, we will change the run command sent to Catalyst to omit it and continue the lowering process as usual.Benefits:
Possible Drawbacks:
Related GitHub Issues: