pennylane icon indicating copy to clipboard operation
pennylane copied to clipboard

Controlled Qutrit Unitary

Open mudit2812 opened this issue 3 years ago • 1 comments

Context: There are very few simulators available today that offer qudit simulation. One notable example is Google's Cirq, which includes support for qudit operations. However, the simulator is far from complete, and a key drawback is the lack of operations available, which creates a need for users to define operations themselves. Popular libraries such as Qiskit and QuTiP also include some qudit manipulation capabilities, but with few use cases. Beyond these libraries, qudit simulation solutions are quite limited. Moreover, qudit simulation is a feature that is already in demand, as seen in this issue on the PennyLane repository.

This PR builds upon the previous PR's that added qutrit functionality by implementing the controlled QutritUnitary operation

Description of the Change:

  • Added ControlledQutritUnitary() operation to PennyLane to use with qutrit devices.

Benefits:

Possible Drawbacks:

Related GitHub Issues: https://github.com/PennyLaneAI/pennylane/issues/2190

mudit2812 avatar Jul 20 '22 20:07 mudit2812

Codecov Report

Merging #2844 (9451aba) into master (3f64179) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2844   +/-   ##
=======================================
  Coverage   99.69%   99.69%           
=======================================
  Files         276      276           
  Lines       24264    24329   +65     
=======================================
+ Hits        24191    24256   +65     
  Misses         73       73           
Impacted Files Coverage Δ
pennylane/devices/default_qutrit.py 100.00% <ø> (ø)
pennylane/ops/qutrit/__init__.py 100.00% <ø> (ø)
pennylane/ops/qutrit/matrix_ops.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 21 '22 20:07 codecov[bot]

Hi @albi3ro ! Thanks for the review. I do agree about the note you made regarding the significant overlap and redundancy between QubitUnitary, QutritUnitary, and ControlledQutritUnitary. When this PR was originally created, ControlledQutritUnitary was the best option due to the incomplete qml.op_math module. However, now that that isn't the case, qml.ctrl (and other functions) can be updated to support qutrit operations, which is my next goal.

With that being said, I've addressed the changes you suggested in your review. I've added ControlledQutritUnitary.adjoint(). I also noticed that neither ControlledQubitUnitary nor ControlledQutritUnitary store the control values in the pow method, thus the operation returned by that method doesn't include the correct control values. I've updated ControlledQutritUnitary.pow() to work correctly.

mudit2812 avatar Oct 17 '22 21:10 mudit2812

I also noticed that neither ControlledQubitUnitary nor ControlledQutritUnitary store the control values in the pow method, thus the operation returned by that method doesn't include the correct control values. I've updated ControlledQutritUnitary.pow() to work correctly.

@mudit2812 that sounds like a bug :fearful: could you please log an issue for that (if there isn't one already)?

glassnotes avatar Oct 18 '22 16:10 glassnotes