PennyLaneAI / PennyLaneAI/catalyst
Dynamic one-shot execution with "hw-like" post-selection does not filter out shots with MCM in higher-order operator
Open
Nobody has claimed this yet.
bug
frontend
- Dominant language
- Python
- Stars
- 234
- Forks
- 84
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 66
Description
In addition to issue #2381:
@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()
return qml.sample(wires=0)
print(circuit(True))
produces unfiltered shots
[[0]
[1]
[0]
[0]
[0]
[0]
[0]
[1]
[1]
[0]]
whereas
@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)
measure(0, postselect=1)
return qml.sample(wires=0)
print(circuit(True))
produces correctly filtered shots
[[-2147483648]
[ 1]
[-2147483648]
[-2147483648]
[ 1]
[-2147483648]
[ 1]
[ 1]
[ 1]
[ 1]]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the qjit/QNode example using lightning.qubit, one-shot execution, hw-like post-selection, cond, and nested measure. Compare its nested conditional behavior with the direct measure example, then add or run a regression case showing that rejected shots use the expected filtered representation rather than unfiltered samples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100