Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS269Q Tomography Debugger Project #137

Closed
wants to merge 9 commits into from
Closed

Conversation

mikh3x4
Copy link

@mikh3x4 mikh3x4 commented Jun 8, 2019

State tomography involves measuring a quantum state repeatedly in the bases given by itertools.product(['X', 'Y', 'Z], repeat=n_qubits). From these measurements, we can reconstruct a density matrix $\rho$. In this project we set out to create a debugging tool to perform state tomography. This project had two parts. The first was constructing a debuggin interface. We decided that our debugger would take the form of a function that could be called on a program and a list of qubits, and would then run tomography algorithms and output a density matrix. The second was choosing an appropriate advanced algorithm to perform state tomography. Since both linear inversion and MLE had already been implemented in the forest benchmarking tomography file (and since Bayesian estimates are apparently "formidable" for quantum states!), we decided to go with matrix completion/compressed sensing methods.

@mikh3x4 mikh3x4 requested a review from a team as a code owner June 8, 2019 06:50
@mikh3x4
Copy link
Author

mikh3x4 commented Jun 8, 2019

Project was done for Stanford's CS269Q class. Full detail of changes are available in this PDF:

CS_269Q_Final_Project_Paper.pdf

@joshcombes
Copy link
Contributor

Hi @mikh3x4, at first glance this is awesome!

I'll start looking over the code more carefully tomorrow. The other thing to mention is Kyle is about to merge in changes which mark a major refactor of the repo. So we might want to wait till that is done.


# if no pauli_num is specified use the maximum
if pauli_num==None:
pauli_num=len(Qubits)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pauli_num=len(Qubits)
pauli_num=len(qubits)

Copy link
Contributor

@joshcombes joshcombes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good.

The comments below are pretty minor.

d = 2 ** qubit_num
pauli_list = []
expectation_list = []
y = np.zeros((m,1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m -> pauli_num


mu = 4 * pauli_num / np.sqrt(1000 * pauli_num)

for i in range(m):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

range(pauli_num)

expectation_list.append(e)

x = cp.Variable((d,d),complex = True)
A = cp.vstack([cp.trace(cp.matmul(pauli_list[i], x)) * np.sqrt(d / m) for i in range(m)])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.sqrt(d / m) -> np.sqrt(d / pauli_num)

range(m) -> range(pauli_num)

d = 2 ** qubit_num
pauli_list = []
expectation_list = []
y = np.zeros((m,1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be a typo as the variable m seems to be undefined.

Maybe should be pauli_num.

I'll point out below the places where m should be replaced with pauli_num

x = cp.Variable((d,d),complex = True)
A = cp.vstack([cp.trace(cp.matmul(pauli_list[i], x)) * np.sqrt(d / m) for i in range(m)])

#Minimize trace norm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might also be nice to point out (in the comment) that the equation below is Eqn. (4) and Eqn. (35) from [FLAMMIA]

#A[i] = e * scale_factor
pauli_list.append(p_tensor)
expectation_list.append(e)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a comment about the objective and constraint in terms of Eqn (3) and (34) in [FLAMMIA]

def compressed_sensing_state_estimate(results: List[ExperimentResult],
qubits: List[int]) -> np.ndarray:
"""
Estimate a quantum state using compressed sensing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estimate a quantum state using compressed sensing, i.e. by constrained trace minimization (a.k.a. the matrix Dantzig selector).

expectation_list = []
y = np.zeros((m,1))

mu = 4 * pauli_num / np.sqrt(1000 * pauli_num)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could be moved down to line 251, i.e. just before you use it.

Also maybe put a comment in the code telling the reader to look at section V. A of [FLAMMIA] for more information

@joshcombes
Copy link
Contributor

I tried to push the updated code to your branch and I could not. So I did not want to loose all the work done on that branch and made the changes and PR here #166. The Git history is still there so everyone can see that you did the work :)

In light of that I will close this PR.

@joshcombes joshcombes closed this Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants