Skip to content

Commit 749a321

Browse files
authored
Merge pull request #82 from apoorvkh/uv-v2
Switching to uv (attempt 2)
2 parents 610c874 + 107e667 commit 749a321

File tree

10 files changed

+1667
-2447
lines changed

10 files changed

+1667
-2447
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,21 @@ on:
99

1010
jobs:
1111

12-
check:
12+
checks:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: prefix-dev/setup-[email protected]
16+
- uses: astral-sh/setup-[email protected]
1717
with:
18-
pixi-version: v0.27.1
19-
frozen: true
20-
cache: true
21-
environments: dev
22-
activate-environment: dev
23-
- run: ruff check
18+
version: "0.5.0"
19+
python-version-file: ".python-version"
20+
enable-cache: true
21+
- run: uv sync
22+
- run: uv run --frozen ruff check
2423
if: success() || failure()
25-
- run: ruff format --check
24+
- run: uv run --frozen ruff format --check
2625
if: success() || failure()
27-
28-
##
29-
30-
typecheck:
31-
runs-on: ubuntu-latest
32-
steps:
33-
- uses: actions/checkout@v4
34-
- uses: prefix-dev/[email protected]
35-
with:
36-
pixi-version: v0.27.1
37-
frozen: true
38-
cache: true
39-
environments: extra
40-
activate-environment: extra
41-
- run: pyright
26+
- run: uv run --frozen pyright
4227
if: success() || failure()
4328

4429
##
@@ -64,26 +49,16 @@ jobs:
6449
test:
6550
runs-on: ubuntu-latest
6651
needs: get-pytorch-versions
67-
strategy:
52+
strategy:
6853
fail-fast: false
6954
matrix:
7055
python: ["3.9", "3.10", "3.11", "3.12"]
7156
pytorch: ${{fromJson(needs.get-pytorch-versions.outputs.versions)}}
72-
7357
steps:
7458
- uses: actions/checkout@v4
75-
76-
- name: Inject (python / pytorch) test deps into pixi.toml / pyproject.toml
77-
run: |
78-
sed -i 's/python = "3.9"/python = "${{ matrix.python }}.*"/' pixi.toml
79-
sed -i 's/torch>=2.0.0/torch~=${{ matrix.pytorch }}/' pyproject.toml
80-
81-
- uses: prefix-dev/[email protected]
59+
- uses: astral-sh/[email protected]
8260
with:
83-
pixi-version: v0.27.1
84-
locked: false
85-
frozen: false
86-
cache: false
87-
environments: default
88-
activate-environment: default
89-
- run: pytest tests/test_ci.py
61+
version: "0.5.0"
62+
- if: contains('2.0,2.1,2.2', matrix.pytorch)
63+
run: echo "NUMPY_VERSION=--with \"numpy<2\"" >> $GITHUB_ENV
64+
- run: uv run --python ${{ matrix.python }} --with torch~=${{ matrix.pytorch }} ${{ env.NUMPY_VERSION }} pytest --verbose tests/test_ci.py

.github/workflows/release.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12-
- uses: prefix-dev/setup-[email protected]
12+
- uses: astral-sh/setup-uv@v3
1313
with:
14-
pixi-version: v0.27.1
15-
frozen: true
16-
cache: true
17-
environments: dev
18-
activate-environment: dev
19-
- run: python -m build
20-
- run: twine upload dist/*
21-
env:
22-
TWINE_USERNAME: __token__
23-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
14+
version: "0.5.0"
15+
python-version-file: ".python-version"
16+
enable-cache: true
17+
- run: uv sync
18+
- run: uv build
19+
- run: uv publish

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.9.20

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Contributing
22

3-
We use the [`pixi`](https://pixi.sh) package manager. Simply [install `pixi`](https://pixi.sh/latest/#installation) and run `pixi shell` in this repository to activate the environment.
3+
We use the [`uv`](https://github.com/astral-sh/uv) package manager. Simply [install `uv`](https://github.com/astral-sh/uv#installation) and run `uv sync` in this repository to build the environment. Run `source .venv/bin/activate` to activate the environment.
44

55
We use `ruff check` for linting, `ruff format` for formatting, `pyright` for static type checking, and `pytest` for testing.
66

7-
We build wheels with `python -m build` and upload to [PyPI](https://pypi.org/project/torchrunx) with [twine](https://twine.readthedocs.io). Our release pipeline is powered by Github Actions.
7+
We build wheels with `uv build` and upload to [PyPI](https://pypi.org/project/torchrunx) with `uv publish`. Our release pipeline is powered by Github Actions.
88

99
## Pull Requests
1010

pixi.lock

Lines changed: 0 additions & 2345 deletions
This file was deleted.

pixi.toml

Lines changed: 0 additions & 28 deletions
This file was deleted.

pyproject.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@ classifiers = [
2222
]
2323
requires-python = ">=3.9"
2424
dependencies = [
25-
"cloudpickle>=3.0",
26-
"fabric>=3.2",
27-
"torch>=2.0",
28-
# torch.distributed depends on numpy
29-
"numpy>=1.20",
25+
"cloudpickle>=3.0",
26+
"fabric>=3.2",
27+
"torch>=2.0",
28+
# torch.distributed depends on numpy
29+
"numpy>=1.20",
3030
]
31+
[dependency-groups]
32+
dev = ["ruff", "pyright", "pytest", "build", "twine"]
33+
dev-extras = ["submitit", "transformers"]
3134

32-
[project.urls]
33-
Repository = "https://github.com/apoorvkh/torchrunx.git"
34-
Documentation = "https://torchrunx.readthedocs.io"
35+
[tool.uv]
36+
managed = true
37+
python-preference = "only-managed"
3538

3639
## Development tools
3740

tests/test_submitit.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
import copy
44

5-
import submitit
5+
import submitit # pyright: ignore [reportMissingImports]
66
import torch
77
from torch.utils.data import Dataset
8-
from transformers import BertForMaskedLM, Trainer, TrainingArguments
8+
from transformers import ( # pyright: ignore [reportMissingImports]
9+
BertForMaskedLM,
10+
Trainer,
11+
TrainingArguments,
12+
)
913

1014
import torchrunx as trx
1115

tests/test_train.py renamed to tests/test_train_gpu.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import os
22

3+
import torch
4+
35
import torchrunx as trx
46

57

6-
def worker() -> None:
7-
import torch
8+
class MLP(torch.nn.Module):
9+
def __init__(self) -> None:
10+
super().__init__()
11+
self.a = torch.nn.Linear(10, 10, bias=False)
12+
self.b = torch.nn.Linear(10, 1, bias=False)
813

9-
class MLP(torch.nn.Module):
10-
def __init__(self) -> None:
11-
super().__init__()
12-
self.a = torch.nn.Linear(10, 10, bias=False)
13-
self.b = torch.nn.Linear(10, 1, bias=False)
14+
def forward(self, x: torch.Tensor) -> torch.Tensor:
15+
return self.b(self.a(x))
1416

15-
def forward(self, x: torch.Tensor) -> torch.Tensor:
16-
return self.b(self.a(x))
1717

18+
def worker() -> None:
1819
local_rank = int(os.environ["LOCAL_RANK"])
1920
print("init model")
2021
model = MLP().to(local_rank)
@@ -33,8 +34,6 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
3334
def test_distributed_train() -> None:
3435
trx.launch(
3536
worker,
36-
hostnames="slurm",
37-
workers_per_host="slurm",
3837
backend="nccl",
3938
)
4039

0 commit comments

Comments
 (0)