-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
- 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`
# Conflicts: # cirq/protocols/apply_unitary_test.py
There was a problem hiding this 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.
cirq/ops/fourier_transform.py
Outdated
|
||
def __repr__(self): | ||
return ('cirq.QuantumFourierTransformGate(num_qubits={!r}, ' | ||
'without_reverse=False)'.format(self._num_qubits, |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
cirq/ops/fourier_transform.py
Outdated
exponent_qubit_index=0) | ||
|
||
|
||
def QFT(*qubits: 'cirq.Qid', without_reverse: bool = False) -> 'cirq.Operation': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be lowercase?
There was a problem hiding this comment.
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?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpharrigan Any other issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this 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.
big_endian_bits
option toApplyUnitaryArgs.subspace_index
This one had snuck into a couple examples as redundant code. It's also one that I've seen people ask about.