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 default precision equal to jax.config's jax_enable_x64 #1485

Merged
merged 7 commits into from
Jul 30, 2021

Conversation

dwierichs
Copy link
Contributor

The default qubit jax device currently always uses float32 precision.
This change makes the device check the status of jax.config.config.read('jax_enable_x64'), which is the variable set to True by jax users to enable float64 precision (also see the jax gotcha).

Benefit
When users consciously change the default of jax' precision, the PennyLane device should play along and now does.

Possible drawbacks
The behaviour changes when jax.config.config.read('jax_enable_x64')=True but into the direction of what users would presumably expect.

An alternative method would be to use this update as new default but provide an override precision kwarg to allow for explicitly setting the precision.

@codecov
Copy link

codecov bot commented Jul 30, 2021

Codecov Report

Merging #1485 (aed3d63) into master (c9905a6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1485   +/-   ##
=======================================
  Coverage   98.32%   98.32%           
=======================================
  Files         180      180           
  Lines       12701    12705    +4     
=======================================
+ Hits        12488    12492    +4     
  Misses        213      213           
Impacted Files Coverage Δ
pennylane/devices/default_qubit_jax.py 94.66% <100.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9905a6...aed3d63. Read the comment docs.

@josh146 josh146 added the enhancement ✨ New feature or request label Jul 30, 2021
Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

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

Looks great @dwierichs!

.github/CHANGELOG.md Outdated Show resolved Hide resolved
.github/CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

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

@dwierichs nice, your changelog entry is better than my original suggestion

Co-authored-by: Josh Izaac <josh146@gmail.com>
@dwierichs
Copy link
Contributor Author

Good catch regarding the syntax highlighting!

@josh146 josh146 merged commit 24cc6c2 into PennyLaneAI:master Jul 30, 2021
@dwierichs dwierichs deleted the flexible-jax-precision branch July 30, 2021 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants