Skip to content

Add an option to make frontend for not unintalling current environment's PL#2914

Open
paul0403 wants to merge 3 commits into
mainfrom
make_frontend_opt_nouninstallPL
Open

Add an option to make frontend for not unintalling current environment's PL#2914
paul0403 wants to merge 3 commits into
mainfrom
make_frontend_opt_nouninstallPL

Conversation

@paul0403

@paul0403 paul0403 commented Jun 4, 2026

Copy link
Copy Markdown
Member

Context:
During development, it is often the case that people will need their local environment to be on a specific PennyLane branch, instead of a nightly package on testpypi. In these cases, make frontend uninstalling the environment's current PL is very frustrating.

Description of the Change:
Add an option to make frontend to keep the local environment's current PL package.

Benefits:
Better development experience.

@paul0403 paul0403 requested review from a team and mudit2812 June 4, 2026 15:13
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md on your branch 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.

@paul0403

paul0403 commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

No changelog needed for build system

@paul0403 paul0403 requested a review from lillian542 June 4, 2026 15:15

@kipawaa kipawaa 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.

❤️

@JerryChen97 JerryChen97 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.

😻 greaaaat

Comment thread Makefile
OQC_BUILD_DIR ?= $(MK_DIR)/frontend/catalyst/third_party/oqc/src/build
ENZYME_BUILD_DIR ?= $(MK_DIR)/mlir/Enzyme/build
COVERAGE_REPORT ?= term-missing
UNINSTALL_PL ?= ON

@dime10 dime10 Jun 4, 2026

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 for adding this! Slightly clearer naming might be the following, because uninstall sounds like we might plain remove it?

Suggested change
UNINSTALL_PL ?= ON
FORCE_PL_INSTALL ?= ON

Comment thread Makefile
$(PYTHON) -m pip uninstall -y pennylane
$(PYTHON) -m pip install -e . --extra-index-url https://test.pypi.org/simple $(PIP_VERBOSE_FLAG)
else
$(PYTHON) -m pip install -e . --no-deps

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mudit2812 I tried locally, setup.py will still overwrite specific PL branch.

Say the current .dep-versions uses PL version dev10. So we have a couple cases:

  • The developer's PL branch is less than dev10. In these cases, setup.py will still uninstall and bump it up to dev10 on testpypi.
  • The developer's PL is >= dev10, in which case it is kept, and setup.py does nothing.

If we use --no-deps like I did here, we guarantee that the uninstall absolutely does not happen, but this does assume make frontend is only run after pip install -r requirements.txt. I do think this is a fair assumption, since this is the recommendation in the build guide.

However, I see the other side too: if a PL branch is too old, it should probably be forwarded by the dev.

What do you think?

@dime10 dime10 Jun 4, 2026

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.

Yeah now that I think about it, the uninstall step merely forces picking up the exact PL version required by Catalyst when the installed package already has the same version tag (sometimes this happens, same tag, but different code). Disabling this does not affect the case where the installed PL version has a different tag, in which case pip will still look for the one provided by catalyst.

The only way around that that I know is --no-deps, we can do that but you can't assume just because requirement.txt was installed that we don't need the deps declared by the Catalyst package. In our setup, requirements.txt are build-time requirements, which are not the same as runtime requirements. Not installing the latter could lead to wonky configurations (e.g. a wrong lightning install, missing xdsl or malt package, etc.).

Of course if you know what you're doing you can proceed at your own risk, but you don't need a separate flag for that tbh, just run pip install -e . --no-deps.

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 had a discussion with @dime10 , and the two most favourable solutions seemed to be the following:

  • Just add a note to the build from source guide saying that make frontend deletes the local installation of PennyLane and it must be reinstalled if needed.
  • Update the implementation of the new flag to look for a preinstalled version of pennylane (using pip list) and then restoring it after installing Catalyst. This one is a bit more complicated, but may provide a better UX

Comment thread Makefile
OQC_BUILD_DIR ?= $(MK_DIR)/frontend/catalyst/third_party/oqc/src/build
ENZYME_BUILD_DIR ?= $(MK_DIR)/mlir/Enzyme/build
COVERAGE_REPORT ?= term-missing
UNINSTALL_PL ?= ON

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add a description and update the help command?

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.

6 participants