-
Notifications
You must be signed in to change notification settings - Fork 615
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
Make qml.QutritBasisStatePreparation
JIT compatible
#6308
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6308 +/- ##
=======================================
Coverage 99.39% 99.39%
=======================================
Files 448 448
Lines 42464 42471 +7
=======================================
+ Hits 42209 42216 +7
Misses 255 255 ☔ View full report in Codecov by Sentry. |
tests/templates/test_state_preparations/test_qutrit_basis_state_prep.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Guillermo Alonso-Linaje <65235481+KetpuntoG@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @willjmax! Some minor queries, before I dig in deeper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 😄
Just one comment. The following example does not work with jax.jit
. For some reason qml.sample
fails. I have tested default.qubit
with BasisState
to see if it should fail but it works correctly there.
n = 2
@jax.jit
@qml.qnode(qml.device("default.qutrit", wires = n, shots = 1))
def circuit(state):
qml.QutritBasisStatePreparation(state, wires = range(n))
return qml.sample(wires = range(n))
state = jax.numpy.array([1,1])
circuit(state)
Otherwise, the PR looks good to me :)
tests/templates/test_state_preparations/test_qutrit_basis_state_prep.py
Outdated
Show resolved
Hide resolved
tests/templates/test_state_preparations/test_qutrit_basis_state_prep.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Non blocker] could combine matrix
and pl_gates
tests into one decomposition
test, otherwise looks good with just one minor thing.
tests/templates/test_state_preparations/test_qutrit_basis_state_prep.py
Outdated
Show resolved
Hide resolved
I think qutrit basis state prep test in |
No, this was due to a bug that I caused. I pushed a fix. |
This PR makes `qml.QutritBasisStatePreparation` JIT compatible. Previously, the template used the `qml.TShift` operator in the decomposition. However, this approach requires non-jittable control flow on the input. To make the template jittable the decomposition is changed to return a `qml.ops.QutritUnitary` representing a `TShift` operator raised to some power. This change requires adding `matrix_power` and `eigh` to the multi dispatch. This PR addresses sc-70863. --------- Co-authored-by: Guillermo Alonso-Linaje <65235481+KetpuntoG@users.noreply.github.com>
This PR makes `qml.QutritBasisStatePreparation` JIT compatible. Previously, the template used the `qml.TShift` operator in the decomposition. However, this approach requires non-jittable control flow on the input. To make the template jittable the decomposition is changed to return a `qml.ops.QutritUnitary` representing a `TShift` operator raised to some power. This change requires adding `matrix_power` and `eigh` to the multi dispatch. This PR addresses sc-70863. --------- Co-authored-by: Guillermo Alonso-Linaje <65235481+KetpuntoG@users.noreply.github.com>
This PR makes
qml.QutritBasisStatePreparation
JIT compatible. Previously, the template used theqml.TShift
operator in the decomposition. However, this approach requires non-jittable control flow on the input. To make the template jittable the decomposition is changed to return aqml.ops.QutritUnitary
representing aTShift
operator raised to some power. This change requires addingmatrix_power
andeigh
to the multi dispatch. This PR addresses sc-70863.