PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.27k stars 585 forks source link

Add a method that calculates Von Neumann entropy #667

Closed Lucaman99 closed 2 years ago

Lucaman99 commented 4 years ago

It might be nice to have a method that can calculate the Von Neumann entropy of some arbitrary state.

I've come across a few papers where a variant of "free energy" is used as a loss function for preparing Gibbs (or Gibbs-like) states [1-3]. This free energy loss function includes both energy expectation and entropy.

I don't think this would be too difficult to implement, we would just have to access dev.state, and return -Tr(p ln p).

[1] https://arxiv.org/abs/1910.02071 [2] https://arxiv.org/abs/1811.11756 [3] https://arxiv.org/abs/1912.11381

co9olguy commented 4 years ago

Thanks @Lucaman99!

We are currently thinking about how to implement more cost functions naturally, so this definitely fits.

We're also thinking about whether it makes sense for state to be a property of the device, or a quantity that is returned (simulators only). In either case, the von Neumann entropy would be a nice candidate for a new cost function

Lucaman99 commented 4 years ago

Awesome, I'd love to help out with the implementation of this feature! Is this something you would want to add into Pennylane now, or would you rather wait until it is decided how state will be defined?

Lucaman99 commented 4 years ago

@co9olguy Also, since you're interested in implementing new cost functions, would you be interested in implementing a free energy cost function directly into PennyLane (as well as the entropy)? It would be a very simple extension since the free energy is given by L = 1/T - S(p).

It also might be worth implementing relative entropy between two states as well! 🙂

co9olguy commented 4 years ago

All of these sound great. Before we add them though, we'll need to think ahead and plan how/where they fit

Lucaman99 commented 4 years ago

@co9olguy Got it, I'm assuming this a change where more people need to be looped-in to the conversation?

co9olguy commented 4 years ago

Yep, it's on our radar currently

Lucaman99 commented 4 years ago

Sounds good!

josh146 commented 3 years ago

@Lucaman99 - now that we have qml.state(), this should pave the way for easily coding this up?

antalszava commented 2 years ago

This has been introduced as part of the quantum info module with https://github.com/PennyLaneAI/pennylane/pull/2617.