Skip to content
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
8b675bd
Disentangle this branch from new specs features
jzaia18 Nov 28, 2025
5c37ef3
Update unit tests to match new specs
jzaia18 Nov 28, 2025
d37e027
Formatting
jzaia18 Nov 28, 2025
1ad4919
Make more tests pass
jzaia18 Nov 28, 2025
0799379
Update docs
jzaia18 Nov 29, 2025
f89312e
More tweaks to how resources are returned
jzaia18 Nov 29, 2025
8b0d16e
Fix more unit tests
jzaia18 Nov 29, 2025
3cb11ac
Yet more test tweaks
jzaia18 Nov 29, 2025
335caa4
More updates
jzaia18 Nov 29, 2025
039512a
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 1, 2025
cef960f
Fix last failing test
jzaia18 Dec 1, 2025
336e9c7
Merge branch 'chore/specs-outputs' of github.com:PennyLaneAI/pennylan…
jzaia18 Dec 1, 2025
4eb692d
Docs for SpecsResources
jzaia18 Dec 1, 2025
a63dcb1
Fix yet another test
jzaia18 Dec 1, 2025
592ffc0
Add docs for SpecsResult
jzaia18 Dec 1, 2025
243692d
These tests Q-Q
jzaia18 Dec 1, 2025
3f0c23a
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 1, 2025
3dfc168
Unit tests for SpecsResources
jzaia18 Dec 1, 2025
88eaec0
Merge branch 'chore/specs-outputs' of github.com:PennyLaneAI/pennylan…
jzaia18 Dec 1, 2025
7f833cd
Re-add tests for _count_resources
jzaia18 Dec 1, 2025
d2e5569
Re-add tests for _count_resources
jzaia18 Dec 1, 2025
53aa47d
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 1, 2025
ba0514c
Test to_dict
jzaia18 Dec 1, 2025
321d605
Tests for SpecsResult
jzaia18 Dec 1, 2025
ef97962
Merge branch 'chore/specs-outputs' of github.com:PennyLaneAI/pennylan…
jzaia18 Dec 1, 2025
cd117ba
Docs updates
jzaia18 Dec 1, 2025
e448e77
Update changelog
jzaia18 Dec 1, 2025
8f09c21
Update pennylane/devices/_qubit_device.py
jzaia18 Dec 1, 2025
04285d0
Rename SpecsResult to CircuitSpecs
jzaia18 Dec 1, 2025
d8266ac
Missed one!
jzaia18 Dec 1, 2025
b4238ed
Update how multi-controlled gates are displayed in specs
jzaia18 Dec 1, 2025
b7ab2e9
Docs updates
jzaia18 Dec 2, 2025
93535e7
More docs updates
jzaia18 Dec 2, 2025
9322d20
Update formatting of null.qubit in docs
jzaia18 Dec 2, 2025
397a15e
Sphinx?
jzaia18 Dec 2, 2025
17691de
Indenting got messed up
jzaia18 Dec 2, 2025
817500b
More docs fixes
jzaia18 Dec 2, 2025
fd1e2fb
Merge branch 'main' into chore/specs-outputs
jzaia18 Dec 2, 2025
3081978
Better separation for pretty printing
jzaia18 Dec 2, 2025
60e90af
ipython display
jzaia18 Dec 2, 2025
a034f6d
Magical BLANKLINE incantations
jzaia18 Dec 2, 2025
c20c38a
Streamline resource conversion
jzaia18 Dec 2, 2025
ca47e4b
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 2, 2025
0230d47
Apply suggestions from code review
jzaia18 Dec 2, 2025
c07f560
Format
jzaia18 Dec 2, 2025
970df34
Remove unused import
jzaia18 Dec 2, 2025
b40c925
Remove 'pycon' codeblock
jzaia18 Dec 3, 2025
57a00b1
Add new unit test for qml.marker with qml.specs
jzaia18 Dec 3, 2025
b2bf47b
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 3, 2025
a0012a5
Update how str is made
jzaia18 Dec 3, 2025
1fe81dd
Update docs
jzaia18 Dec 3, 2025
d18c41d
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 3, 2025
f81bae9
Return observable info within measurements for plain PL specs
jzaia18 Dec 4, 2025
5ce0ab4
Merge branch 'main' into chore/specs-outputs
jzaia18 Dec 4, 2025
53edb6d
Update unit tests
jzaia18 Dec 4, 2025
e63fdf4
Update docs
jzaia18 Dec 4, 2025
e1e3af3
Skip coverage on ipython display helper
jzaia18 Dec 4, 2025
b3b2b24
Add hamiltonian tests
jzaia18 Dec 5, 2025
f78be3f
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 5, 2025
b7d54f4
Change how batching is handled
jzaia18 Dec 5, 2025
aba6550
Docs fixes
jzaia18 Dec 5, 2025
78f64ac
Apply suggestions from code review
jzaia18 Dec 5, 2025
7c4994a
Docs changes
jzaia18 Dec 5, 2025
1b31c14
Merge branch 'chore/specs-outputs' of github.com:PennyLaneAI/pennylan…
jzaia18 Dec 5, 2025
54c298a
Minor typo
jzaia18 Dec 5, 2025
bc1ff64
Switch back to list as possible output
jzaia18 Dec 5, 2025
dcfee7b
Fix printing for CircuitSpecs
jzaia18 Dec 5, 2025
77e9543
Fix doctests
jzaia18 Dec 5, 2025
51ca4b1
Clean up specs output
jzaia18 Dec 5, 2025
eebde8d
Placate codefactor
jzaia18 Dec 5, 2025
294f2fb
More thorough testing for new batch output
jzaia18 Dec 5, 2025
5250274
Add more coverage
jzaia18 Dec 5, 2025
f3b7ec3
Apply suggestions from code review
jzaia18 Dec 6, 2025
74cfce3
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 6, 2025
b894da4
Implement Anton's suggestions
jzaia18 Dec 7, 2025
1e8a45a
Apply suggestions from code review
jzaia18 Dec 8, 2025
e80bd40
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 8, 2025
cf9c3b3
Update how hamiltonians are tracked
jzaia18 Dec 8, 2025
8efa45b
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 8, 2025
a694229
Update test
jzaia18 Dec 8, 2025
39e4601
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 8, 2025
ac15ca0
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 8, 2025
4b3ee0c
Standardize how observables are printed
jzaia18 Dec 8, 2025
03045c3
Merge branch 'chore/specs-outputs' of github.com:PennyLaneAI/pennylan…
jzaia18 Dec 8, 2025
c03c44b
Doctests
jzaia18 Dec 8, 2025
fed1a3d
Update pennylane/resource/__init__.py
jzaia18 Dec 8, 2025
ff91811
Fix missing import
jzaia18 Dec 8, 2025
6f797fc
Coverage
jzaia18 Dec 8, 2025
b9fcbf1
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 8, 2025
ccbf8c6
Merge branch 'master' into chore/specs-outputs
jzaia18 Dec 9, 2025
7e3809b
Codecov
jzaia18 Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@

<h3>Breaking changes 💔</h3>

* The output format of `qml.specs` has been restructured into a dataclass to streamline the outputs.
Some legacy information has been removed from the new output format.
[(#8713)](https://github.com/PennyLaneAI/pennylane/pull/8713)

* The unified compiler, implemented in the `qml.compiler.python_compiler` submodule, has been removed from PennyLane.
It has been migrated to Catalyst, available as `catalyst.python_interface`.
[(#8662)](https://github.com/PennyLaneAI/pennylane/pull/8662)
Expand Down
18 changes: 4 additions & 14 deletions pennylane/devices/_qubit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@
SampleMeasurement,
SampleMP,
ShadowExpvalMP,
Shots,
StateMeasurement,
StateMP,
VarianceMP,
VnEntropyMP,
)
from pennylane.operation import Operation, Operator, operation_derivative
from pennylane.ops import MeasurementValue, MidMeasure, Rot, X, Y, Z, adjoint
from pennylane.resource import Resources
from pennylane.tape import QuantumScript
from pennylane.wires import Wires

Expand Down Expand Up @@ -314,19 +312,11 @@ def execute(self, circuit, **kwargs):
self._num_executions += 1

if self.tracker.active:
shots_from_dev = self._shots if not self.shot_vector else self._raw_shot_sequence
tape_resources = circuit.specs["resources"]

resources = Resources( # temporary until shots get updated on tape !
tape_resources.num_wires,
tape_resources.num_gates,
tape_resources.gate_types,
tape_resources.gate_sizes,
tape_resources.depth,
Shots(shots_from_dev),
)
self.tracker.update(
executions=1, shots=self._shots, results=results, resources=resources
executions=1,
shots=self._shots,
results=results,
resources=circuit.specs["resources"],
)
self.tracker.record()

Expand Down
61 changes: 40 additions & 21 deletions pennylane/resource/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2022 Xanadu Quantum Technologies Inc.
# Copyright 2018-2025 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,14 +18,8 @@
.. seealso::
The :mod:`~.estimator` module for higher level resource estimation of quantum programs.

.. warning::
The functions ``estimate_error``, ``estimate_shots`` and the classes ``DoubleFactorization``,
``FirstQuantization`` have been moved to the :mod:`pennylane.estimator` module.
Accessing them from the :mod:`pennylane.resource` module is deprecated and will be removed
in v0.45.

Circuit specifications
----------------------
Circuit Specifications (specs)
------------------------------

.. currentmodule:: pennylane

Expand All @@ -34,6 +28,18 @@

~specs

Circuit Specification Classes and Utilities
-------------------------------------------

.. currentmodule:: pennylane.resource

.. autosummary::
:toctree: api

~CircuitSpecs
~SpecsResources

~resources_from_tape

Error Tracking
--------------
Expand All @@ -47,6 +53,12 @@
~SpectralNormError
~ErrorOperation

.. warning::
The functions ``estimate_error``, ``estimate_shots`` and the classes ``DoubleFactorization``,
``FirstQuantization`` have been moved to the :mod:`pennylane.estimator` module.
Accessing them from the :mod:`pennylane.resource` module is deprecated and will be removed
in v0.45.

Resource Classes
----------------

Expand Down Expand Up @@ -75,8 +87,8 @@
Tracking Resources for Custom Operations
----------------------------------------

We can use the :code:`null.qubit` device with the :class:`pennylane.Tracker` to track the resources
used in a quantum circuit with custom operations without execution.
We can use the :mod:`null.qubit <pennylane.devices.null_qubit>` device with the :class:`pennylane.Tracker`
to track the resources used in a quantum circuit with custom operations without execution.

.. code-block:: python

Expand Down Expand Up @@ -112,25 +124,32 @@ def circuit(theta):

We can examine the resources by accessing the :code:`resources` key:

>>> resources_lst = tracker.history['resources']
>>> print(resources_lst[0])
num_wires: 3
num_gates: 7
depth: 5
shots: Shots(total=100)
gate_types:
{'RZ': 1, 'CNOT': 2, 'Hadamard': 2, 'PauliZ': 2}
gate_sizes:
{1: 5, 2: 2}
>>> resources_lst = tracker.history['resources']
>>> print(resources_lst[0])
Total qubit allocations: 3
Total gates: 7
Circuit depth: 5
<BLANKLINE>
Gate types:
RZ: 1
CNOT: 2
Hadamard: 2
PauliZ: 2
<BLANKLINE>
Measurements:
expval(PauliZ): 1
"""
from .error import AlgorithmicError, ErrorOperation, SpectralNormError
from .resource import (
Resources,
ResourcesOperation,
SpecsResources,
CircuitSpecs,
add_in_series,
add_in_parallel,
mul_in_series,
mul_in_parallel,
resources_from_tape,
substitute,
)
from .specs import specs
Expand Down
Loading