Skip to content

Conversation

@jzaia18
Copy link
Contributor

@jzaia18 jzaia18 commented Nov 6, 2025

Context:
For code compiled using Catalyst, the only currently supported level argument is level="device" which does runtime resource tracking. Since users may specify compilation passes that get applied to their code, it would be useful to support intermediate levels between the user-specified program and the final execution.

Description of the Change:
Introduces several other legal levels:

  • Any int, will return information about the compiler pass or tape transform at that level (starting from 0)
  • A str marker, returns information about the level where this marker is defined
  • Iterable of a mix of the 2 prior options, gets specs for each specfied level
  • "all", returns information about all compiler passes and tape transforms
  • "all-mlir", returns information about only compiler passes (and not tape transforms)

Benefits:
It is possible to learn gather information about the circuit during several/after various compilation levels

Possible Drawbacks:
Increased complexity of qml.specs

Related GitHub Issues:
[sc-104118]
Relies upon a Catalyst utility added in PennyLaneAI/catalyst#2238
Integration tests for these new features are added in PennyLaneAI/catalyst#2272

@jzaia18 jzaia18 self-assigned this Nov 6, 2025
@jzaia18 jzaia18 added WIP 🚧 Work-in-progress do not merge ⚠️ Do not merge the pull request until this label is removed labels Nov 6, 2025
@jzaia18 jzaia18 marked this pull request as draft November 6, 2025 22:55
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

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.

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.

Thanks Jake, the PR looks good to me from a technical standpoint. You have a soft approval from me - I'd like the testing PR in Catalyst to be approved before this one is approved.

@jzaia18 jzaia18 requested a review from isaacdevlugt December 12, 2025 22:09
Copy link
Contributor

@isaacdevlugt isaacdevlugt left a comment

Choose a reason for hiding this comment

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

Thanks Jake this looks great overall! Made some minor suggestions but this is ready 🚢

about the circuit after applying the specified transforms, expansions, and/or compilation passes.
Args:
qnode (.QNode | .QJIT): the QNode to calculate the specifications for.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the .<class name> convention something we follow elsewhere?

Some resource information from pass-by-pass specs may be estimated, since it is not always
possible to determine exact resource usage from intermediate representations.
For example, resources contained in a ``for`` loop with a non-static range or a ``while`` loop will only be counted as if one iteration occurred.
Additionally, resources contained in conditional branches from ``if`` or ``switch`` statements will take a union of resources over all branches, providing a tight upper-bound.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it the union of all resources, or the most expensive branch that is chosen?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also stick this warning up a bit higher. Right between these two lines:

        a real device.

        .. code-block:: python

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.

5 participants