Skip to content

Add resource tracking to NullQubit #1619

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

Merged
merged 65 commits into from
May 22, 2025
Merged

Add resource tracking to NullQubit #1619

merged 65 commits into from
May 22, 2025

Conversation

jzaia18
Copy link
Contributor

@jzaia18 jzaia18 commented Apr 7, 2025

Context:
For benchmarking, we need a method of precise resource tracking. This method has to be compatible with code run directly from PennyLane and should be able to track precise resources after various transformation passes have already occurred.

See also: https://github.com/PennyLaneAI/pennylane-benchmarks/pull/76 and PennyLaneAI/pennylane#7226

Description of the Change:
Adds 2 new class attributes to NullQubit, as well as an optional argument to its constructor. When this option is toggled on, NullQubit will track precise gate counts while "executing" a circuit and save them to a file when all qubits are released.

Benefits:
It is now possible to track precise gate counts (with or without gate decomposition or other transformation passes) for measuring circuit complexity.

Possible Drawbacks:
This implementation currently write the resources JSON to a file on disk as opposed to neatly returning an object back through to the Python caller in PennyLane. In the future, a more robust solution may be desired.

Related GitHub Issues:
[sc-91366]

@jzaia18 jzaia18 requested a review from maliasadi April 7, 2025 19:32
@jzaia18 jzaia18 self-assigned this Apr 7, 2025
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 97.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.65%. Comparing base (a2e4742) to head (c69b8f2).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
runtime/lib/backend/null_qubit/NullQubit.hpp 95.38% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1619      +/-   ##
==========================================
+ Coverage   96.53%   96.65%   +0.11%     
==========================================
  Files          82       82              
  Lines        9039     9170     +131     
  Branches      864      864              
==========================================
+ Hits         8726     8863     +137     
+ Misses        256      250       -6     
  Partials       57       57              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jzaia18 jzaia18 marked this pull request as draft April 7, 2025 19:47
@dime10
Copy link
Contributor

dime10 commented Apr 7, 2025

Oh wow, I was just starting on this as well a couple of hours ago (just as a hack) 😆 Super useful though, thanks!

Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Thanks @jzaia18!

@jzaia18 jzaia18 changed the title [WIP] Add resource tracking to NullQubit Add resource tracking to NullQubit Apr 16, 2025
@jzaia18 jzaia18 marked this pull request as ready for review April 16, 2025 18:47
@jzaia18 jzaia18 requested a review from dime10 May 7, 2025 15:18
Copy link
Contributor

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

🎉

Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Nice work @jzaia18! 🥳 Just a few minor comments to resolve before merge!

@jzaia18 jzaia18 requested review from dime10 and maliasadi May 13, 2025 14:23
Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Nice work @jzaia18! Just a few minor comments to consider before merging the PR.

@jzaia18 jzaia18 merged commit 3e9b0d4 into main May 22, 2025
38 checks passed
@jzaia18 jzaia18 deleted the feature/complexity-stats branch May 22, 2025 14:36
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.

5 participants