Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable enable_new_opmath for lightning.tensor #919

Merged
merged 8 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@

### Bug fixes

* Bug fix for `_pauli_word` of `QuantumScriptSerializer`. `_pauli_word` can process `PauliWord` object: `I`.
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
[(#919)](https://github.com/PennyLaneAI/pennylane-lightning/pull/919)

* Bug fix for analytic `probs` in the `lightning.tensor` C++ layer.
[(#906)](https://github.com/PennyLaneAI/pennylane-lightning/pull/906)

Expand Down
2 changes: 1 addition & 1 deletion doc/lightning_tensor/device.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and greater. This device supports both exact and finite shots measurements. Curr

The ``lightning.tensor`` device is designed for expectation value calculations. Measurements of ``qml.probs()`` or ``qml.state()`` return dense vectors of dimension :math:`2^{n_\text{qubits}}`, so they should only be used for small systems.

.. note:: ``qml.Hermitian`` is currently only supported for single wires. You can use ``qml.pauli_decompose`` on smaller matrices to obtain a compatible Pauli decomposition in the meantime. As a result, it is advisable to disable ``new_opmath`` for the ``lightning.tensor`` device to prevent the implicit conversion of Pauli words to multi-wire Hermitian observables. This limitation will be addressed once multi-wires Hermitian observables can be supported with ``cutensornet``.
.. note:: ``qml.Hermitian`` is currently only supported for single wires. You can use ``qml.pauli_decompose`` on smaller matrices to obtain a compatible Pauli decomposition in the meantime.

Users also have the flexibility to customize these parameters according to their specific needs with:

Expand Down
3 changes: 3 additions & 0 deletions pennylane_lightning/core/_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@
def map_wire(wire: int):
return wires_map[wire] if wires_map else wire

if len(observable) == 0:
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
return self.named_obs(PAULI_NAME_MAP["I"], [0])

Check warning on line 289 in pennylane_lightning/core/_serialize.py

View check run for this annotation

Codecov / codecov/patch

pennylane_lightning/core/_serialize.py#L288-L289

Added lines #L288 - L289 were not covered by tests
maliasadi marked this conversation as resolved.
Show resolved Hide resolved

if len(observable) == 1:
wire, pauli = list(observable.items())[0]
return self.named_obs(PAULI_NAME_MAP[pauli], [map_wire(wire)])
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.39.0-dev30"
__version__ = "0.39.0-dev31"
3 changes: 0 additions & 3 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ class TestQChem:
def test_VQE_gradients(self, diff_method, tol):
"""Test if the VQE procedure returns the expected gradients."""

if qml.operation.active_new_opmath() and device_name == "lightning.tensor":
pytest.skip("The new operation math is not yet fully supported for lightning.tensor")

symbols = ["H", "H"]

geometry = np.array(
Expand Down
Loading