PennyLaneAI / PennyLaneAI/catalyst

Dynamic one-shot execution with "hw-like" post-selection does not filter out shots with MCM in higher-order operator

Open
#2,382 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.