catalyst
catalyst copied to clipboard
Add resource tracking to NullQubit
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 andclang-format-14are 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 tomlir/test, and Runtime tests should be added toruntime/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]