Skip to content

enforce qaoa and noise as "tertiary" modules #7266

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

Open
wants to merge 12 commits into
base: fix-optimize-dep
Choose a base branch
from

Conversation

andrijapau
Copy link
Contributor

@andrijapau andrijapau commented Apr 11, 2025

Context:

The goal of this PR is to isolate the noise and qaoa module as tertiary modules.

Description of the Change:

  • Removes all top-level imports, import pennylane as qml from this module.
  • Cleans up useless pylint disables.
  • Makes I alias accessible at the ops module level (required to remove qml dependency in noise)

Benefits: Module dependency enforcement

Possible Drawbacks: N/A

[sc-88858]

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.

@andrijapau andrijapau changed the title enforce pennylane.qaoa as an "tertiary" moduloe enforce pennylane.qaoa as an "tertiary" module Apr 11, 2025
@andrijapau andrijapau changed the title enforce pennylane.qaoa as an "tertiary" module enforce qaoa and noise as "tertiary" modules Apr 11, 2025
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.64%. Comparing base (6ca0253) to head (e35b6ce).

Additional details and impacted files
@@                Coverage Diff                @@
##           fix-optimize-dep    #7266   +/-   ##
=================================================
  Coverage             99.64%   99.64%           
=================================================
  Files                   512      512           
  Lines                 50219    50227    +8     
=================================================
+ Hits                  50041    50049    +8     
  Misses                  178      178           

☔ 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.

Copy link
Contributor

@JerryChen97 JerryChen97 left a comment

Choose a reason for hiding this comment

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

Let's start debugging Sphinx with the ":func:~.cycle_mixer" in line607 of cost.py

@JerryChen97
Copy link
Contributor

Maybe :func:~pennylane.qaoa.cycle.cycle_mixer ?

@andrijapau
Copy link
Contributor Author

Maybe :func:~pennylane.qaoa.cycle.cycle_mixer ?

Let me first try fixing the __init__.py file. lol

@JerryChen97
Copy link
Contributor

Compared with previous warnings are they different here:

/github/workspace/doc/code/qml_qaoa.rst.rst:24: WARNING: autosummary: stub file not found 'pennylane.qaoa.mixers.prod'. Check your autosummary_generate setting.
/github/workspace/doc/code/qml_qaoa.rst.rst:41: WARNING: autosummary: stub file not found 'pennylane.qaoa.cost.bit_flip_mixer'. Check your autosummary_generate setting.
/github/workspace/doc/code/qml_qaoa.rst.rst:41: WARNING: autosummary: stub file not found 'pennylane.qaoa.cost.cycle_mixer'. Check your autosummary_generate setting.
/github/workspace/doc/code/qml_qaoa.rst.rst:41: WARNING: autosummary: stub file not found 'pennylane.qaoa.cost.loss_hamiltonian'. Check your autosummary_generate setting.
/github/workspace/doc/code/qml_qaoa.rst.rst:41: WARNING: autosummary: stub file not found 'pennylane.qaoa.cost.net_flow_constraint'. Check your autosummary_generate setting.
/github/workspace/doc/code/qml_qaoa.rst.rst:41: WARNING: autosummary: stub file not found 'pennylane.qaoa.cost.out_flow_constraint'. Check your autosummary_generate setting.
/github/workspace/doc/code/qml_qaoa.rst.rst:41: WARNING: autosummary: stub file not found 'pennylane.qaoa.cost.wires_to_edges'. Check your autosummary_generate setting.
/github/workspace/doc/code/qml_qaoa.rst.rst:41: WARNING: autosummary: stub file not found 'pennylane.qaoa.cost.x_mixer'. Check your autosummary_generate setting.

@JerryChen97
Copy link
Contributor

Looks like the same. Sphinx is still recognizing those class as all in the same local file

@andrijapau
Copy link
Contributor Author

Looks like the same. Sphinx is still recognizing those class as all in the same local file

Why is prod here 🫠

image

@andrijapau andrijapau marked this pull request as draft April 11, 2025 19:50
@JerryChen97
Copy link
Contributor

It's annoying that we still don't have Sphinx trigger for drafts 😢

@andrijapau
Copy link
Contributor Author

It's annoying that we still don't have Sphinx trigger for drafts 😢

yeah lol, first im going to fix the docs landing page then go from there

@JerryChen97
Copy link
Contributor

Starting from line 1397 massive warnings... https://github.com/PennyLaneAI/pennylane/actions/runs/14411333479/job/40419734554?pr=7266

@andrijapau andrijapau added the do not merge ⚠️ Do not merge the pull request until this label is removed label Apr 11, 2025
@andrijapau andrijapau marked this pull request as ready for review April 11, 2025 20:52
from pennylane.templates import ControlledSequence
from pennylane.wires import WireError, Wires

# pylint: disable = unnecessary-lambda, too-few-public-methods, too-many-statements, too-many-branches
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Contributor

@albi3ro albi3ro Apr 14, 2025

Choose a reason for hiding this comment

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

I decided to try and investigate the too-many-branches 😨 I should know better by now.

Comment on lines +24 to +53
from pennylane.measurements import (
ClassicalShadowMP,
CountsMP,
DensityMatrixMP,
ExpectationMP,
MeasurementProcess,
MeasurementValue,
MidMeasureMP,
MutualInfoMP,
ProbabilityMP,
PurityMP,
SampleMP,
ShadowExpvalMP,
StateMP,
VarianceMP,
VnEntropyMP,
classical_shadow,
counts,
density_matrix,
expval,
measure,
mutual_info,
probs,
purity,
sample,
shadow_expval,
state,
var,
vn_entropy,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to not use just import pennylane import measurements here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge ⚠️ Do not merge the pull request until this label is removed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants