-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Tracing an MCM operation requires a postselect_mode argument in order to generate the correct primitive:
| def trace_quantum(self, ctx, device, trace, qrp, postselect_mode=None) -> QRegPromise: |
In particular, with
- "hw-like" execution, the
postselectkwarg is removed from the primitive in order to generate both valid and invalid shots - "fill-whots" execution, the
postselectkwarg is included in the mcm primitive which then acts like a project operation
While the mcm_config is provided when tracing top-level mcm operations:
catalyst/frontend/catalyst/jax_tracer.py
Lines 1673 to 1674 in 4fdebcc
| qrp_out = trace_quantum_operations( | |
| tape, device, qreg_in, ctx, trace, mcm_config, snapshot_results |
there are several instances where this not the case. Specifically, whenever a higher-order operator traces its body region:
https://github.com/search?q=repo%3APennyLaneAI%2Fcatalyst%20trace_quantum_operations(&type=code
As a result, the mcm primitive is incorrectly configured when an MCM operation is used from within a higher-order operator:
@qjit
@qml.qnode(
qml.device("lightning.qubit", wires=1),
shots=10,
mcm_method="one-shot",
postselect_mode="hw-like",
)
def circuit(b: bool):
qml.H(0)
@cond(b)
def nested():
measure(0, postselect=1)
nested()
print(circuit.mlir)Metadata
Metadata
Assignees
Labels
No labels