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

Remove warning example qsvt #6693

Merged
merged 8 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ such as `shots`, `rng` and `prng_key`.
* The `qml.qsvt` function has been improved to be more user-friendly. Old functionality is moved to `qml.qsvt_legacy`
and it will be deprecated in release v0.40.
[(#6520)](https://github.com/PennyLaneAI/pennylane/pull/6520/)
[(#6693)](https://github.com/PennyLaneAI/pennylane/pull/6693)

<h4>Other Improvements</h4>

Expand Down
4 changes: 2 additions & 2 deletions pennylane/templates/subroutines/qsvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def qsvt(A, poly, encoding_wires=None, block_encoding=None, **kwargs):

@qml.qnode(dev)
def circuit():
qml.qsvt(hamiltonian, poly, encoding_wires=[0])
qml.qsvt(hamiltonian, poly, encoding_wires=[0], block_encoding="prepselprep")
return qml.state()


Expand Down Expand Up @@ -369,7 +369,7 @@ def circuit():
"block_encoding = {block_encoding} not supported for A of type {type(A)}. When A is a matrix block_encoding should take the value 'embedding' or 'fable'. Otherwise, please provide an input with a Pauli decomposition. For more details, see the 'qml.pauli_decompose' function."
)

A = qml.math.array(A)
A = qml.math.atleast_2d(A)
max_dimension = 1 if len(qml.math.array(A).shape) == 0 else max(A.shape)

if block_encoding == "fable":
Expand Down
7 changes: 7 additions & 0 deletions tests/templates/test_subroutines/test_qsvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,12 @@ def test_qsvt_warning(self):
"fable",
[0, 1, 2, 3, 4],
),
(
KetpuntoG marked this conversation as resolved.
Show resolved Hide resolved
0.3,
[0.2, 0, 0.3],
"embedding",
[0],
),
],
)
def test_matrix_input(self, A, poly, encoding_wires, block_encoding):
Expand All @@ -707,6 +713,7 @@ def circuit():
qml.qsvt(A, poly, encoding_wires, block_encoding)
return qml.state()

A = qml.math.atleast_2d(A)
# Calculation of the polynomial transformation on the input matrix
expected = sum(coef * matrix_power(A, i) for i, coef in enumerate(poly))

Expand Down
Loading