Skip to content

Add Quantum Fourier Transform #2135

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

Merged
merged 12 commits into from
Sep 24, 2019
Merged

Add Quantum Fourier Transform #2135

merged 12 commits into from
Sep 24, 2019

Conversation

Strilanc
Copy link
Contributor

  • Add PhaseGradientGate, QuantumFourierTransformGate, and QFT method
  • QFT does not define apply_unitary or unitary because the most efficient way to get them is actually via the decomposition
  • Add exponent_qubit_index to CircuitDiagramInfo
  • Update ControlledOperation circuit_diagram_info to forward exponent_qubit_index
  • Add circuit_diagram_info to _InverseCompositeGate
  • Update phase_estimator example to use built-in QFT
  • Update hhl example to use built-in QFT
  • Add big_endian_bits option to ApplyUnitaryArgs.subspace_index

This one had snuck into a couple examples as redundant code. It's also one that I've seen people ask about.

- Add PhaseGradientGate, QuantumFourierTransformGate, and QFT method
- QFT does not define _apply_unitary_ or _unitary_ because the most efficient way to get them is actually via the decomposition
- Add exponent_qubit_index to CircuitDiagramInfo
- Update ControlledOperation _circuit_diagram_info_ to forward exponent_qubit_index
- Add _circuit_diagram_info_ to _InverseCompositeGate
- Update phase_estimator example to use built-in QFT
- Update hhl example to use built-in QFT
- Add `big_endian_bits` option to `ApplyUnitaryArgs.subspace_index`
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Sep 20, 2019
@Strilanc Strilanc requested a review from dabacon September 20, 2019 07:21
Copy link
Collaborator

@vtomole vtomole left a comment

Choose a reason for hiding this comment

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

nit: Change new files' copyright to 2019.


def __repr__(self):
return ('cirq.QuantumFourierTransformGate(num_qubits={!r}, '
'without_reverse=False)'.format(self._num_qubits,
Copy link
Collaborator

Choose a reason for hiding this comment

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

How will self._without_reverse .format if you hardcode it to False?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whooooops. Added the true case to the test battery inputs and fixed this.

exponent_qubit_index=0)


def QFT(*qubits: 'cirq.Qid', without_reverse: bool = False) -> 'cirq.Operation':
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be lowercase?

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 was trying to make it appear the same as e.g. cirq.H and cirq.SWAP. A user learning the API won't be aware that it's a function instead of a global constant (and isn't a function technically a global constant anyways?).

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mpharrigan Any other issue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@viathor viathor left a comment

Choose a reason for hiding this comment

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

This is nice implementation of QFT! Also, thanks for cleaning up the other ad hoc versions. I have a few suggestions.

@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 24, 2019
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 24, 2019
@CirqBot CirqBot merged commit 498200c into master Sep 24, 2019
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 24, 2019
@CirqBot CirqBot deleted the quirk_tooling2 branch September 24, 2019 21:44
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants