# How to do state tomography when using sampling in Qiskit?

Could anyone please explain how do I do state tomography when using sampling (on real device or QASM) in Qiskit? I know there's a special method for this, but I could not find a working example.

More precisely, I would be interested in two cases: when the full state tomography is performed (all the $$2^n$$ amplitudes are measured) and when it's known apriori that the wave function has support in a certain subspace (say, only $$|10\rangle$$ and $$|01\rangle$$ for a two-qubit system).

BTW, is $$3^n$$ a lower bound on the number of operators which have to be measured in order to perform the state tomography? ($$X$$, $$Y$$, $$Z$$ for each qubit.)

• I don't have time to write a proper answer right now on the entire question, but at least there used to be a wonderful qiskit tutorial notebook on QST (although I can't find it anymore). I'll try to answer later if there is no answer yet. – JSdJ Aug 3 at 11:17
• The $3^{n}$ bound is not a strict bound; in principle you could do with $4^{n}$ state populations (the $3^{n}$ operators of course give $6^{n}$ states) when you use a SIC-POVM - but in practice, it's just easier to use the $3^{n}$ Pauli operators. – JSdJ Aug 3 at 11:19

I would suggest you use the code from the tutorial about quantum state tomography, adapting it to a real device of your choice. You can find the updated tutorial here

Caveat: as state tomography requires 3^n circuits, you will need probably to find a method of batch processing of these circuits if they exceed the job circuit limit of your real device. See the code here

“This performs measurement in the Pauli-basis resulting in :math:3^n circuits for an n-qubit state tomography experiment.”

For an example of results of « full state tomography » on real devices (Melbourne and ibmqx4) for up to 5 qubits, I suggest you have a look at the end of my own qiskit tutorial here

For the exploration of a certain subspace on a real device, I have some doubt about the approach as noise will inevitability produce a result somewhere in the entire Hilbert space and not confined to the chosen subspace.

However, you may be interested by this recent paper

and by its presentation in Phys.org

I quote from this presentation written by Ingrid Fadelli

“By combining statistical learning and unitary t-design theory, the researchers were able to devise a rigorous and efficient procedure that allows classical machines to produce approximate classical descriptions of quantum many-body systems. These descriptions can be used to predict several properties of the quantum systems that are being studied by performing a minimal number of quantum measurements.”

So, you are surely right in proposing that full tomography can be replaced by alternate methods using a lower number of measurements.

• just fyi, you can add links typing e.g. [click here](http://www.google.com)`, which gives you click here – glS Aug 10 at 11:12
• As a small sidenote, there is another reason why only considering a subspace during reconstruction is tricky, as not (ac)counting for projections on other subspaces as valid measurement outcomes results in essentially 'lost' measurements (i.e. you performed a measurement but did not record the outcome). Reconstructing for $\rho$ will then not only disregard the information regarding these subspaces, but will also not be trace-class, meaning that the trace of the state will not be $1$. – JSdJ Aug 10 at 13:05