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

Support numpy qid indexes #6987

Merged
merged 2 commits into from
Jan 28, 2025
Merged

Support numpy qid indexes #6987

merged 2 commits into from
Jan 28, 2025

Conversation

daxfohl
Copy link
Collaborator

@daxfohl daxfohl commented Jan 28, 2025

Fixes #6985

It converts indexes to ints in the constructor. It also changes the hash implementation to be precomputed in the constructor rather than lazy-computed. This eliminates an if branch from the __hash__ method, where speed is critical. The tradeoff is that it's always computed in the constructor, even if it's not used. But that's almost never the case: even creating an operation is dependent on hash(qid). And it will still allow creation of millions of qubits per second, so not a bottleneck in any real-world scenario.

@daxfohl daxfohl requested review from vtomole and a team as code owners January 28, 2025 00:23
@daxfohl daxfohl requested a review from dabacon January 28, 2025 00:23
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jan 28, 2025
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.88%. Comparing base (79d562a) to head (6c16eb3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6987      +/-   ##
==========================================
- Coverage   97.88%   97.88%   -0.01%     
==========================================
  Files        1085     1085              
  Lines       94991    95032      +41     
==========================================
+ Hits        92984    93018      +34     
- Misses       2007     2014       +7     

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

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

Nice, thank you for the fix!

@daxfohl daxfohl added this pull request to the merge queue Jan 28, 2025
Merged via the queue into quantumlib:main with commit 435f3e1 Jan 28, 2025
37 checks passed
@daxfohl daxfohl deleted the fix-qid-numpy branch January 28, 2025 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qid subtype hashes fail when initialized with numpy int types
3 participants