Skip to content

Commit 424a290

Browse files
authored
Move to UV (#59)
1 parent dfc3ba0 commit 424a290

File tree

6 files changed

+56
-42
lines changed

6 files changed

+56
-42
lines changed

.github/workflows/ruff.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v3
18+
1619
- name: Set up Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.x'
20+
run: uv python install
2021

2122
- name: Install package with dev dependencies
22-
run: pip install -e .[dev]
23+
run: uv sync --dev
2324

2425
- name: Run ruff check
25-
run: ruff check .
26+
run: uv run ruff check .
2627

2728
- name: Run ruff format check
28-
run: ruff format --check .
29+
run: uv run ruff format --check .

.github/workflows/smoke-test.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,17 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v3
20+
1821
- name: Set up Python
19-
uses: actions/setup-python@v4
20-
with:
21-
python-version: '3.x'
22+
run: uv python install
2223

2324
- name: Install package and dependencies
24-
run: |
25-
pip install -e .[dev]
25+
run: uv sync --dev
2626

2727
- name: Run smoke test
28-
run: |
29-
python -m BackendBench.scripts.main --suite smoke --backend aten
28+
run: uv run python -m BackendBench.scripts.main --suite smoke --backend aten
3029

3130
- name: Run pytest tests
32-
run: |
33-
pytest test/
31+
run: uv run pytest test/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ backendbench.egg-info/
77
CLAUDE.md
88
venv/
99
ops/
10+
uv.lock

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,43 @@ We provide both
1010
1. Comprehensive operator level correctness checks using the PyTorch OpInfo test suite
1111
2. Performance checks using the ops that show up in the most popular Hugging Face models with realistic tensor shapes
1212

13+
# Installation:
14+
15+
Install using uv (recommended):
16+
```bash
17+
uv add backendbench
18+
```
19+
20+
Or install in development mode:
21+
```bash
22+
uv sync --dev
23+
```
24+
1325
# Usage:
1426

1527
Run a simple smoke test (relu) with the default ATen backend:
1628
```bash
17-
python scripts/main.py --suite smoke --backend aten
29+
uv run python scripts/main.py --suite smoke --backend aten
1830
```
1931

2032
Run the smoke test with FlagGems:
2133
```bash
22-
python scripts/main.py --suite smoke --backend flag_gems
34+
uv run python scripts/main.py --suite smoke --backend flag_gems
2335
```
2436

2537
Run opinfo tests (correctness only) with ATen
2638
```bash
27-
python scripts/main.py --suite opinfo --backend aten
39+
uv run python scripts/main.py --suite opinfo --backend aten
2840
```
2941

3042
Run a filtered set of opinfo tests with FlagGems
3143
```bash
32-
python scripts/main.py --suite opinfo --backend flag_gems --ops "add,sub"
44+
uv run python scripts/main.py --suite opinfo --backend flag_gems --ops "add,sub"
3345
```
3446

3547
Run all the opinfo tests with FlagGems (takes a few minutes)
3648
```bash
37-
python scripts/main.py --suite opinfo --backend flag_gems
49+
uv run python scripts/main.py --suite opinfo --backend flag_gems
3850
```
3951

4052
## LLM-Based Kernel Generation and Evaluation
@@ -44,7 +56,7 @@ Generate and evaluate PyTorch kernels using Claude API:
4456
Run LLM evaluation on smoke test (relu operation):
4557
```bash
4658
export ANTHROPIC_API_KEY=your_api_key_here
47-
python scripts/main.py --suite smoke --backend llm
59+
uv run python scripts/main.py --suite smoke --backend llm
4860
```
4961

5062
## KernelAgent-Based Triton Kernel Generation
@@ -59,19 +71,19 @@ git submodule update --init --recursive
5971
Run KernelAgent evaluation on smoke test (relu operation):
6072
```bash
6173
export OPENAI_API_KEY=your_api_key_here
62-
python scripts/main.py --suite smoke --backend kernel_agent
74+
uv run python scripts/main.py --suite smoke --backend kernel_agent
6375
```
6476

6577
Run KernelAgent with custom configuration:
6678
```bash
6779
export OPENAI_API_KEY=your_api_key_here
68-
python scripts/main.py --suite smoke --backend kernel_agent --kernel-agent-workers 6 --kernel-agent-max-rounds 15
80+
uv run python scripts/main.py --suite smoke --backend kernel_agent --kernel-agent-workers 6 --kernel-agent-max-rounds 15
6981
```
7082

7183
Run KernelAgent on opinfo tests with a specific operation:
7284
```bash
7385
export OPENAI_API_KEY=your_api_key_here
74-
python scripts/main.py --suite opinfo --backend kernel_agent --ops "add"
86+
uv run python scripts/main.py --suite opinfo --backend kernel_agent --ops "add"
7587
```
7688

7789
## Directory-Based Kernel Development
@@ -160,10 +172,10 @@ if __name__ == "__main__":
160172

161173
Test individual implementations:
162174
```bash
163-
python generated_kernels/relu/relu_implementation_1.py
175+
uv run python generated_kernels/relu/relu_implementation_1.py
164176
```
165177

166178
Test with BackendBench:
167179
```bash
168-
python scripts/main.py --suite smoke --backend directory
180+
uv run python scripts/main.py --suite smoke --backend directory
169181
```

pyproject.toml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools>=61.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "backendbench"
@@ -27,25 +27,27 @@ dependencies = [
2727
]
2828

2929
[project.optional-dependencies]
30-
dev = [
30+
flaggems = [
31+
# flag_gems must be installed from source: https://github.com/FlagOpen/FlagGems
32+
]
33+
34+
[project.scripts]
35+
backendbench = "BackendBench.scripts.main:cli"
36+
37+
[tool.hatch.build.targets.wheel]
38+
packages = ["BackendBench"]
39+
40+
[tool.uv]
41+
dev-dependencies = [
3142
"pytest",
32-
"pytest-cov",
43+
"pytest-cov",
3344
"pytest-mock",
3445
"pytest-timeout",
3546
"ruff==0.12.1",
3647
"torch",
3748
"numpy",
38-
"cupy-cuda12x",
49+
# cupy-cuda12x is platform specific, install manually if needed
3950
]
40-
flaggems = [
41-
"flag_gems",
42-
]
43-
44-
[project.scripts]
45-
backendbench = "BackendBench.scripts.main:cli"
46-
47-
[tool.setuptools.packages.find]
48-
include = ["BackendBench*"]
4951

5052
[tool.ruff]
5153
line-length = 100

test/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def func_with_pytorch_stream():
2828

2929
@pytest.mark.skipif(not HAS_CUDA, reason="CUDA not available")
3030
def test_cupy_stream_creation(self):
31-
import cupy
32-
3331
"""Test detection of CuPy CUDA stream creation."""
32+
pytest.importorskip("cupy")
33+
import cupy
3434

3535
def func_with_cupy_stream():
3636
stream = cupy.cuda.Stream()

0 commit comments

Comments
 (0)