-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implement a N - qubit QFT with one line of code. #26
Comments
Sounds like a blast, I'd like to take this one @matt-lourens! |
That's Great, thanks @Aaron-Robertson! Let me know if anything is unclear, I'm happy to elaborate more on the issue or package. |
@matt-lourens I walked through the examples and code but I'm still not completely clear, so perhaps better we sync up! I'm happy to take notes while we do if you like, since I noticed a few TODOs around documenting |
Hey @Aaron-Robertson sure thing, let's do call and sync up, are you free sometime tomorrow? I'm in SAST time, and can do a call the morning somewhere between 09:00 and 13:00. Let me know what time would work for you.
The outline for Qpivot will look something like: class Qpivot(Qmotif):
"""
"""
def __init__(self, pattern="1*", **kwargs):
# Initalize Qpivot, has a pattern attribute
pass
def __call__(self, Qc_l, *args, **kwargs):
# Check if arity==2
# Get pivot pattern function based on the logic from Qmask_base.get_mask_pattern_fn
# The relevant logic from Qmask_base.get_mask_pattern_fn is lines 731-753 (the if any("*") block)
# Set source and pivot qubits by calling pivot pattern function
# Generate edges based on connection type, nearest_cicle, nearest_tower, cycle
# The logic of this will be similar to Qmask lines 849-881
# You can ignore the other Qmask code, the true case for the if on line 844 goes into the mask functionality that most mimics the qpivot one
# If connection type is cycle use stride, step and offset to generate the edges
# The stride
return self
def __eq__(self, other):
# Equality check
pass I hope that makes things a bit clearer. Stepping through the code: u = Qunitary(V2, 0, 2)
hierq = Qinit(8) + Qmask("1*1*1", mapping=u)
circuit = hierq(backend="qiskit")
circuit.draw("mpl")
u = Qunitary(V2, 0, 2)
hierq = Qinit(8) + Qmask("*1", mapping=u)
circuit = hierq(backend="qiskit")
circuit.draw("mpl") Should also help, specifically if you have a breakpoint on line 849 |
@matt-lourens That clarifies most of my concerns, so thanks! I can be available from 12-13, but will go ahead with the stub as provided. Fortunately all I'd done was use a find and replace on |
Hey @Aaron-Robertson 12 SAST works for me, do you have discord? I'm on the unitary fund server, you can reach me at: Mattx2#9155 |
Fixed with #40 |
Summary
The Quantum Fourier Transform has nice symmetry in it's circuit representation, as seen here from Nielsen and Chuang Chapter 5:
![image](https://private-user-images.githubusercontent.com/51360109/239731603-bc8b0ae8-9ca8-4141-89dc-0d7385c9a71b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA2NTc4MTQsIm5iZiI6MTcyMDY1NzUxNCwicGF0aCI6Ii81MTM2MDEwOS8yMzk3MzE2MDMtYmM4YjBhZTgtOWNhOC00MTQxLTg5ZGMtMGQ3Mzg1YzlhNzFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzExVDAwMjUxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM4MGRkNTA0MGY2MTQ0YjgzNGYxM2EyNTNhYWNhZjU4YjJlNDNkZmE3Mjk0ZjMyOWFhZGI5NjkzYjRlN2RiZDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.HPfBqKY1PTZkSNnS9M__kzdsm0925LF9Ri2m8KUCxv4)
This amends itself well to being implementable with HierarQcal. We will however need a new primitive operation called
Qpivot
which given a 2 qubit unitary, cycles though each qubit and connects it to one pivot qubit (pivot acts as target, more detail below). The gist of this issue is implementing the new Qpivot primitive and showcasing it's usage in the examples notebook with QFT, which I think we can do in essentially one line.Example usage
It will go something like this:
The
Qpivot
primitive is very similar to theQmask
primitive so use that as a reference (seeQmask
examples in quickstart.ipynb), and I'm happy to explain in more detail howQmask
works to make the development easier.Qpivot
will receive a pattern string, where '1' indicates the pivot qubit and0
the control. The star is a wild card which gets filled with '0''s based on the number of available qubits.1*
pivots to the top qubit,*1
to the bottom,*1*
to the middle,1*1*1
has 3 pivots which can be connected based on nearest neighbour or the normal cycle pattern, something similar is already implemented inQmask
which I can take you through. For one qubit unitaries (such as theh_top
for the Hadamard) the unitary gets placed only on pivot qubits. You can ignore theN>2
-qubit unitary case, I will implement that logic but it will be the same idea asQmask
.Here's some examples of the directed graphs corresponding the pivot primitive (qubits are nodes and 2-qubit unitaries edges):
Pivot "1*" pattern on 8 qubits
Pivot "*1" pattern on 8 qubits
The text was updated successfully, but these errors were encountered: