Skip to content

Support PBC Depth within SpecsResources#9703

Open
jzaia18 wants to merge 5 commits into
mainfrom
feature/pbc-specs
Open

Support PBC Depth within SpecsResources#9703
jzaia18 wants to merge 5 commits into
mainfrom
feature/pbc-specs

Conversation

@jzaia18

@jzaia18 jzaia18 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Context:
PennyLaneAI/catalyst#2967 adds support for some PBC-related fields to the resource analysis output. As a temporary measure, PBC depth fields will be added to SpecsResources. This work is related to the frontend integration of ppm_specs

Description of the Change:
Adds an optional pbc_depth field to SpecsResources. This field is either None (in most cases, and therefore hidden) or a tuple of the depth-0 and depth-1 related to the PPMs & PPRs in the circuit's IR.

Benefits:
Allows PBC depth info to be displayed to end users, which is useful to some internal researchers.

Possible Drawbacks:
These fields are not used in most cases and should not live in this class long term. This adds tech debt that we will have to repay some time next quarter when we restructure the resource class hierarchy.

Related GitHub Issues:
[sc-122858]

@jzaia18 jzaia18 self-assigned this Jun 18, 2026
@github-actions

Copy link
Copy Markdown
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.

@jzaia18 jzaia18 requested review from AntonNI8 and sengthai June 18, 2026 22:00
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.45%. Comparing base (5f2a71c) to head (d63e5d2).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pennylane/resource/resource.py 76.66% 7 Missing ⚠️
pennylane/resource/mlir_specs.py 64.28% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9703      +/-   ##
==========================================
- Coverage   99.47%   99.45%   -0.02%     
==========================================
  Files         629      629              
  Lines       69155    69197      +42     
==========================================
+ Hits        68789    68818      +29     
- Misses        366      379      +13     

☔ View full report in Codecov by Harness.
📢 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.

@sengthai sengthai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @jzaia18 for PR!

depth_str = (
_count_to_str(self.depth, markdown_safe=True)
if self.depth is not None
else "Not computed"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For non-pbc circuit, do we need to show PBC depth as well? it seems we return "Not computed".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's for ordinary circuit depth, not PBC depth

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can add a comment to make this clearer in the code

Comment on lines +127 to +129
if depths := resources.get("pbc_depth"):
if "depth_0" in depths and "depth_1" in depths:
pbc_depth = (depths["depth_0"], depths["depth_1"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I briefly brought this up on slack, but would it make sense to frame these more generally?

I wonder if we could make the labels a bit more descriptive, for instance Depth-any-comm, Depth-qw-comm, or similar.

The (PBC) header could also be removed if we wanted a single section for all our depth metrics, and perhaps others in the future. The qubit-wise commutativity depth for instance is not exclusive to the PBC model, one could compute it on regular gate circuits as well.

Maybe the depth labels themselves can be grabbed from the resource data, and we don't have to assume that these are PBC specific?

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.

3 participants