feat: add megatron-bridge as dependency #3
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
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Generate UV Lockfile | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| pull_request: | |
| paths: | |
| - 'pyproject.toml' | |
| jobs: | |
| generate-lockfile: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: nvcr.io/nvidia/pytorch:25.09-py3 | |
| steps: | |
| - name: Install git | |
| run: | | |
| apt-get update | |
| apt-get install -y git | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up environment | |
| run: | | |
| echo "UV_PROJECT_ENVIRONMENT=/opt/venv" >> $GITHUB_ENV | |
| echo "VIRTUAL_ENV=/opt/venv" >> $GITHUB_ENV | |
| echo "UV_LINK_MODE=copy" >> $GITHUB_ENV | |
| echo "CUDA_HOME=/usr/local/cuda" >> $GITHUB_ENV | |
| echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
| echo "$HOME/.local/bin:$PATH:$CUDA_HOME/bin" >> $GITHUB_PATH | |
| echo "CUDACXX=/usr/local/cuda/bin/nvcc" >> $GITHUB_ENV | |
| echo "TORCH_CUDA_ARCH_LIST=6.0;6.1;7.0;7.5;8.0;8.6;9.0" >> $GITHUB_ENV | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/0.8.22/install.sh | sh | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| - name: Create virtual environment | |
| run: | | |
| uv venv ${UV_PROJECT_ENVIRONMENT} --system-site-packages | |
| - name: Install build dependencies | |
| run: | | |
| uv pip install setuptools torch packaging ninja pybind11 Cython "numpy<2.0.0" | |
| - name: Generate lockfile | |
| run: | | |
| uv lock | |
| - name: Upload lockfile artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: uv-lockfile | |
| path: uv.lock | |
| retention-days: 7 | |
| - name: Check for lockfile changes | |
| id: check_changes | |
| run: | | |
| if git diff --quiet uv.lock; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit lockfile (if changed) | |
| if: steps.check_changes.outputs.changed == 'true' && github.event_name == 'workflow_dispatch' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add uv.lock | |
| git commit -m "Update uv.lock [skip ci]" | |
| git push | |
| - name: Comment on PR with lockfile status | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const changed = '${{ steps.check_changes.outputs.changed }}'; | |
| const message = changed === 'true' | |
| ? '⚠️ **uv.lock needs to be regenerated**\n\nThe lockfile is out of sync with pyproject.toml. Please run the "Generate UV Lockfile" workflow manually or regenerate locally on Linux.' | |
| : '✅ **uv.lock is up to date**\n\nThe lockfile is in sync with pyproject.toml.'; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: message | |
| }); |