pennylane
pennylane copied to clipboard
Controlled Qutrit Unitary
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
Codecov Report
Merging #2844 (9451aba) into master (3f64179) will increase coverage by
0.00%. The diff coverage is100.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.
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.
I also noticed that neither
ControlledQubitUnitarynorControlledQutritUnitarystore the control values in thepowmethod, thus the operation returned by that method doesn't include the correct control values. I've updatedControlledQutritUnitary.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)?