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

Build with uv instead of just pip #1324

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

jennifgcrl
Copy link
Contributor

@jennifgcrl jennifgcrl commented Nov 8, 2024

Description

Fixes #1323

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refractor

Changes

Please list the changes introduced in this PR:

  • build_tools picks uv or python -m pip depending on if pip exists or not
  • additional install_and_imports for uv's clean build environments

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Signed-off-by: Jennifer Zhou <[email protected]>
Copy link
Collaborator

@timmoon10 timmoon10 left a comment

Choose a reason for hiding this comment

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

uv looks neat, but I'm uncomfortable hard-coding like this until it has wider adoption.

I've written up my thoughts on the root problems at #1323 (comment). I think the best approach for now is to adopt your changes to uninstall_te_wheel_packages and to build TE with build isolation disabled. uv should support this (astral-sh/uv#1715).

As an aside, I agree with @Taytay's assessment that build isolation is not a good fit for the ML ecosystem since it depends on custom, vendor-provided packages that are tricky to install. It's annoying the lengths that the Python developers went to to coerce package maintainers to use build isolation.

Comment on lines 312 to +319
def uninstall_te_wheel_packages():
subprocess.check_call(
[
sys.executable,
"-m",
"pip",
"uninstall",
"-y",
"transformer_engine_cu12",
"transformer_engine_torch",
"transformer_engine_paddle",
"transformer_engine_jax",
]
)
if find_spec("pip") is not None:
subprocess.check_call(
[
sys.executable,
"-m",
"pip",
"uninstall",
"-y",
"transformer_engine_cu12",
"transformer_engine_torch",
"transformer_engine_paddle",
"transformer_engine_jax",
]
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a reasonable change that I would accept on its own. It doesn't fully solve the root issue (the package structure is different when installing from PyPI or from source), so I could imagine users running into problems if they install TE multiple times. But it seems fair to expect users to handle this on their own if they are using a non-standard build environment.

)

install_and_import("pybind11[global]")
Copy link
Member

Choose a reason for hiding this comment

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

This installation should be guarded depending on which framework the extensions are being built for

@jennifgcrl
Copy link
Contributor Author

@timmoon10 Thanks for looking into this! I've updated the PR to be just the uninstall_te_wheel_packages change.

I think it's easier for me to just maintain a fork than --no-build-isolation since (as far as I can tell) there's no way to tell rye to pass --no-build-isolation to uv.

Do you think we can (for the time being) support both build isolation and no build isolation? One way this might work is: if NVTE_FRAMEWORK contains frameworks that aren't in the current python environment, try installing them; otherwise use the existing package.

@jennifgcrl jennifgcrl requested a review from timmoon10 November 9, 2024 05:49
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.

TransformerEngine doesn't work with uv
3 participants