Hi, I need to obtain the density matrix from circuit run on a noisy device, like qiskit.aer
, to calculate the fidelity. Is it possible to do this in Pennylane?
Hi @Yang,
Absolutely! You can learn more about measuring a density matrix from a circuit on the PennyLane docs.
Remember that in PennyLane you will need to use the “default.mixed” device for noisy circuits. You can learn more about noisy circuits in this demo.
Please let me know if you have any further questions.
Hi @CatalinaAlbornoz ,
Thank you for your advice. Actually, I am planning to use the qiskit.aer
device to simulate the noise of physical quantum device. However, it raised an error which told me qml.density_matrix
is not supported on this device.
Hi @Yang,
You’re right. qiskit.aer
doesn’t support returning density matrices. You could try using default.mixed
if you want to use density matrices and add different types of noise. You can learn how to do this in this demo.
Otherwise you can use qiskit.aer
but returning an expectation value.
Can you still do what you need with any of these approaches?
Hi @CatalinaAlbornoz ,
Thank you for your message. I have to use qiskit.aer
to load the noise model from IBMQ devices. To obtain the density matrix, I want to do quantum state tomography. Are there some APIs in Pennylane used to do this?
Hi @Yang,
qiskit.aer
acts a lot like actual hardware so it doesn’t return the state. This means that unfortunately we cannot return the density matrix. We will make a note of this to see how we can support tomography in the future, but it’s not currently possible with qiskit.aer
.
Something you could maybe try is using default.mixed
and Kraus operators as described in this blog post, to create your own custom noise. I’m not sure what information about noise IBM gives you but maybe you can try to extract this information from their devices and then use it to create a custom noise model in PennyLane.
I hope this helps!