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

Commit f863e3d

Browse files
committed
Delete online autotuner
Signed-off-by: Edward Z. Yang <ezyangfb.com> ghstack-source-id: 9188a92 Pull Request resolved: #1042
1 parent 058b358 commit f863e3d

File tree

4 files changed

+1
-70
lines changed

4 files changed

+1
-70
lines changed

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ offline-autotune-gpu: develop
124124
python autotune.py --nvfuser
125125
python benchmarks/torchbench.py --nvfuser -d cuda --offline-autotune -n100
126126

127-
online-autotune-cpu: develop
128-
python benchmarks/torchbench.py --online-autotune -n50
129-
130-
online-autotune-gpu: develop
131-
python benchmarks/torchbench.py --nvfuser -d cuda --online-autotune -n100
132-
133127
fixed1-gpu: develop
134128
python benchmarks/torchbench.py --nvfuser -d cuda --speedup-fixed1 -n100
135129

benchmarks/common.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from torchdynamo.optimizations.inference import fixed_strategy1
3030
from torchdynamo.optimizations.inference import fixed_strategy2
3131
from torchdynamo.optimizations.inference import offline_autotuner
32-
from torchdynamo.optimizations.inference import online_autotuner
3332
from torchdynamo.optimizations.log_args import conv_args_analysis
3433
from torchdynamo.profiler import Profiler
3534
from torchdynamo.profiler import fx_insert_profiling
@@ -1284,9 +1283,6 @@ def parse_args():
12841283
group.add_argument(
12851284
"--coverage", action="store_true", help="(default) " + help(coverage_experiment)
12861285
)
1287-
group.add_argument(
1288-
"--online-autotune", action="store_true", help=help(speedup_experiment)
1289-
)
12901286
group.add_argument(
12911287
"--offline-autotune", action="store_true", help=help(speedup_experiment)
12921288
)
@@ -1560,10 +1556,6 @@ def main(runner, original_dir=None):
15601556
optimize_ctx = torchdynamo.optimize("inductor", nopython=args.nopython)
15611557
experiment = speedup_experiment
15621558
output_filename = "inductor.csv"
1563-
elif args.online_autotune:
1564-
optimize_ctx = torchdynamo.optimize(online_autotuner, nopython=args.nopython)
1565-
experiment = speedup_experiment
1566-
output_filename = "speedups.csv"
15671559
elif args.offline_autotune:
15681560
optimize_ctx = torchdynamo.optimize(offline_autotuner, nopython=args.nopython)
15691561
experiment = speedup_experiment
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from .backends import BACKENDS
22
from .inference import offline_autotuner
3-
from .inference import online_autotuner
43
from .training import create_aot_backends
54

65
create_aot_backends()
76

8-
__all__ = ["online_autotuner", "offline_autotuner", "BACKENDS"]
7+
__all__ = ["offline_autotuner", "BACKENDS"]

torchdynamo/optimizations/inference.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import time
1010
from collections import defaultdict
1111

12-
import numpy as np
1312
import torch
1413

1514
from .. import config
@@ -19,7 +18,6 @@
1918
from ..utils import clone_inputs
2019
from ..utils import count_calls
2120
from ..utils import counters
22-
from ..utils import timed
2321
from .backends import BACKENDS
2422
from .normalize import long_name
2523
from .normalize import normalize_ir
@@ -257,55 +255,3 @@ def argmin(perf):
257255
# small bias torwards using eager since it is more robust
258256
best_sec *= 0.99
259257
return best
260-
261-
262-
class OnlineAutotuner(TorchScriptStrategy):
263-
repeat = 15
264-
265-
def candidate(self):
266-
if check_requires_grad(self.gm, self.original_example_inputs):
267-
warning("not optimizing requires_grad=True")
268-
return None
269-
self.scripted = self.scripted.eval()
270-
example_inputs_copy = self.example_inputs
271-
models = [("eager", self.gm.forward)]
272-
for name in self.select_backends():
273-
try:
274-
compiled_model = BACKENDS[name](self.scripted, example_inputs_copy)
275-
if compiled_model is None:
276-
continue
277-
self.restore()
278-
result = compiled_model(*self.example_inputs)
279-
assert same(result, self.correct)
280-
models.append((name, compiled_model))
281-
except AssertionError:
282-
logging.exception(f"incorrect while running {name}")
283-
except Exception:
284-
logging.exception(f"error while running {name}")
285-
286-
timings = np.zeros((self.repeat, len(models)), np.float64)
287-
for rep in range(timings.shape[0]):
288-
# interleave the runs to handle frequency scaling and load changes
289-
for i, (n, m) in enumerate(models):
290-
result, timings[rep, i] = timed(m, example_inputs_copy)
291-
median = np.median(timings, axis=0)
292-
median[0] *= 0.99 # a bias towards eager
293-
best = int(np.argmin(median))
294-
counters["backend"][models[best][0]] += 1
295-
return models[best][1]
296-
297-
def select_backends(self):
298-
if check_is_cuda(self.gm, self.original_example_inputs):
299-
backend_names = [
300-
"ts",
301-
"cudagraphs_ts_ofi",
302-
"nnc_ofi",
303-
"tensorrt",
304-
]
305-
else:
306-
backend_names = ["ofi", "onnxrt_cpu"]
307-
return backend_names
308-
309-
310-
online_autotuner = OnlineAutotuner.compile_fn
311-
BACKENDS["autotune"] = online_autotuner

0 commit comments

Comments
 (0)