Skip to content

Conversation

@jzaia18
Copy link
Contributor

@jzaia18 jzaia18 commented Nov 20, 2025

Context:
Runtime resource tracking currently writes out resource data at the moment that all allocated qubits are released. This causes issues when executing functions that allocate and deallocate multiple times, such as this illustrative example:

import pennylane as qml
from pennylane.compiler.python_compiler.transforms import split_non_commuting_pass

qml.capture.enable()

dev = qml.device("lightning.qubit", wires=3)

@qml.qjit(keep_intermediate=True)
@split_non_commuting_pass
@qml.qnode(dev)
def circuit():
    qml.Hadamard(wires=0)
    return qml.expval(qml.PauliX(0)), qml.expval(qml.PauliY(0))

print(qml.specs(circuit, level="device")())

Description of the Change:
Updates NullQubit to instead write out resource information in its destructor, ensuring all resource data is the sum of data collected for all executions.

Benefits:
Prevents crashes with an ambiguous error message, allows total resource counts to be collected from split workflows

Possible Drawbacks:
The aggregated data is not possible to disaggregate if this would be desired in the future.

Related GitHub Issues:
[sc-104344]

@jzaia18 jzaia18 self-assigned this Nov 20, 2025
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.49%. Comparing base (f930860) to head (5f91108).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2219   +/-   ##
=======================================
  Coverage   97.49%   97.49%           
=======================================
  Files          93       93           
  Lines       10886    10890    +4     
  Branches     1038     1038           
=======================================
+ Hits        10613    10617    +4     
  Misses        211      211           
  Partials       62       62           

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

Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

No notes from me --- thanks @jzaia18
I'll leave approval to others

Copy link
Member

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

Copy link
Member

@paul0403 paul0403 left a comment

Choose a reason for hiding this comment

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

All good from my side, just pending resolution of Shuli's comments 👍

Copy link
Member

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

Nice one! Thanks @jzaia18 !

@jzaia18 jzaia18 merged commit 526b58b into main Nov 21, 2025
39 checks passed
@jzaia18 jzaia18 deleted the feature/res-tracking-multi-exec branch November 21, 2025 01:33
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