jsqubits icon indicating copy to clipboard operation
jsqubits copied to clipboard

Measure and destroy a qubit

Open tobiasBora opened this issue 5 years ago • 4 comments

Hello,

First, thanks for this nice library. I'd like to perform sometimes some measurements that require auxiliary qubits (a.k.a. ancillae), but after the measurement the qubits are not useful anymore. I can add qubits using the tensor mechanism, but is there a way to remove qubits that have been measured? It could be useful to avoid to have an increasing number of qubits in use, to simplify the states, and also to simplify the code (one solution to avoid the explosion of the number of qubits in simple cases is to keep in mind which qubit is auxiliary and which one is not, but it complicates the code, and if at one point one needs lots of auxiliary for a particular measurement, then the state will stay big for the rest of the computation).

Thanks!

tobiasBora avatar Oct 09 '20 08:10 tobiasBora

Currently there isn’t a way to remove qubits. However, I can see this could be useful. Will consider trying to support it.

davidbkemp avatar Oct 09 '20 21:10 davidbkemp

Nice, thanks a lot. I guess this could be seen as a tracing out operation, so implementing a partial trace operation would solve the problem I guess. Thanks!

tobiasBora avatar Oct 12 '20 09:10 tobiasBora

Sorry, it will take at least another week or so before I get back to this. Life has got rather busy.

I agree it could be seen as a "tracing out operation". I don't think it could be a general partial trace or we would have to support mixed states. It could work if you are only allowed to trace out the bits that have the same values in all states I guess, or we tie it to the measurement operation and only allow you to trace out the measured bits. It has been a few years since I looked at this though.

davidbkemp avatar Oct 18 '20 07:10 davidbkemp

Oh, no worries, there is nothing urgent, it was just a suggestion, take your time. It's already great to see that you are thinking to implement it!

Oh yeah you are right, I forgot that the library was dealing with pure states only. Then I guess it makes sense to bind it to a measurement operation (otherwise the function that checks if a qubit is composed only of zeros or ones could fail and it would not be "physical" as it allows you to test if a qubit is in superposition or not). And I guess it may also be more efficient to measure and remove at the same time rather than by doing two operations. Maybe adding an optional argument to the measurement operator would be a nice user interface?

Thanks a lot!

tobiasBora avatar Oct 18 '20 08:10 tobiasBora