Skip to content

Conversation

@jzaia18
Copy link
Contributor

@jzaia18 jzaia18 commented Nov 28, 2025

Context:
qml.specs makes very few guarantees on the shape of its output. This PR aims to make a single unified out type for qml.specs, which contains all of (and only) the information needed for circuit inspection.

Description of the Change:

  • Introduces new SpecsResources and CircuitSpecs classes
  • Refactors various specs functions throughout PennyLane to make use of the new classes
  • Updates _count_resources to use the Catalyst-style resource names for multi-controlled gates. e.g. a 10-controlled IsingXX is now shown as 10C(IsingXX) and no longer just C(IsingXX). This matches how resources are counted in Catalyst.

Benefits:
Cleaner and more consistent specs returns.

Happens to also fix #8048

Possible Drawbacks:
Introduces another "resources" object into PennyLane. A followup PR should restructure these PRs such that all of them inherit from a common base class.

Removes some information which used to be included in qml.specs, such as num_observables (now migrated into the resources' measurements) or various gradient information.

Related GitHub Issues:
[sc-104965]
#8048

@jzaia18 jzaia18 requested a review from AntonNI8 November 28, 2025 23:10
@jzaia18 jzaia18 self-assigned this Nov 28, 2025
@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.37%. Comparing base (0e7bedd) to head (7e3809b).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8713      +/-   ##
==========================================
- Coverage   99.37%   99.37%   -0.01%     
==========================================
  Files         589      589              
  Lines       62830    62929      +99     
==========================================
+ Hits        62437    62534      +97     
- Misses        393      395       +2     

☔ 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 requested a review from albi3ro December 8, 2025 16:57
@jzaia18
Copy link
Contributor Author

jzaia18 commented Dec 8, 2025

Just a heads up that I'll also need reviews on this follow-up PR which fixes the specs integration tests in Catalyst: PennyLaneAI/catalyst#2255 . These tests will begin to fail as soon as the changes from this PR are used with Catalyst (requires a change to the manual pin)

@jzaia18 jzaia18 requested a review from albi3ro December 8, 2025 18:54
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

So excited to have this in! I've actually wanted something like this for a while, so quite happy to have something like this now.

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Looks great @jzaia18 .

Introduces another "resources" object into PennyLane. A followup PR should restructure these PRs such that all of them inherit from a common base class.

Is there already a story for this? If not, could you please add one?

@jzaia18
Copy link
Contributor Author

jzaia18 commented Dec 8, 2025

Is there already a story for this? If not, could you please add one?

Not sure about a story, but I think there's a whole epic for it planned for Q1, it's in the technical roadmap

@jzaia18 jzaia18 added this pull request to the merge queue Dec 9, 2025
Merged via the queue into master with commit f28334e Dec 9, 2025
56 of 57 checks passed
@jzaia18 jzaia18 deleted the chore/specs-outputs branch December 9, 2025 15:37
jzaia18 added a commit to PennyLaneAI/catalyst that referenced this pull request Dec 9, 2025
**Context:**
[This PR](PennyLaneAI/pennylane#8713) in
PennyLane changes how `qml.specs` returns its results. This will break
some integration tests within Catalyst.

**Description of the Change:**
Updates tests within `frontend/test/pytest/test_specs.py` to account for
the new `qml.specs` output format.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
PennyLaneAI/pennylane#8713
[sc-104965]

---------

Co-authored-by: Mudit Pandey <[email protected]>
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.

[BUG] Transforms are applied repeatedly with qml.specs

5 participants