Skip to content
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

Add a transform get_unitary_matrix to obtain matrix representations of circuits #1609

Merged
merged 101 commits into from
Sep 23, 2021

Conversation

ingstra
Copy link
Contributor

@ingstra ingstra commented Aug 30, 2021

Context:

Create a new function to construct the unitary matrix corresponding to any quantum circuit.

Description of the Change:

The new transform get_unitary_matrix works similarly to _apply_unitary() in devices/default_qubit.py.
Benefits:

Can process all operations, including controlled gates on non-adjacent wires or wires in reverse order.

Possible Drawbacks:

Related GitHub Issues:
#1462

ingstra and others added 30 commits August 17, 2021 21:14
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Copy link
Contributor

@rmoyard rmoyard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ingstra, thanks for the update. You can follow Josh's advice on how to reduce the number of ifand else, this should solve the last problem 💯

pennylane/transforms/get_unitary_matrix.py Outdated Show resolved Hide resolved
pennylane/transforms/get_unitary_matrix.py Show resolved Hide resolved
@ingstra
Copy link
Contributor Author

ingstra commented Sep 21, 2021

Why is Sphinx suddenly failing? The error message is not very forthcoming:

[sphinx-action] Build failed with 0 warnings
Traceback (most recent call last):
File "/entrypoint.py", line 22, in
action.build_all_docs(github_env, [os.environ.get("INPUT_DOCS-FOLDER")])
File "/sphinx_action/action.py", line 167, in build_all_docs
raise RuntimeError("Build failed")
RuntimeError: Build failed

Copy link
Contributor

@rmoyard rmoyard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ingstra, it looks good on my side thank you again for the great work! 💯 I let @glassnotes give a final review.

Copy link
Contributor

@glassnotes glassnotes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ingstra this is awesome!! 💯 All but one of my suggestions here is just formatting. The only thing left to add is an interface test for JAX, which will look quite similar to the other interface tests. Once that's in, it's ready to merge 🚀

doc/releases/changelog-dev.md Show resolved Hide resolved
pennylane/transforms/__init__.py Outdated Show resolved Hide resolved
pennylane/transforms/get_unitary_matrix.py Outdated Show resolved Hide resolved
pennylane/transforms/get_unitary_matrix.py Outdated Show resolved Hide resolved
pennylane/transforms/__init__.py Outdated Show resolved Hide resolved
tests/transforms/test_get_unitary_matrix.py Outdated Show resolved Hide resolved
tests/transforms/test_get_unitary_matrix.py Show resolved Hide resolved
tests/transforms/test_get_unitary_matrix.py Outdated Show resolved Hide resolved
tests/transforms/test_get_unitary_matrix.py Outdated Show resolved Hide resolved
tests/transforms/test_get_unitary_matrix.py Show resolved Hide resolved
ingstra and others added 11 commits September 22, 2021 18:46
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
@ingstra
Copy link
Contributor Author

ingstra commented Sep 22, 2021

Thanks @glassnotes! I accepted your suggestions and added a test with JAX.

Copy link
Contributor

@glassnotes glassnotes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ingstra changes looks great, this is ready to go! 🎉 It looks like there will be a few merge conflicts when updating the branch, let me know if you run into any trouble with those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants