Migrate from pip to uv for dependency management#188
Merged
speediedan merged 7 commits intomainfrom Nov 14, 2025
Merged
Conversation
…interface - Replace custom regen_reqfiles.py with simple lock_ci_requirements.sh - Consolidate all dependencies in pyproject.toml using PEP 735 groups - Simplify CI installation to 2-step process (editable + locked reqs) - auto-register config classes as safe globals for PyTorch checkpoint unpickling - Update documentation (README, copilot-instructions) with new install flows - Update Makefile docs target to use --group docs - Remove obsolete requirements files (base.txt, devel.txt, docs.txt, etc.) - Update dev infra scripts and CI workflows for uv pip interface This improves installation speed, reliability, and maintainability while preserving all existing functionality.
…egression for AnalysisStoreProtocol, remove deprecated used of pkg_resources
|
regen-ci-req-check detected changes to pinned CI requirements and uploaded a patch artifact named 'regen-pins-diff'. Top changes:
Please review the artifact and CI results. This workflow is report-only and will not open a PR; the scheduled regen workflow will open PRs automatically. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR migrates Interpretune from pip-based dependency management to uv, a modern, fast Python package installer. The migration simplifies dependency management, improves installation speed (10-100x faster), and enhances reproducibility across development and CI environments.
Key Changes:
- Replaced custom Python script (
regen_reqfiles.py) with simple shell script (lock_ci_requirements.sh) usinguv pip compile - Migrated from deprecated
pkg_resourcestoimportlib.metadatafor version checking - Introduced PEP 735 dependency groups in
pyproject.tomlfor better organization - Updated PyTorch checkpoint loading to handle
weights_only=Truewith automatic class registration - Simplified CI/CD workflows to 2-step installation: editable install + locked requirements
- Enhanced build scripts with support for multiple from-source packages and flexible venv placement
Reviewed Changes
Copilot reviewed 43 out of 46 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/warns.py, tests/runif.py | Migrated from pkg_resources to importlib.metadata for version checking |
| tests/core/test_regen_reqfiles.py | Deleted (no longer needed with uv-based locking) |
| src/it_examples/utils/raw_graph_analysis*.py | Fixed attribute name (logit_tokens → logit_token_ids), commented out incomplete example |
| src/interpretune/utils/logging.py | Added safety check for pip_packages parsing |
| src/interpretune/utils/import_utils.py | Migrated from pkg_resources to importlib.metadata |
| src/interpretune/protocol.py | Narrowed StrOrPath type, added PathLike back to AnalysisStoreProtocol |
| src/interpretune/config/shared.py | Added auto-registration of config classes for PyTorch safe pickle loading |
| src/interpretune/analysis/core.py | Updated type hints to include os.PathLike |
| scripts/infra_utils.sh | Added utility functions for venv management and from-source package parsing |
| scripts/gen_it_coverage.sh | Updated to use new from-source specification format |
| scripts/build_it_env.sh | Rewritten to use uv with 3-step installation flow |
| requirements/utils/lock_ci_requirements.sh | New shell script replacing Python-based regeneration |
| requirements/utils/regen_reqfiles.py | Deleted (replaced by lock_ci_requirements.sh) |
| requirements/*.txt | Deleted individual requirement files (consolidated in pyproject.toml) |
| requirements/ci/requirements.txt | Updated to uv-generated lock file with 799 lines |
| requirements/ci/*.txt (other files) | Deleted (no longer needed with uv) |
| pyproject.toml | Reorganized dependencies into PEP 735 dependency groups |
| dockers/* | Updated PyTorch version to 2.9.1, migrated from pip to uv |
| README.md | Added comprehensive installation documentation |
| Makefile | Updated to use uv and removed obsolete environment variables |
| .gitignore | Added .python-version for uv |
| .github/workflows/* | Updated CI workflows to use uv with 2-step installation |
| .github/copilot-instructions.md | Updated with comprehensive uv-based workflows |
| .github/actions/* | Updated actions to use uv and simplified installation |
| .azure-pipelines/gpu-tests.yml | Aligned with GitHub Actions uv-based installation |
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.
Overview
This PR migrates Interpretune from pip-based dependency management to uv, a modern, fast Python package installer. This migration improves installation speed, reliability, and reproducibility across development and CI environments.
Key Changes
1. Dependency Management Migration
Before: Multiple requirements files managed by custom
regen_reqfiles.pyscriptrequirements/ci/requirements.in+ various constraint filesrequirements/ci/platform_dependent.txtrequirements/ci/post_upgrades.txtrequirements/ci/circuit_tracer_pin.txtrequirements/docs.txtAfter: Centralized dependency specification in
pyproject.tomlwith UV-based lockingpyproject.tomlusing PEP 735 dependency groupsrequirements/utils/lock_ci_requirements.shfor generating locked requirementsgit-depsgroup (UV doesn't support URLs in universal lock files)requirements/ci/requirements.txtfor CI reproducibility2. Installation Flow Simplification
CI Installation (2 steps):
Development Installation (single command):
uv pip install -e ".[test,examples,lightning,profiling]" --group git-deps devAdvanced Development (with from-source packages):
3. Dependency Groups (PEP 735)
Organized dependencies into logical groups in pyproject.toml:
git-deps: Git URL dependencies (circuit-tracer) - installed separately from locked requirementsdev: Core development tools (uv, pre-commit, pyright)test: Testing framework and tools (pytest, coverage, etc.)profiling: Performance profiling tools (py-spy)4. PyTorch
weights_onlycheckpoint Compatibility FixesIssue: with
weights_only=Truefor checkpoint loading now requires explicit allowlisting of classes for safe unpickling.Solution: Auto-register all config classes and Path types as safe globals:
__init_subclass__toITSerializableCfgbase classtorch.serialization.add_safe_globals()pathlib.PosixPathandpathlib.WindowsPathto allow Path objects in serialized configsFiles Modified:
Path | strinstead of restricting tostr5. Build Script Improvements
build_it_env.sh:
lock_ci_requirements.sh:
uv pip compile6. CI/CD Updates
GitHub Actions:
uv runprefixes (environment pre-activated)--group devinstead of listing packagesAzure Pipelines:
7. Documentation Updates
README.md:
.github/copilot-instructions.md:
Makefile:
uv pip install --group docsinstead of docs.txt8. Type System Improvements
StrOrPathType Alias:Union[str, PathLike, Path]toUnion[str, Path]PathLikeobjects in practice)Files Deleted
requirements/ci/requirements.inrequirements/ci/platform_dependent.txtrequirements/ci/post_upgrades.txtrequirements/ci/circuit_tracer_pin.txtrequirements/utils/regen_reqfiles.pytests/core/test_regen_reqfiles.pyFiles Added
requirements/ci/requirements.txtuv.lock(UV's lock file, not committed but may be generated locally)Testing
Performance Improvements
Migration Impact
Breaking Changes: None for end users
Developer Impact:
Next Steps
After this PR merges: