1
$\begingroup$

I want to find the operator that describes this qutrit quantum circuit. Where a TSub, some TRZ rotations and a TAdd are applied to 2 quitrits. I am using Pennylane 0.34.0. Qutrit circuit

This is the code:

import pennylane as qml

TSub = qml.adjoint(qml.TAdd)

res = qml.TAdd(wires=[0, 1]) @ qml.TRZ(0.5, wires=1, subspace=(0, 1)) @ \
    qml.TRZ(0.5, wires=1, subspace=(0, 2)) @ TSub(wires=[0, 1])

print(res.matrix())

And I get this error:

 File "/home/dan/anaconda3/envs/q_env/lib/python3.12/site-packages/autoray/autoray.py", line 80, in do
    return get_lib_fn(backend, fn)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 6 is different from 9)
$\endgroup$

1 Answer 1

2
$\begingroup$

this is a bug in Pennylane for qutrits, here is a link to the issue. If you would like a short-term solution you could do.

import pennylane as qml
import numpy as np

TSub = qml.adjoint(qml.TAdd)
TRZ_01 = lambda phi: qml.QutritUnitary(np.kron(np.eye(3),qml.TRZ.compute_matrix(phi)), wires=(0,1))
TRZ_02 = lambda phi: qml.QutritUnitary(np.kron(np.eye(3),qml.TRZ.compute_matrix(phi, subspace=(0,2))), wires=(0,1))

res = qml.TAdd(wires=[0, 1]) @ TRZ_01(0.5) @ \
    TRZ_02(0.5) @ TSub(wires=[0, 1])

print(res.matrix())

I recommend checking np.diag(res.matrix()) as it will be diagonal.

Also, for an intuitive understanding of this circuit, it is implementing a rotation of phase by phi for states where qutrits are the same and -phi/2 otherwise. More information on the algorithm can be found in my paper, and the source code is here.

I hope this is helpful!

Please feel free to reach out if you have any more questions.

$\endgroup$
1
  • $\begingroup$ It works. I was indeed reading your paper. In the code you are not specifying subspace=(0,1) for TRZ_01 but I guess it's the default behavior. $\endgroup$ Feb 27 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.