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

Explicitly provide data types in default qubit device #2448

Merged
merged 36 commits into from
May 5, 2022

Conversation

chaeyeunpark
Copy link
Contributor

@chaeyeunpark chaeyeunpark commented Apr 14, 2022

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    test directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the doc/releases/changelog-dev.md file, summarizing the
    change, and including a link back to the PR.

  • The PennyLane source code conforms to
    PEP8 standards.
    We check all of our code against Pylint.
    To lint modified files, simply pip install pylint, and then
    run pylint pennylane/path/to/file.py.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context: With ongoing effort to add SIMD/GPU supports in PennyLane-Lightning, we hope to have better support of a single-precision floating-point throughout the codebase. This PR deals with these requirements.

Description of the Change: QubitDevice, the parent class of all devices that support qubit operations, now accepts data types as an argument in the initializer. Some implicit type conversions happening in some methods became explicit to preserve data types.

Benefits: Offer more flexibility to devices to use their own data type.

Possible Drawbacks:

Related GitHub Issues:

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@chaeyeunpark chaeyeunpark changed the title [WIP] Explicitly specify data types in default qubit [WIP] Explicitly provide data types in default qubit Apr 14, 2022
@codecov
Copy link

codecov bot commented Apr 14, 2022

Codecov Report

Merging #2448 (c79f946) into master (5bad4fa) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2448   +/-   ##
=======================================
  Coverage   99.53%   99.53%           
=======================================
  Files         243      243           
  Lines       19414    19436   +22     
=======================================
+ Hits        19323    19345   +22     
  Misses         91       91           
Impacted Files Coverage Δ
pennylane/_device.py 98.06% <ø> (ø)
pennylane/_grad.py 100.00% <ø> (ø)
pennylane/gradients/parameter_shift_hessian.py 100.00% <ø> (ø)
pennylane/interfaces/autograd.py 100.00% <ø> (ø)
pennylane/interfaces/torch.py 100.00% <ø> (ø)
pennylane/numpy/tensor.py 97.53% <ø> (ø)
pennylane/ops/qubit/hamiltonian.py 100.00% <ø> (ø)
...nylane/transforms/optimization/pattern_matching.py 99.67% <ø> (ø)
pennylane/transforms/tape_expand.py 100.00% <ø> (ø)
pennylane/_qubit_device.py 98.76% <100.00%> (+0.03%) ⬆️
... and 16 more

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 5bad4fa...c79f946. Read the comment docs.

@chaeyeunpark chaeyeunpark marked this pull request as ready for review April 14, 2022 18:29
@chaeyeunpark chaeyeunpark requested review from antalszava and josh146 and removed request for antalszava April 14, 2022 18:30
@chaeyeunpark chaeyeunpark changed the title [WIP] Explicitly provide data types in default qubit [WIP] Explicitly provide data types in default qubit device Apr 14, 2022
@chaeyeunpark chaeyeunpark changed the title [WIP] Explicitly provide data types in default qubit device Explicitly provide data types in default qubit device Apr 20, 2022
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

Hi @chaeyeunpark, lots of apologies for the delayed review here 😿

The PR is looking great! 🙏

One definite change from my side would be to go from assert statements to errors. For the rest, I'm curious about your input too.

pennylane/_qubit_device.py Outdated Show resolved Hide resolved
pennylane/_qubit_device.py Outdated Show resolved Hide resolved
pennylane/devices/default_qubit.py Show resolved Hide resolved
pennylane/devices/default_qubit.py Outdated Show resolved Hide resolved
pennylane/devices/default_qubit.py Show resolved Hide resolved
pennylane/devices/default_qubit_autograd.py Show resolved Hide resolved
pennylane/devices/default_qubit_tf.py Show resolved Hide resolved
tests/devices/test_default_qubit.py Outdated Show resolved Hide resolved
tests/devices/test_default_qubit.py Outdated Show resolved Hide resolved
tests/test_quantum_gradients.py Show resolved Hide resolved
Copy link
Contributor Author

@chaeyeunpark chaeyeunpark left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed review @antalszava! I will incorporate the remaining points ASAP.

pennylane/devices/default_qubit_tf.py Show resolved Hide resolved
tests/devices/test_default_qubit.py Outdated Show resolved Hide resolved
tests/devices/test_default_qubit.py Outdated Show resolved Hide resolved
tests/test_quantum_gradients.py Show resolved Hide resolved
Copy link
Contributor

@antalszava antalszava 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 🥇 Awesome changes 🙂

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
pennylane/_qubit_device.py Show resolved Hide resolved
tests/devices/test_default_qubit.py Show resolved Hide resolved
@chaeyeunpark
Copy link
Contributor Author

Thanks @antalszava for approving this.

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

2 participants