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

Improve generic select documentation #105

Merged
merged 8 commits into from
Nov 7, 2022
Merged

Conversation

mpharrigan
Copy link
Collaborator

like #103

  • Clean up docstrings and latex
  • Make the example less chemistry-y

Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

LGTM % nits

@@ -6,12 +7,23 @@


class GenericSelect(unary_iteration.UnaryIterationGate):
r"""Gate that implements SELECT for a Hamiltonian expressed as an LCU.
r"""A generic controlled SELECT operation for applying Pauli strings.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"for applying Pauli strings" seems like an abrupt / incomplete ending.

Maybe "Operation to selectively apply Pauli's to a target register conditioned on integer stored in selection register." ?

I'm open to suggestions here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How about:

A generic controlled SELECT gate for selecting and applying operators from an array of PauliStrings

I think we can assume some familiarity with the notion of "SELECT is array indexing" at least in the first introductory line, so I don't think we need "conditioned on an integer" or anything like that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

or "list" if not array

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

7b1054f do you think this is ok?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good, except that it should fit in a single line. Maybe:

class GenericSelect(unary_iteration.UnaryIterationGate):
    r"""Generic SELECT gate for selecting and applying operators from an array of `PauliString`s.
    
    """

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

cirq_qubitization/generic_select.py Show resolved Hide resolved
return GenericSelect(selection_bitsize, target_bitsize, select_unitaries=dense_ham)
target_bitsize = 4
us = ['XIXI', 'YIYI', 'ZZZZ', 'ZXYZ']
us = [cirq.DensePauliString(u) for u in us]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reusing same variable would lead to a mypy error?

Suggested change
us = [cirq.DensePauliString(u) for u in us]
us_dps = [cirq.DensePauliString(u) for u in us]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

xref: quantumlib/Cirq#3832

  • we can configure mypy to be fine with this
  • it will probably be the default anyways
  • I think it's way better to re-use existing name than having hungarian variable names and the previous version still hanging around that you could accidentally use instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, maybe open an issue to make sure we update the mypy config to add the flag so it doesn't complain. Right now, the config is basically copied from Cirq.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add to #30

@tanujkhattar tanujkhattar self-assigned this Nov 3, 2022
@tanujkhattar tanujkhattar enabled auto-merge (squash) November 7, 2022 22:41
@tanujkhattar tanujkhattar merged commit f147315 into main Nov 7, 2022
@mpharrigan mpharrigan deleted the 2022-11-generic-select branch November 15, 2023 20:52
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.

2 participants