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

use int64 for samples instead of bool8 #4539

Merged
merged 8 commits into from
Aug 30, 2023
Merged

use int64 for samples instead of bool8 #4539

merged 8 commits into from
Aug 30, 2023

Conversation

timmysilv
Copy link
Contributor

@timmysilv timmysilv commented Aug 28, 2023

Context:
The new qubit device was going to return booleans for 0-1 samples because that is what a boolean represents. However, this change is different from what we had before., and booleans still take a full byte of memory to stay aligned (let's not get too crazy here in Pythonland anyway) which is the same as np.int8.

Description of the Change:
sample_state, and consequentially qml.sample() now returns samples of dtype=np.int64 instead of np.bool8.

Benefits:

  • The user will receive the more-familiar int return type.
  • There are no problems with memory-alignment
  • The new device API is consistent with the old one
  • existing interface code still works without change

Possible Drawbacks:
np.bool8 was smaller

@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.

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (15bcf04) 99.66% compared to head (73af749) 99.66%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4539   +/-   ##
=======================================
  Coverage   99.66%   99.66%           
=======================================
  Files         376      376           
  Lines       33059    33060    +1     
=======================================
+ Hits        32949    32950    +1     
  Misses        110      110           
Files Changed Coverage Δ
pennylane/devices/qubit/sampling.py 100.00% <100.00%> (ø)

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

@timmysilv timmysilv requested a review from a team August 29, 2023 19:24
@timmysilv timmysilv changed the title use int8 for samples instead of bool8 use int64 for samples instead of bool8 Aug 29, 2023
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Sad that we have to do this, but it allows us to move forward.

@timmysilv timmysilv enabled auto-merge (squash) August 30, 2023 15:11
@timmysilv timmysilv merged commit a6dc1be into master Aug 30, 2023
38 checks passed
@timmysilv timmysilv deleted the sample-return-int branch August 30, 2023 15:46
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.

3 participants