Skip to content

[BUG] CompilePipeline adds duplicate expand transform when called on a QNode #9058

@andrijapau

Description

@andrijapau

Expected behavior

The pipeline of the QNode should not duplicate any expand transforms.

Actual behavior

When the pipeline is created, we automatically add the appropriate expand transform due to metric_tensor. However, when the pipeline is being called on the QNode, and we are processing it transform by transform, we end up adding another expand transform when processing metric_tensor.

Additional information

No response

Source code

pipeline = qml.transforms.merge_rotations + qml.metric_tensor

@pipeline
@qml.qnode(qml.device("default.qubit", wires=2))
def circuit():
    return qml.expval(qml.Z(0))

print(circuit.compile_pipeline)

Tracebacks

CompilePipeline(
  [0] merge_rotations(),
  [1] _expand_metric_tensor(), # DUPLICATE
  [2] _expand_metric_tensor(device_wires=Wires([0, 1])),
  [3] metric_tensor(device_wires=Wires([0, 1]))
)

System information

PL v0.44

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