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

Update tutorial_qnn_module_tf after the deprecation of qml.qnn.KerasLayer #1334

Merged
merged 36 commits into from
Apr 1, 2025

Conversation

JerryChen97
Copy link
Contributor

@JerryChen97 JerryChen97 commented Mar 20, 2025

Context:
KerasLayer has been already deprecated in PennyLane master branch (see PennyLaneAI/pennylane#7097). This PR updates the tutorial_qnn_module_tf demo that relies on KerasLayer in Keras2.

Summary:
Converted the mentioned demo into non-executable. As a result, the following changes to output were made:

  • Uploaded our previous scatter plot figure into _static and show in the first output
  • Hardcoded the TF/Keras fitting output printing info as the second and third output
  • Removed those TF warnings that used to exist. Users shall still get these warnings printing if they run on their own

Added user warning on the top of tutorial_qnn_module_tf.

Inplace warning catchers for wherever the KerasLayer was used.

Relevant references:

Possible Drawbacks:

Related GitHub Issues:
[sc-86997]

If you are writing a demonstration, please answer these questions to facilitate the marketing process.

  • GOALS — Why are we working on this now?

    Eg. Promote a new PL feature or show a PL implementation of a recent paper.

  • AUDIENCE — Who is this for?

    Eg. Chemistry researchers, PL educators, beginners in quantum computing.

  • KEYWORDS — What words should be included in the marketing post?

  • Which of the following types of documentation is most similar to your file?
    (more details here)

  • Tutorial
  • Demo
  • How-to

Copy link

👋 Hey, looks like you've updated some demos!

🐘 Don't forget to update the dateOfLastModification in the associated metadata files so your changes are reflected in Glass Onion (search and recommendations).

Please hide this comment once the field(s) are updated. Thanks!

@JerryChen97 JerryChen97 changed the base branch from master to dev March 20, 2025 19:46
@JerryChen97 JerryChen97 self-assigned this Mar 20, 2025
@JerryChen97 JerryChen97 added the demos Updating the demonstrations/tutorials label Mar 20, 2025
@JerryChen97 JerryChen97 marked this pull request as ready for review March 20, 2025 19:51
Copy link

github-actions bot commented Mar 20, 2025

Thank you for opening this pull request.

You can find the built site at this link.

Deployment Info:

  • Pull Request ID: 1334
  • Deployment SHA: dcb612dea9c2c8c49ca6b6bd17177eb75b751a4d
    (The Deployment SHA refers to the latest commit hash the docs were built from)

Note: It may take several minutes for updates to this pull request to be reflected on the deployed site.

@JerryChen97 JerryChen97 changed the title Deprecate keras layer Update tutorial_qnn_module_tf after the deprecation of KerasLayer on PennyLane master branch Mar 20, 2025
@JerryChen97 JerryChen97 changed the title Update tutorial_qnn_module_tf after the deprecation of KerasLayer on PennyLane master branch Update tutorial_qnn_module_tf after the deprecation of qml.qnn.KerasLayer Mar 20, 2025
@josh146
Copy link
Member

josh146 commented Mar 20, 2025

Thanks @JerryChen97. Rather than making this demo catch warnings, let's make it non-executable (will need to add codeblocks to represent the output like other non-executable demos).

I've updated the warning in a comment to reflect this.

Co-authored-by: Josh Izaac <josh146@gmail.com>
@JerryChen97
Copy link
Contributor Author

Thanks @JerryChen97. Rather than making this demo catch warnings, let's make it non-executable (will need to add codeblocks to represent the output like other non-executable demos).

I've updated the warning in a comment to reflect this.

@josh146 I am checking how_to_catalyst_lightning_gpu.py as example. Is this a good reference for our purpose?

@JerryChen97
Copy link
Contributor Author

JerryChen97 commented Mar 20, 2025

This demo has three actual outputs.
Two are numbers (used to be followed by bunch of TF warnings)
One is the plt scatter plot.
I plan to hard code the two numbers, and upload the current official figure to our static resource to refer to later

JerryChen97 and others added 2 commits March 20, 2025 18:15
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
@JerryChen97

This comment was marked as resolved.

Copy link
Contributor

@PietropaoloFrisoni PietropaoloFrisoni left a comment

Choose a reason for hiding this comment

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

Thanks a lot Yushao! Hopefully this will fix the dev branch before the release 👍

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.

Can we uncomment the code now?

Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
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.

Thanks for the updates.

@JerryChen97 JerryChen97 enabled auto-merge (squash) April 1, 2025 14:02
@JerryChen97 JerryChen97 merged commit e562b0e into dev Apr 1, 2025
10 checks passed
@JerryChen97 JerryChen97 deleted the Deprecate-KerasLayer branch April 1, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demos Updating the demonstrations/tutorials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants