Skip to content

[BUG] qml.Barrier is not supported by qre.estimate #9103

@KetpuntoG

Description

@KetpuntoG

Expected behavior

I would expect qre.estimate to ignore the Barrier when estimating the cost of the circuit

Actual behavior

Current error:

ValueError: not enough values to unpack (expected 2, got 0)

Additional information

Jay`s suggestion:

Add the following script in estimator/resource_mapping.py

@_map_to_resource_op.register
def _(op: qops.Barrier):
    return re_ops.Identity()

Source code

wires = [0,1,2]
@qml.qnode(qml.device('default.qubit'))
def circuit():

  for wire in wires:
    qml.Hadamard(wires = wire)
  qml.Barrier()

  return [qml.probs(wires = wire) for wire in wires]

qre.estimate(circuit)()

Tracebacks

System information

Name: pennylane
Version: 0.44.0
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: 
License: 
Location: /usr/local/lib/python3.12/dist-packages
Platform info:           Linux-6.6.113+-x86_64-with-glibc2.35
Python version:          3.12.12
Numpy version:           2.0.2
Scipy version:           1.16.3
JAX version:             0.7.2
Installed devices:
- default.clifford (pennylane-0.44.0)
- default.gaussian (pennylane-0.44.0)
- default.mixed (pennylane-0.44.0)
- default.qubit (pennylane-0.44.0)
- default.qutrit (pennylane-0.44.0)
- default.qutrit.mixed (pennylane-0.44.0)
- default.tensor (pennylane-0.44.0)
- null.qubit (pennylane-0.44.0)
- reference.qubit (pennylane-0.44.0)
- lightning.qubit (pennylane_lightning-0.44.0)

Existing GitHub issues

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

Metadata

Metadata

Assignees

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