[WIP Do not review yet] Support modern uv project management (uv init + uv add)#3474
Draft
igorts-git wants to merge 1 commit intomainfrom
Draft
[WIP Do not review yet] Support modern uv project management (uv init + uv add)#3474igorts-git wants to merge 1 commit intomainfrom
igorts-git wants to merge 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Update MaxText installation scripts to detect 'uv.lock' and use 'uv add --frozen'. - Consolidate uv detection and installation logic into a shared 'uv_utils.py' module. - Improve uv detection robustness by prioritizing 'python -m uv' and path lookup. - Update docs/install_maxtext.md with modern uv workflow instructions and fix outdated paths. - Fix macOS installation by dynamically skipping legacy MaxText directory.
d04ab05 to
902af4e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Objective
Enable users to use MaxText seamlessly within their own
uv-managed projects. Previously, MaxText's installation scripts relied exclusively onuv pip install, which does not update a project'spyproject.tomloruv.lock. This PR introduces automatic detection ofuvprojects and usesuv addto correctly track "extra" dependencies (like GitHub-based requirements) when applicable.Background
There is a modern uv usage mode that is different from the traditional uv pip install flow.
The new mode requires
uv initanduv addcommands instead ofuv pip install.This PR makes it compatible with the new flow.
Key changes:
uv.lockDetection: Added logic toinstall_pre_train_deps.py,install_post_train_deps.py, andsetup.shto check for the presence of auv.lockfile in the current working directory.uv addIntegration:uvproject is detected, the scripts now useuv add --frozen -r <requirements>to add extra dependencies to the user'spyproject.toml.--frozenflag is used to ensure that only the requested dependencies are added/updated without triggering a full environment resolution/sync, which is critical given MaxText's complex optional dependency tree.uv pip installworkflow as a fallback for standard virtual environments, Docker builds, and MaxText development.docs/install_maxtext.mdwith instructions for the modernuvworkflow and corrected several outdated paths and command names.Pair-programmed with Gemini-CLI.
FIXES: #3441
Tests
1. Build a new Wheel
To verify that the package metadata and entry points are correctly defined:
2. Verify Legacy Installation (
uv pip install)Ensures no regressions for existing users:
3. Verify Modern Installation (
uv add)Tests the new project management workflow:
4. Local Smoke Training
Verify that the installed environment is functional:
# Run a short smoke test training python3 -m MaxText.train MaxText/configs/base.yml \ run_name=test_smoke \ base_output_directory=/tmp/maxtext_test \ dataset_type=synthetic \ steps=5 \ enable_checkpointing=False \ enable_goodput_recording=False5. Docker Image Validation
Verify that Docker builds still work correctly and produce consistent results:
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.