QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
924 stars 122 forks source link

[TODO] Density Matrix Interfaces #395

Open GiggleLiu opened 2 years ago

GiggleLiu commented 2 years ago
jlbosse commented 1 year ago

I was looking into implementing intermediate measurements with measure!() for DensityMatrixes. One option is to reimplement most of the YaoAPI.measure!() logic here for density matrices. The other option is to implement focus! and relax! for density matrices. As far as I can tell, it should be possible to implement focus! and relax! s.t. density matrices are 4-dimensional arrays and instruct! still works correctly. Tough the downside of that would be that a lot of the stuff like von_neumann_entropy, mutual_information etc. will need to reshape the 4-dimensional dm.state to a 2-dimensional matrix to work.

GiggleLiu commented 1 year ago

Implementing focus! and relax! for density matrices may not be easy easy. These two functions are for selecting system qubits, which may cause loss of information for density matrices. I would suggest implementing measure! directly.

jlbosse commented 1 year ago

I am not sure I follow. How would focus! and relax! loose information?

My idea was to change DensityMatrix is a 2^nactive × 2^nremain × 2^nactive × 2^nremain array (assuming qubits, remain 2 with nlevel for qudits). Of course, this would imply quite a few changes for all functions that currently use matrix algebra, like tr, mutual_information etc..