Skip to content

Add 2-CNOT decomposition for qml.QubitUnitary #8666

@lillian542

Description

@lillian542

Important Note

⚠️ This issue is part of an internal assignment and not meant for external contributors.

Context

We would like to add a 2-CNOT decomposition for the qml.QubitUnitary operation. This will be more efficient for some cases that currently decompose to 3 CNOT gates unnecessarily.

Implementation Details

This task is to add a new decomposition, _decompose_2_cnots, for the two-qubit decomposition for QubitUnitary. Once added, the logic in two_qubit_decomposition should be updated to dispatch to this decomposition when relevant.

The implementation should:

  • Define a decomposition using 2 CNOT gates, based on this paper
  • Update the logic in _compute_num_cnots to determine if the 2 CNOT decomposition is the best option.
  • Update the logic in the dispatch in the function two_qubit_decomposition to link to the 2 CNOT case instead of the 3 CNOT case when applicable.

All functions added or modified for this task belong in the pennylane/ops/op_math/decompositions/unitary_decompositions file.

Relevant functions include:

  • qml.QubitUnitary
  • qml.ops.op_math.decompositions.unitary_decompositions._compute_num_cnots
  • qml.ops.op_math.decompositions.unitary_decompositions._decompose_3_cnots
  • qml.ops.two_qubit_decomposition

Additional Requirements

A completed PR would:

  • Include a docstring for the new _decompose_2_cnots function with details about what the function does and a link to the referenced paper
  • Update the docstring of _compute_num_cnots to include a correct reference for the logic used for the 2 CNOT case
  • Update the docstring of two_qubit_decomposition to reflect the change.
  • Include a changelog entry at doc/releases/changelog-dev.md. Make sure to include your name in the list of contributors at the bottom!
  • Add tests to the file tests/ops/op_math/test_decompositions.py. The tests should include an adequate suite of both unit and integration tests.
  • Pass all existing tests including black and pylint checks

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions