Open erick-xanadu opened 8 months ago
Copying description from the duplicate issue:
Some MLIR transforms, like the parameter shift pass, predate the introduction of the
qnode
attribute on MLIR functions with quantum code. The use of the attribute has also been extended, for example to determine asynchronous execution scopes.In order to support the asynchronous execution of shifted circuits, the parameter-shift transform should propagate the
qnode
attribute from the original function it acts upon to the shifted function calls which each represent an independent quantum execution.Note I don't think the current implementation would be able to benefit much from asynchronous execution, except perhaps for two evaluations at a time, because the shifted circuits are not generated in a batched but a procedural fashion. See the following snippet, where the results a quantum call a used pretty much immediately:
Expected behavior: The attribute remains through the lowering of gradient and quantum dialect up until LLVM-IR (in which case we might wish to annotate it with some metadata).
Actual behavior: The gradient transforms generates helper functions which will strip the
qnode
attribute from qnodes. E.g.,Changes to:
This causes async to not be triggered since async looks for the
qnode
attribute.