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

Make BasisRotation jit compatible #6779

Merged
merged 3 commits into from
Jan 8, 2025
Merged

Make BasisRotation jit compatible #6779

merged 3 commits into from
Jan 8, 2025

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Jan 7, 2025

Context:

PR #6019 only fixes BasisRotation when using backprop on default.qubit. It is not jit compatible on any other device. This is because unitary_matrix was being considered a hyperparameter, not a piece of data. So we could not detect that the matrix was a tracer and we were in jitting mode, and we could not convert the matrix back into numpy data.

Description of the Change:

Make unitary_matrix a piece of data instead of a hyperparameter. This allows us to detect when it is being jitted.

As a by-product, I also made it valid pytree.

By making unitary_matrix a piece of data, we were able to get rid of the custom comparison method in qml.equal.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

[sc-51603] Fixes #6004

@albi3ro albi3ro changed the base branch from master to v0.40.0-rc0 January 7, 2025 20:54
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (v0.40.0-rc0@22b172b). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             v0.40.0-rc0    #6779   +/-   ##
==============================================
  Coverage               ?   99.60%           
==============================================
  Files                  ?      476           
  Lines                  ?    45222           
  Branches               ?        0           
==============================================
  Hits                   ?    45045           
  Misses                 ?      177           
  Partials               ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PietropaoloFrisoni PietropaoloFrisoni added this to the v0.40 milestone Jan 8, 2025
@andrijapau andrijapau self-requested a review January 8, 2025 15:51
Copy link
Contributor

@andrijapau andrijapau left a comment

Choose a reason for hiding this comment

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

Just something I noticed passing by 😸

Copy link
Contributor

@obliviateandsurrender obliviateandsurrender left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for this! 🚀

@albi3ro albi3ro merged commit 0f95698 into v0.40.0-rc0 Jan 8, 2025
41 checks passed
@albi3ro albi3ro deleted the basis-rotation-fix branch January 8, 2025 20:48
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.

[BUG] BasisRotation is not JAX compatible
5 participants