-
Notifications
You must be signed in to change notification settings - Fork 181
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
[WIP] QROM demo #1123
base: dev
Are you sure you want to change the base?
[WIP] QROM demo #1123
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! |
[sc-63852] |
Thank you for opening this pull request. You can find the built site at this link. Deployment Info:
Note: It may take several minutes for updates to this pull request to be reflected on the deployed site. |
{ | ||
"title": "Intro to QSVT", | ||
"authors": [ | ||
{ | ||
"id": "guillermo_alonso" | ||
} | ||
], | ||
"dateOfPublication": "2023-05-23T00:00:00+00:00", | ||
"dateOfLastModification": "2024-03-04T00:00:00+00:00", | ||
"categories": [ | ||
"Algorithms", |
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.
The metadata I usually updated at the end when we already have the thumbnails
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.
The overall structure is great, but I think there is a lot of room for improvement in the presentation
Managing data is a crucial task on any computer, and quantum computers are no exception. Efficient data management is vital in Quantum Machine Learning (QML), search algorithms or state preparation. | ||
In this demonstration, we will introduce the concept of Quantum Read-Only Memory (QROM), a data structure designed to facilitate these tasks. |
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.
Managing data is a crucial task on any computer, and quantum computers are no exception. Efficient data management is vital in Quantum Machine Learning (QML), search algorithms or state preparation. | |
In this demonstration, we will introduce the concept of Quantum Read-Only Memory (QROM), a data structure designed to facilitate these tasks. | |
Managing data is a crucial task on any computer, and quantum computers are no exception. Efficient data management is vital in quantum machine learning, search algorithms, and state preparation. | |
In this demonstration, we will introduce the concept of a Quantum Read-Only Memory (QROM), a data structure designed to load classical data on a quantum computer. |
No need for acronyms (QML) if you are not using them again
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.
You should also mention in the introduction that we are going to explain how to implement it using PennyLane
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.
In particular, we should probably mention that we have a specific QROM operation that implements it directly, and link to it already at the beginning for easy access
The QROM is an operator that allows us to load classical data into a quantum computer | ||
associated with indices. This data is represented as a bitstring (list of 0s and 1s) and the operator can be defined as: |
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.
The QROM is an operator that allows us to load classical data into a quantum computer | |
associated with indices. This data is represented as a bitstring (list of 0s and 1s) and the operator can be defined as: | |
The QROM is an operator that allows us to load classical data into a quantum computer. Data is represented as a collection of bitstrings (list of 0s and 1s) that we denote by :math:`b_1, b_2, \ldots, b_N`. The QROM operator is then defined as: |
Suppose our data consists of eight bit-strings :math:`[11, 01, 11, 00, 10, 10, 11, 00]`. Then, the index register will consist of three | ||
qubits (:math:`\log_2 8`) and the target register of two qubits (length of the bit-strings). Following the same example, | ||
:math:`\text{QROM}|010\rangle|00\rangle = |010\rangle|11\rangle`, since the bit-string associated with index :math:`2` is :math:`11`. | ||
We will show three different implementations of this operator: Select, SelectSwap and an extension of the | ||
last one. |
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.
Suppose our data consists of eight bit-strings :math:`[11, 01, 11, 00, 10, 10, 11, 00]`. Then, the index register will consist of three | |
qubits (:math:`\log_2 8`) and the target register of two qubits (length of the bit-strings). Following the same example, | |
:math:`\text{QROM}|010\rangle|00\rangle = |010\rangle|11\rangle`, since the bit-string associated with index :math:`2` is :math:`11`. | |
We will show three different implementations of this operator: Select, SelectSwap and an extension of the | |
last one. | |
For example, suppose our data consists of eight bit-strings, each with two bits: :math:`[11, 01, 11, 00, 10, 10, 11, 00]`. Then, the index register will consist of three | |
qubits (:math:`3 = \log_2 8`) and the target register of two qubits (length of the bit-strings). In this case, the QROM operator acts as | |
:math:`\text{QROM}|010\rangle|00\rangle = |010\rangle|11\rangle`, since the bit-string associated with index :math:`2` is :math:`11`. | |
We will now explain three different implementations of a QROM: Select, SelectSwap, and an extension of SelectSwap. |
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.
Actually, here I think it may be better to have a simple dataset of 4 strings of 2 bits, then show the complete action of QROM on all of them. If we pick the first 4 in your example it would be
QROM |00> |00> = |00>|11>
QROM |01> |00> = |01>|01>
QROM |10> |00> = |10>|11>
QROM |11> |00> = |11>|00>
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.
You can use one example with 4 bitstrings here, then have another example with 8 bitstrings to be used later throughout
|
||
.. math:: | ||
|
||
\text{Sel}|i\rangle|0\rangle = |i\rangle|\phi_i\rangle, |
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.
\text{Sel}|i\rangle|0\rangle = |i\rangle|\phi_i\rangle, | |
\text{Sel}|i\rangle|0\rangle = |i\rangleU_i|0\rangle =|i\rangle|\phi_i\rangle, |
Since the bitstrings can be seen as a particular quantum state, we particularize this operator to the QROM case. | ||
For the following example we are going to use :class:`~.pennylane.BasisEmbedding` as :math:`U_i`, and | ||
the :class:`~.pennylane.Select` template provided by PennyLane. |
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.
Since the bitstrings can be seen as a particular quantum state, we particularize this operator to the QROM case. | |
For the following example we are going to use :class:`~.pennylane.BasisEmbedding` as :math:`U_i`, and | |
the :class:`~.pennylane.Select` template provided by PennyLane. | |
Since the bitstrings are encoded in computational basis states, we can view QROM as a special case of a Select operator. | |
For the following example we are going to use :class:`~.pennylane.BasisEmbedding` as :math:`U_i`, and | |
the :class:`~.pennylane.Select` template provided by PennyLane. |
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 don't understand what you mean by "use :class:~.pennylane.BasisEmbedding
as :math:U_i
". Please clarify in the text.
# | ||
# QROM in PennyLane | ||
# ----------------- | ||
# Coding these ideas from scratch can be painful but with the help of PennyLane you can use it in just one line. |
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.
# Coding these ideas from scratch can be painful but with the help of PennyLane you can use it in just one line. | |
# Coding a QROM circuit from scratch can be painful, but with the help of PennyLane you can do it in just one line. |
# QROM in PennyLane | ||
# ----------------- | ||
# Coding these ideas from scratch can be painful but with the help of PennyLane you can use it in just one line. | ||
# We are going to encode the same bitstrings, using the first SelectSwap approach. In this example we use two work wires |
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.
# We are going to encode the same bitstrings, using the first SelectSwap approach. In this example we use two work wires | |
# We are going to encode the same bitstrings, using the SelectSwap approach. In this example we use two work wires |
return True | ||
return False | ||
|
||
@partial(qml.devices.preprocess.decompose, stopping_condition = my_stop, max_expansion=2) |
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.
What's the purpose of this @partial?
qml.PauliX(control_wires[-3]) | ||
qml.Hadamard(control_wires[-1]) | ||
qml.Hadamard(control_wires[-2]) |
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 find this confusing, like you're trying to do too much. I suggest instead creating a more complicated QROM circuit and drawing it to show that it's correct and easy to implement with PL
# | ||
# By implementing various versions of the QROM operator, such as Select and SelectSwap, we optimize quantum circuits | ||
# for enhanced performance and scalability. Numerous studies demonstrate the efficacy of these methods in improving | ||
# State Preparation [#StatePrep]_ techniques by reducing the number of required gates, which I recommend you explore. |
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.
# State Preparation [#StatePrep]_ techniques by reducing the number of required gates, which I recommend you explore. | |
# state preparation [#StatePrep]_ techniques by reducing the number of required gates, which we recommend you explore. |
Use "we", not "I"
Before submitting
Please complete the following checklist when submitting a PR:
Ensure that your tutorial executes correctly, and conforms to the
guidelines specified in the README.
Remember to do a grammar check of the content you include.
All tutorials conform to
PEP8 standards.
To auto format files, simply
pip install black
, and thenrun
black -l 100 path/to/file.py
.When all the above are checked, delete everything above the dashed
line and fill in the pull request template.
Title:
Summary:
Relevant references:
Possible Drawbacks:
Related GitHub Issues:
If you are writing a demonstration, please answer these questions to facilitate the marketing process.
GOALS — Why are we working on this now?
Eg. Promote a new PL feature or show a PL implementation of a recent paper.
AUDIENCE — Who is this for?
Eg. Chemistry researchers, PL educators, beginners in quantum computing.
KEYWORDS — What words should be included in the marketing post?
Which of the following types of documentation is most similar to your file?
(more details here)