Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize execution interfaces by adding internal Enum object #6643

Merged
merged 202 commits into from
Dec 5, 2024

Conversation

andrijapau
Copy link
Contributor

@andrijapau andrijapau commented Nov 27, 2024

Context:

This is a follow-up to #6649.

The purpose of this PR is to standardize how the interface value is handled, preventing it from being remapped multiple times during execution. Users should provide their preferred interface, which will be mapped directly to a canonical value for consistent use. If the interface is set to "auto", it will be inferred from the data type and converted into a supported canonical interface. This inferred interface value will then be used to configure the execution later down the pipeline.

Description of the Change:

  • Updated qnode.py and execution.py to use a new canonical interface Enum.
  • Modified tests that previously expected interface to be a string in parts of the code where it is now represented as an enum value.
  • Removed support for interface=None. Instead, the default interface is now explicitly set to numpy.
  • Adjusted execution config to store only the canonical interface value.

Benefits:

  • Enhances code testability.
  • Resolves ambiguities in how the interface value is handled during execution.

Possible Drawbacks: None identified.

[sc-73432]
[sc-79735]

@andrijapau andrijapau changed the title [WIP] Add internal Enum to standarize execution interfaces Add internal Enum to standarize execution interfaces Dec 4, 2024
pennylane/workflow/qnode.py Outdated Show resolved Hide resolved
@andrijapau andrijapau requested a review from albi3ro December 5, 2024 02:24
@albi3ro
Copy link
Contributor

albi3ro commented Dec 5, 2024

I believe this now also satisfies [sc-51194]

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.

❤️

Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

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

So neat and tidy! 🧹

pennylane/math/interface_utils.py Outdated Show resolved Hide resolved
@andrijapau andrijapau changed the title Add internal Enum to standarize execution interfaces Standardize execution interfaces by adding internal Enum object Dec 5, 2024
@andrijapau andrijapau merged commit 6b20437 into master Dec 5, 2024
46 checks passed
@andrijapau andrijapau deleted the add-interface-enum branch December 5, 2024 20:45
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