Skip to content

Update torchdynamo backend for torchbench #1091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/torchdynamo/nvfuser-aot-speedup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ args:
# empty argument means the default pytorch eager mode
- ""
- "--torchdynamo nvfuser"
- "--torchdynamo aot_autograd_speedup_strategy"
- "--torchdynamo aot_nvfuser"
10 changes: 1 addition & 9 deletions torchbenchmark/util/backends/torchdynamo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
import functools
from typing import List
import torchdynamo
from torchdynamo.optimizations.training import aot_autograd_speedup_strategy

EXTRA_BACKENDS = {
"aot_autograd_speedup_strategy": aot_autograd_speedup_strategy,
}

def parse_torchdynamo_args(model: 'torchbenchmark.util.model.BenchmarkModel', dyamo_args: List[str]) -> argparse.Namespace:
parser = argparse.ArgumentParser()
available_backends = torchdynamo.list_backends()
available_backends.extend(EXTRA_BACKENDS.keys())
parser.add_argument(
"--torchdynamo", choices=available_backends, help="Specify torchdynamo backends"
)
Expand All @@ -23,9 +17,7 @@ def parse_torchdynamo_args(model: 'torchbenchmark.util.model.BenchmarkModel', dy


def apply_torchdynamo_args(model: 'torchbenchmark.util.model.BenchmarkModel', args: argparse.Namespace, precision: str):
if args.torchdynamo in EXTRA_BACKENDS:
model.add_context(functools.partial(torchdynamo.optimize, EXTRA_BACKENDS[args.torchdynamo]))
elif args.torchdynamo == "fx2trt" and precision == "fp16":
if args.torchdynamo == "fx2trt" and precision == "fp16":
model.add_context(functools.partial(torchdynamo.optimize, torchdynamo.optimizations.backends.fx2trt_compiler_fp16))
else:
model.add_context(functools.partial(torchdynamo.optimize, args.torchdynamo))
Expand Down