Skip to content

[BUG] hw-like postselection with Catalyst and capture enabled gives incorrect results #8379

@isaacdevlugt

Description

@isaacdevlugt

Expected behavior

I expect that the result gets padded with -2147483648 when the postselection criterion wasn't met

Actual behavior

The criterion is always met

Additional information

No response

Source code

dev = qml.device("lightning.qubit", wires=1)

qml.capture.enable()

@qml.qjit
@qml.set_shots(10)
@qml.qnode(dev, mcm_method="one-shot", postselect_mode="hw-like")
def circuit():
    qml.H(0)
    m0 = qml.measure(0, postselect=1)

    return qml.sample()

print(circuit())

[[1]
 [1]
 [1]
 [1]
 [1]
 [1]
 [1]
 [1]
 [1]
 [1]]

Tracebacks

N/A

System information

Name: pennylane
Version: 0.43.0.dev68
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: 
Author: 
Author-email: 
License-Expression: Apache-2.0
Location: /Users/isaac/.virtualenvs/catalyst-latest/lib/python3.11/site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing_extensions
Required-by: amazon-braket-pennylane-plugin, pennylane_catalyst, pennylane_lightning, pennylane_lightning_kokkos

Platform info:           macOS-15.7-arm64-arm-64bit
Python version:          3.11.13
Numpy version:           2.3.1
Scipy version:           1.16.0
JAX version:             0.6.2
Installed devices:
- nvidia.custatevec (pennylane_catalyst-0.13.0.dev65)
- nvidia.cutensornet (pennylane_catalyst-0.13.0.dev65)
- oqc.cloud (pennylane_catalyst-0.13.0.dev65)
- softwareq.qpp (pennylane_catalyst-0.13.0.dev65)
- default.clifford (pennylane-0.43.0.dev68)
- default.gaussian (pennylane-0.43.0.dev68)
- default.mixed (pennylane-0.43.0.dev68)
- default.qubit (pennylane-0.43.0.dev68)
- default.qutrit (pennylane-0.43.0.dev68)
- default.qutrit.mixed (pennylane-0.43.0.dev68)
- default.tensor (pennylane-0.43.0.dev68)
- null.qubit (pennylane-0.43.0.dev68)
- reference.qubit (pennylane-0.43.0.dev68)
- braket.aws.ahs (amazon-braket-pennylane-plugin-1.31.3)
- braket.aws.qubit (amazon-braket-pennylane-plugin-1.31.3)
- braket.local.ahs (amazon-braket-pennylane-plugin-1.31.3)
- braket.local.qubit (amazon-braket-pennylane-plugin-1.31.3)
- lightning.kokkos (pennylane_lightning_kokkos-0.43.0.dev36)
- lightning.qubit (pennylane_lightning-0.43.0.dev36)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions