-
Notifications
You must be signed in to change notification settings - Fork 211
Add demo on resourcefulness analysis with generalised Fourier transforms #1462
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
base: master
Are you sure you want to change the base?
Conversation
👋 Hey, looks like you've updated some demos! 🐘 Don't forget to update the Please hide this comment once the field(s) are updated. Thanks! |
…o resourcefulness_demo
Hi @mariaschuld — The metadata checks were failing due to the following categories not passing validation. I think @alvaro-at-xanadu can clarify if these need to be added. |
Your preview is ready 🎉!You can view your changes here |
Hi @mariaschuld These are the allowed categories: ![]() |
…o resourcefulness_demo
…o resourcefulness_demo
@daniela-angulo I added Tarik's pictures, but need to work on this demo a little more to polish and turn code into PL functionality. Will get back to it! |
|
||
###################################################################### | ||
# | ||
# About the authors | ||
# ----------------- | ||
# |
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.
Hey @mariaschuld — we now no longer need these sections at the bottom demos, they are added dynamically when displayed on the website.
###################################################################### | |
# | |
# About the authors | |
# ----------------- | |
# |
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.
Thanks Alan!
…o resourcefulness_demo
|
||
import pennylane as qml | ||
from scipy.stats import unitary_group | ||
|
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.
@Alex-Preciado @isaacdevlugt , the code shared by the authors was creating these states by hand. I found it much neater to use PL, and I think this is an important use case: to make mathematical computations quicker and more reliable. However, I would love to have a qml.HaarState
operator!
|
||
import itertools | ||
import functools | ||
|
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 would be a perfect section for PL's pauli
module. I tried this:
from pennylane.pauli import string_to_pauli_word, pauli_word_to_matrix
n=2
all_strs = [''.join(s) for s in itertools.product('IXYZ', repeat=n)]
# sort by number of identities in the Pauli word
basis = sorted(all_strs, key=lambda s: (n - s.count('I'), s))
# collect flattened Pauli basis matrices
B = []
for s in basis:
pauli_word = string_to_pauli_word(s)
M = pauli_word_to_matrix(pauli_word)
print(pauli_word, M)
M_flat = M.reshape(-1) / np.sqrt(2**n)
B.append(M_flat)
B = np.array(B)
Where I gave up for now is that string_to_pauli_word
somehow deletes the identities, and I end up with the wrong shape of the matrices. I know I could circumvent this using the wire_map
keyword, but didn't have the patience.
@daniela-angulo this demo is ready for another technical review and a product review! |
# `here <https://github.com/PennyLaneAI/qml/demonstrations_v2/tutorial_resourcefulness/utils.py>`__: | ||
# | ||
|
||
from utils import group_rows_cols_by_sparsity |
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.
Is this a good way to do it? I could probably find a more elegant way than using this function, but it would take too much time right now.
# But ``Uvec_diag`` does not look block diagonal. What happened here? | ||
# Well, it *is* block-diagonal, but we have to reorder the columns and rows of the final matrix to make this visible. | ||
# This takes a bit of pain, which we outsource to a utility function that can be found | ||
# `here <https://github.com/PennyLaneAI/qml/demonstrations_v2/tutorial_resourcefulness/utils.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.
Todo: check this link when live!
I will wait until the technical review is done and then perform the content review. I'll keep an eye on. Thank you so much @mariaschuld |
This is a demo we are creating with the first authors of this paper.