Skip to content

Qutrit Device#2781

Merged
glassnotes merged 134 commits intoPennyLaneAI:masterfrom
mudit2812:qutrit_unitary
Jul 13, 2022
Merged

Qutrit Device#2781
glassnotes merged 134 commits intoPennyLaneAI:masterfrom
mudit2812:qutrit_unitary

Conversation

@mudit2812
Copy link
Copy Markdown
Contributor

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 adds a QutritDevice abstract base class to PennyLane to be used as a parent class for qutrit devices, which will be added in later pull requests.

Description of the Change:

  • Added new device QutritDevice as a parent device. Users will need to define all abstract methods that QutritDevice inherits from Device to use it. Currently, QutritDevice.execute() does NOT work when the quantum tape contains measurements, but qutrit operations, such as QutritUnitary can be executed.

Benefits:

Possible Drawbacks:

Related GitHub Issues:
#2190

@mudit2812 mudit2812 mentioned this pull request Jun 24, 2022
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 24, 2022

Codecov Report

Merging #2781 (4e95342) into master (0bed03f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2781   +/-   ##
=======================================
  Coverage   99.62%   99.62%           
=======================================
  Files         258      259    +1     
  Lines       21140    21237   +97     
=======================================
+ Hits        21060    21158   +98     
+ Misses         80       79    -1     
Impacted Files Coverage Δ
pennylane/__init__.py 100.00% <100.00%> (ø)
pennylane/_qutrit_device.py 100.00% <100.00%> (ø)
pennylane/_qubit_device.py 99.45% <0.00%> (+0.27%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0bed03f...4e95342. Read the comment docs.

Copy link
Copy Markdown
Contributor

@glassnotes glassnotes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mudit2812 looking good! ⭐ Just a few small comments, mostly about clearly denoting any major changes or missing parts and/or large sections that are similar / the same as for QubitDevice. Once addressed this should be ready for review 🎉

mudit2812 and others added 9 commits June 28, 2022 05:40
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
@antalszava antalszava requested review from Qottmann and antalszava July 7, 2022 18:44
Copy link
Copy Markdown
Contributor

@Qottmann Qottmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mudit2812 great work! I dont have much to say, it seems to be a clean 1-to-1 copy of the qubit device with modifications where necessary :)

Copy link
Copy Markdown
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mudit2812, this is looking very nice! 🎉 👏 The main ask from my side is changing the formula that appears in the docs for marginal_prob, the other comments are minor.


One thing to note is that we're exploring new return datastructures for quantum functions. Likely that change will affect QubitDevice and potentially QutritDevice. To give an example, a quantum function that returns multiple expectation values has a tensor output with shape (2,). We would like to change that to be a tuple of two scalar tensors, each with the shape ().

Still in the early stages with it, but thought of mentioning it as this could become relevant.

More info: we'd basically like quantum functions to always return the same type as indicated by the ‘return’ statement:

  • return meas1, meas2 returns a tuple of tensors;
  • return qml.expval() returns a scalar tensor;
  • return qml.probs() returns a N-dimensional tensor;
  • return [qml.expval(), qml.var()] returns a list of scalar tensors;
  • return (qml.probs([0]), qml.probs([1,2])) returns a tuple of N-dimensional
    tensors.

Copy link
Copy Markdown
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🎉 🙂

There seems to be a merge conflict in the changelog file, it can be resolved by merging in master and resolving the conflicts in the file locally.

Copy link
Copy Markdown
Contributor

@glassnotes glassnotes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing everyone's comments @mudit2812 ! Looks like this is good to go. Drop by my office this afternoon if you would like to do the honours and click the merge button 😀

@glassnotes glassnotes merged commit c8f78b6 into PennyLaneAI:master Jul 13, 2022
@rmoyard rmoyard added this to the v0.26.0 milestone Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants