catalyst icon indicating copy to clipboard operation
catalyst copied to clipboard

Add resource tracking to NullQubit

Open jzaia18 opened this issue 6 months ago • 2 comments

Before submitting

Please complete the following checklist when submitting a PR:

  • [x] All new functions and code must be clearly commented and documented.

  • [x] Ensure that code is properly formatted by running make format. The latest version of black and clang-format-14 are used in CI/CD to check formatting.

  • [x] All new features must include a unit test. Integration and frontend tests should be added to frontend/test, Quantum dialect and MLIR tests should be added to mlir/test, and Runtime tests should be added to runtime/tests.

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


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 https://github.com/PennyLaneAI/pennylane/pull/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 saves the resources JSON as a file 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-88213]

jzaia18 avatar Apr 07 '25 19:04 jzaia18