Closed albi3ro closed 3 weeks ago
Thanks, I don't expect this to work (at least it's not listed as a supported measurement process in the docs), but wouldn't that require a DM simulator?
We can calculate the density matrix from a state vector. We just can't do the reverse.
This may be an issue because DensityMatrixMP
inherits from StateMP
due to the fact that historically we treated a "density matrix" as just a StateMP
with wires.
We can calculate the density matrix from a state vector. We just can't do the reverse.
This may be an issue because
DensityMatrixMP
inherits fromStateMP
due to the fact that historically we treated a "density matrix" as just aStateMP
with wires.
Ohh I see, so this is a qml.state
on a subset of wires 🤔 Yeah we probably convert StateMP
to jaxpr with an isinstance check. We can probably ensure that this doesn't pass the verifier, or add support for this MP but that depends on what the device supports ...
Historically, density matrix was just state on a subset of wires. But we discovered that caused a lot of confusion and problems in pennylane, so we decided to separate them to the best of our ability.
This would be particularily relevant for catalyst, as a density matrix has a completely different shape and size than the state.
@lillian542 quick question: would your work on MP validation resolve this issue (since we would simply raise a better error message)?
@josh146 this should raise an error now. My computer is currently rebuilding catalyst from the bottom up, so I can't check for sure, but I'll confirm that the example code raises a clear error on the latest catalyst branch as soon as my install is working again.
Assuming it does, can I close this issue?
Assuming it does, can I close this issue?
Yep!
Unfortunately not quite solved yet, the current verification registers DensityMatrixMP as identical to StateMP, and allows it when it shouldn't. Basically what Christina said above:
This may be an issue because DensityMatrixMP inherits from StateMP due to the fact that historically we treated a "density matrix" as just a StateMP with wires.
is still an issue for DensityMatrixMP specifically.
This now raises an NotImplementedError
as discussed above, following https://github.com/PennyLaneAI/catalyst/pull/1118
Issue description
Description of the issue - include code snippets and screenshots here if relevant. You may use the following template below
I would the expect the same behavior as in a non-qjit execution. Requesting
qml.density_matrix(wires)
should return a density matrix.Without the qjit, I get:
We just get the state.
Every time I execute it.
import pennylane as qml; qml.about()
)master pennylane, recent catalyst
Source code and tracebacks
Please include any additional code snippets and error tracebacks related to the issue here.
Additional information
Any additional information, configuration or data that might be necessary to reproduce the issue.