-
Notifications
You must be signed in to change notification settings - Fork 575
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
Pattern matching for quantum circuit optimization #2032
Conversation
self.max_match_list.append(Match(sorted(matches.match), matches.qubit)) | ||
|
||
|
||
class SubstitutionConfig: # pylint: disable=too-many-arguments, too-few-public-methods |
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.
Might be a good candidate for a dataclass.
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.
💯
self.circuit_blocked[succ] = True | ||
|
||
|
||
class Match: # pylint: disable=too-few-public-methods |
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.
Could this be done with a named tuple instead?
|
||
.. code-block:: python | ||
|
||
def circuit(): |
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 wonder if it would be better to start with a blatantly obvious example, where a human can see the pattern without having to stare at it for too long, and then show the more complicated template example.
Like the template is something like [qml.S(0), qml.S(0), qml.PauliZ(0)]
.
|
||
.. code-block:: python | ||
|
||
def circuit(): |
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 wonder if it would be better to start with a blatantly obvious example, where a human can see the pattern without having to stare at it for too long, and then show the more complicated template example.
Like the template is something like [qml.S(0), qml.S(0), qml.PauliZ(0)]
.
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.
Also changelog.
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.
Just a few comments on the changelog.
doc/releases/changelog-dev.md
Outdated
2: ──Z──────╰Z─┤ | ||
``` | ||
|
||
Note that with this pattern we also replace a ``pennylane.S``, ``pennylane.PauliZ`` sequence by ``pennylane.S``. |
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 think at this point we can just point the reader to the documentation and paper. The point of examples in the changelog is to catch interest, not explain in detail.
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.
Ok great I will remove this part!
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
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.
Looks great! Lot of work here and quite an achievement 🥇
Context:
https://arxiv.org/pdf/1909.05270.pdf
Description of the Change:
Introduce a new transform that takes a list of patterns as parameter and returns an optimized version of the circuit.
Example