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

Data structures for specifying input states #770

Merged
merged 31 commits into from
Feb 6, 2019

Conversation

mpharrigan
Copy link
Contributor

v1 of operator_estimation.py used PauliTerms to specify the input state, which is an abuse of data structures. This PR introduces two new datastructures, the later of which behaves similar to PauliTerm but for specifying "named" states. You can specify the +/- eigenstates of pauli X,Y,Z or SIC[0-3] for the sic basis.

These constructs are necessary for process tomography

Copy link
Contributor

@kylegulshen kylegulshen left a comment

Choose a reason for hiding this comment

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

No required changes. Some questions and potential requests that I could be easily talked out of.

pyquil/operator_estimation.py Show resolved Hide resolved
pyquil/operator_estimation.py Show resolved Hide resolved
pyquil/operator_estimation.py Show resolved Hide resolved
pyquil/operator_estimation.py Outdated Show resolved Hide resolved
pyquil/operator_estimation.py Outdated Show resolved Hide resolved
@mpharrigan
Copy link
Contributor Author

Merged in #754 and consolidated some of the functionality. @msohaibalam can you take a look at the new term-grouping changes


Given some PauliTerm, the 'natural' tensor product basis (tpb) to
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function is now redundant, but this was a good docstring so I put it in group_experiments so people might actually find it

@@ -287,6 +287,33 @@ def bitphase_flip_operators(p):
'bitphase_flip': bitphase_flip_operators,
}

SIC0 = np.array([1, 0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a reference so people can check?

I personally use this http://info.phys.unm.edu/~caves/reports/infopovm.pdf see Eqns. 22 and 23

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool; I'll add that in



def _generate_random_states(n_qubits, n_terms):
oneq_states = [SIC0, SIC1, SIC2, SIC3, plusX, minusX, plusY, minusY, plusZ, minusZ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Im flying blind here, so apologies if this doesn't make sense.

It seems like one might want to generate a random state from the Pauli eigenstates or from the SIC states but not from both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is just for the tests, so it doesn't make perfect sense; but it is something you can do (in code)

def _validate_all_diagonal_in_tpb(ops: Iterable[PauliTerm]) -> Dict[int, str]:
"""Each non-identity qubit should result in the same op_str among all operations. Return
said mapping.
def _max_weight_operator(ops: Iterable[PauliTerm]) -> Union[None, PauliTerm]:
Copy link
Contributor

Choose a reason for hiding this comment

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

This function as well as _max_weight_state(..) are defined slightly later than their first use (in construct_tpb_graph(..)); I'd place them immediately before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've prioritized readability of the diff

assert expt2.out_operator == oop


def test_experiment_no_in():
def test_setting_no_in_back_compat():
Copy link
Contributor

Choose a reason for hiding this comment

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

This test as well as test_setting_no_in(..) both raise the warning message UserWarning: ExperimentSetting.in_operator is deprecated in favor of in_state. In general, we should try to avoid writing tests that will raise warning messages. If we add the decorator @pytest.mark.filterwarnings("ignore:ExperimentSetting") to both these tests, we'd have a warning free test output (see https://docs.pytest.org/en/latest/warnings.html)

@msohaibalam
Copy link
Contributor

@mpharrigan I've tested out the (slightly modified) code for the grouping methods explicitly on (a) random experiments, (b) exhaustive experiments, and (c) chemistry experiments (LiH, and BeH2), and the results stay the same as before. So the changes look good to me!

@mpharrigan mpharrigan merged commit fbd3261 into rigetti:master Feb 6, 2019
@mpharrigan mpharrigan deleted the in-state branch February 6, 2019 19:29
@karalekas karalekas added this to the v2.4.0 milestone Feb 14, 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.

6 participants