Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 2788fcc

Browse files
authored
Early version of TorchInductor (#190)
1 parent e0688cf commit 2788fcc

29 files changed

+6195
-11
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test Inductor
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test-inductor:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.8'
17+
cache: 'pip'
18+
- run: make setup_nightly
19+
- run: pytest ./tests/test_torchinductor.py
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
23+
cancel-in-progress: true

.isort.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
profile=black
33
src_paths=test,torchdynamo
44
force_single_line=True
5+
known_first_party=torchdynamo,torchinductor

Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.PHONY: default develop test torchbench format lint setup clean autotune
22

3-
PY_FILES := $(wildcard *.py) $(wildcard torchdynamo/*.py) $(wildcard torchdynamo/*/*.py) $(wildcard tests/*.py)
3+
PY_FILES := $(wildcard *.py) $(wildcard torchdynamo/*.py) $(wildcard torchdynamo/*/*.py) \
4+
$(wildcard tests/*.py) $(wildcard torchinductor/*.py) $(wildcard torchinductor/*/*.py)
45
C_FILES := $(wildcard torchdynamo/*.c torchdynamo/*.cpp)
56
CLANG_TIDY ?= clang-tidy-10
67
CLANG_FORMAT ?= clang-format-10
@@ -35,9 +36,17 @@ lint:
3536
lint-deps:
3637
grep -E '(black|flake8|isort|click)' requirements.txt | xargs pip install
3738

39+
setup_lint: lint-deps
40+
3841
setup:
3942
pip install -r requirements.txt
4043

44+
setup_nightly:
45+
pip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu
46+
pip install git+https://github.com/pytorch/functorch.git
47+
pip install -r requirements.txt
48+
python setup.py develop
49+
4150
clean:
4251
python setup.py clean
4352
rm -rf build torchdynamo.egg-info torchdynamo/*.so __pycache__ .pytest_cache .benchmarks *.csv dist
@@ -117,3 +126,17 @@ baseline-gpu: develop
117126
python torchbench.py -dcuda --isolate -n100 --speedup-trt
118127
python torchbench.py -dcuda --isolate -n100 --speedup-onnx
119128
paste -d, baseline_nnc.csv baseline_nvfuser.csv baseline_trt.csv baseline_onnx.csv > baseline_all.csv
129+
130+
baseline-gpu-inductor: develop
131+
rm -f baseline_*.csv
132+
python torchbench.py -dcuda --float32 --isolate -n50 --inductor
133+
python torchbench.py -dcuda --float32 --isolate -n50 --backend=cudagraphs && mv speedup_cudagraphs.csv baseline_cudagraphs.csv
134+
python torchbench.py -dcuda --float32 --isolate -n50 --backend=cudagraphs_ts --nvfuser && mv speedup_cudagraphs_ts.csv baseline_cg_nvfuser.csv
135+
python torchbench.py -dcuda --float32 --isolate -n50 --backend=cudagraphs_ts && mv speedup_cudagraphs_ts.csv baseline_cg_nnc.csv
136+
# python torchbench.py -dcuda --float32 --isolate -n50 --speedup-ts --nvfuser && mv baseline_ts.csv baseline_ts_nvfuser.csv
137+
# python torchbench.py -dcuda --float32 --isolate -n50 --speedup-ts && mv baseline_ts.csv baseline_ts_nnc.csv
138+
paste -d, inductor.csv baseline_cudagraphs.csv baseline_cg_nvfuser.csv baseline_cg_nnc.csv > baseline_all.csv
139+
140+
141+
142+

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ usability and performance.
1515

1616
![](TorchDynamo.png)
1717

18-
For more information see progress updates posted on dev-discuss.pytorch.org:
18+
Links for more information and development progress updates:
19+
1920
- [Update 1: An Experiment in Dynamic Python Bytecode Transformation](https://dev-discuss.pytorch.org/t/torchdynamo-an-experiment-in-dynamic-python-bytecode-transformation/361)
2021
- [Update 2: 1.48x Geomean Speedup on TorchBench CPU Inference](https://dev-discuss.pytorch.org/t/torchdynamo-update-1-48x-geomean-speedup-on-torchbench-cpu-inference/397)
2122
- [Update 3: GPU Inference Edition](https://dev-discuss.pytorch.org/t/torchdynamo-update-3-gpu-inference-edition/460)
2223
- [Update 4: LazyTensor & nvFuser Experiments](https://dev-discuss.pytorch.org/t/torchdynamo-update-4-lazytensor-nvfuser-experiments/496)
2324
- [Update 5: Improved Capture & Bigger Graphs](https://dev-discuss.pytorch.org/t/torchdynamo-update-5-improved-capture-bigger-graphs/556)
2425
- [Update 6: Training support with AOTAutograd](https://dev-discuss.pytorch.org/t/torchdynamo-update-6-training-support-with-aotautograd/570)
26+
- [Update 7: Inference with FX2TRT](https://dev-discuss.pytorch.org/t/torchdynamo-update-7-inference-with-fx2trt/576)
27+
- (Video) [Live deep-dive into TorchDynamo](https://www.youtube.com/watch?v=egZB5Uxki0I)
2528

2629
*TorchDynamo is experimental* and under active development.
2730
You are welcome to try it out and contribute, but should expect to find
@@ -364,9 +367,10 @@ cd .. # if still in torchdynamo/
364367
365368
# download everything
366369
git clone [email protected]:jansel/benchmark.git torchbenchmark
367-
python torchbenchmark/install.py
370+
cd torchbenchmark
371+
python install.py
368372
369-
cd torchdynamo
373+
cd ../torchdynamo
370374
371375
# fix the version of black so `make format` / `make lint` work
372376
make lint-deps
@@ -380,6 +384,7 @@ make lint-deps
380384
[![Test Python 3.7](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py37.yml/badge.svg)](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py37.yml)
381385
[![Test Python 3.8](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py38.yml/badge.svg)](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py38.yml)
382386
[![Test Python 3.9](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py39.yml/badge.svg)](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py39.yml)
387+
[![Test Python 3.10](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py310.yml/badge.svg)](https://github.com/facebookresearch/torchdynamo/actions/workflows/test-py39.yml)
383388

384389
Run tests with
385390
```shell

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ ninja
77
pytest
88
tabulate
99
torch
10+
sympy

setup.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@
2525
license="BSD-3",
2626
keywords="pytorch machine learning compilers",
2727
python_requires=">=3.7, <3.11",
28-
install_requires=["torch>=1.11.0", "numpy", "tabulate"],
29-
packages=find_packages(include=["torchdynamo", "torchdynamo.*"]),
28+
install_requires=["torch>=1.11.0", "numpy", "tabulate", "sympy"],
29+
packages=find_packages(
30+
include=[
31+
"torchdynamo",
32+
"torchdynamo.*",
33+
"torchinductor",
34+
"torchinductor.*",
35+
]
36+
),
37+
zip_safe=False,
3038
ext_modules=[
3139
Extension(
3240
"torchdynamo._eval_frame",

0 commit comments

Comments
 (0)