From f3aaea5e456f21e2fa1390922d859097abfc0283 Mon Sep 17 00:00:00 2001 From: diwei sun Date: Tue, 23 Apr 2024 14:35:59 +0800 Subject: [PATCH 1/6] patch for windows install --- torchbenchmark/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/torchbenchmark/__init__.py b/torchbenchmark/__init__.py index 074c898fee..ba5dcc9ab2 100644 --- a/torchbenchmark/__init__.py +++ b/torchbenchmark/__init__.py @@ -62,14 +62,16 @@ def _install_deps(model_path: str, verbose: bool = True) -> Tuple[bool, Any]: ] run_env = os.environ.copy() run_env["PYTHONPATH"] = this_dir.parent + for key, item in run_env.items(): + run_env[key] = str(run_env[key]) run_kwargs = { "cwd": model_path, - "check": True, + "check": 'True', "env": run_env, } output_buffer = None - _, stdout_fpath = tempfile.mkstemp() + fd, stdout_fpath = tempfile.mkstemp() try: output_buffer = io.FileIO(stdout_fpath, mode="w") @@ -91,7 +93,9 @@ def _install_deps(model_path: str, verbose: bool = True) -> Tuple[bool, Any]: except Exception as e: return (False, e, io.FileIO(stdout_fpath, mode="r").read().decode()) finally: + output_buffer.close() del output_buffer + os.close(fd) os.remove(stdout_fpath) return (True, None, None) From 86196426f44ef448fabd2f2c5fb83b1aa125fd5c Mon Sep 17 00:00:00 2001 From: diwei sun Date: Thu, 25 Apr 2024 20:35:42 +0800 Subject: [PATCH 2/6] enable unet1d inference --- torchbenchmark/models/unet1d/__init__.py | 27 +++++++++++++++++++ torchbenchmark/models/unet1d/install.py | 9 +++++++ torchbenchmark/models/unet1d/metadata.yml | 8 ++++++ torchbenchmark/models/unet1d/requirements.txt | 1 + 4 files changed, 45 insertions(+) create mode 100644 torchbenchmark/models/unet1d/__init__.py create mode 100644 torchbenchmark/models/unet1d/install.py create mode 100644 torchbenchmark/models/unet1d/metadata.yml create mode 100644 torchbenchmark/models/unet1d/requirements.txt diff --git a/torchbenchmark/models/unet1d/__init__.py b/torchbenchmark/models/unet1d/__init__.py new file mode 100644 index 0000000000..79274cc90c --- /dev/null +++ b/torchbenchmark/models/unet1d/__init__.py @@ -0,0 +1,27 @@ +from ...util.model import BenchmarkModel + +import torch +from diffusers import UNet1DModel + +class Model(BenchmarkModel): + DEFAULT_EVAL_BSIZE = 64 + def __init__(self, test, device, batch_size=None, extra_args=[]): + super().__init__( test=test, device=device, + batch_size=batch_size, extra_args=extra_args) + + self.in_channels = 32 + self.seq_len = 256 + self.num_features = 16 + self.block_out_channels = (self.seq_len, 64, 64) + print(self.batch_size) + self.example_inputs = torch.randn(1, self.num_features, self.seq_len) + self.timesteps = torch.tensor([1]) + self.model = UNet1DModel(in_channels=self.in_channels, block_out_channels=self.block_out_channels) + + def get_module(self): + return self.model, self.example_inputs + + def eval(self): + self.model.eval() + with torch.no_grad(): + out=self.model(self.example_inputs, self.timesteps) diff --git a/torchbenchmark/models/unet1d/install.py b/torchbenchmark/models/unet1d/install.py new file mode 100644 index 0000000000..33fb7bf189 --- /dev/null +++ b/torchbenchmark/models/unet1d/install.py @@ -0,0 +1,9 @@ +import subprocess +import sys +import os + +def pip_install_requirements(): + subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) + +if __name__ == '__main__': + pip_install_requirements() \ No newline at end of file diff --git a/torchbenchmark/models/unet1d/metadata.yml b/torchbenchmark/models/unet1d/metadata.yml new file mode 100644 index 0000000000..c0e058b49a --- /dev/null +++ b/torchbenchmark/models/unet1d/metadata.yml @@ -0,0 +1,8 @@ +devices: + NVIDIA A100-SXM4-40GB: + eval_batch_size: 64 +eval_benchmark: true +eval_deterministic: false +eval_nograd: true +train_benchmark: true +train_deterministic: false \ No newline at end of file diff --git a/torchbenchmark/models/unet1d/requirements.txt b/torchbenchmark/models/unet1d/requirements.txt new file mode 100644 index 0000000000..81caff4c2f --- /dev/null +++ b/torchbenchmark/models/unet1d/requirements.txt @@ -0,0 +1 @@ +diffusers \ No newline at end of file From d21ea2bb144b6da619a5828cc434f818908ed26a Mon Sep 17 00:00:00 2001 From: DiweiSun <105627594+DiweiSun@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:43:09 +0800 Subject: [PATCH 3/6] update seq_len default value for unet1d --- torchbenchmark/models/unet1d/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torchbenchmark/models/unet1d/__init__.py b/torchbenchmark/models/unet1d/__init__.py index 79274cc90c..ca901a5168 100644 --- a/torchbenchmark/models/unet1d/__init__.py +++ b/torchbenchmark/models/unet1d/__init__.py @@ -4,13 +4,13 @@ from diffusers import UNet1DModel class Model(BenchmarkModel): - DEFAULT_EVAL_BSIZE = 64 + DEFAULT_EVAL_BSIZE = 32 def __init__(self, test, device, batch_size=None, extra_args=[]): super().__init__( test=test, device=device, batch_size=batch_size, extra_args=extra_args) self.in_channels = 32 - self.seq_len = 256 + self.seq_len = 2016 self.num_features = 16 self.block_out_channels = (self.seq_len, 64, 64) print(self.batch_size) From eac2b2c1bdeb6f5891431a9e671b5c313d10de73 Mon Sep 17 00:00:00 2001 From: DiweiSun <105627594+DiweiSun@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:44:29 +0800 Subject: [PATCH 4/6] update seq_len default value for unet1D --- torchbenchmark/models/unet1d/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchbenchmark/models/unet1d/__init__.py b/torchbenchmark/models/unet1d/__init__.py index ca901a5168..f511487f69 100644 --- a/torchbenchmark/models/unet1d/__init__.py +++ b/torchbenchmark/models/unet1d/__init__.py @@ -10,7 +10,7 @@ def __init__(self, test, device, batch_size=None, extra_args=[]): batch_size=batch_size, extra_args=extra_args) self.in_channels = 32 - self.seq_len = 2016 + self.seq_len = 256 self.num_features = 16 self.block_out_channels = (self.seq_len, 64, 64) print(self.batch_size) From fa42c4461938c3c47481be73afddb2c91f52fbdd Mon Sep 17 00:00:00 2001 From: diwei sun Date: Tue, 7 May 2024 11:26:46 +0800 Subject: [PATCH 5/6] update __init__.py --- torchbenchmark/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/torchbenchmark/__init__.py b/torchbenchmark/__init__.py index 1a4fe37091..07f0e9be2f 100644 --- a/torchbenchmark/__init__.py +++ b/torchbenchmark/__init__.py @@ -59,9 +59,7 @@ def _install_deps(model_path: str, verbose: bool = True) -> Tuple[bool, Any]: [sys.executable, install_file], ] run_env = os.environ.copy() - run_env["PYTHONPATH"] = this_dir.parent run_env["PYTHONPATH"] = Path(this_dir.parent).as_posix() - run_kwargs = { "cwd": model_path, "check": True, From aa3ea2a28d4bb88083bd32edb054eb577ebf92b1 Mon Sep 17 00:00:00 2001 From: diwei sun Date: Tue, 7 May 2024 18:48:18 +0800 Subject: [PATCH 6/6] update metadata.yml for unet1d --- torchbenchmark/models/unet1d/metadata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchbenchmark/models/unet1d/metadata.yml b/torchbenchmark/models/unet1d/metadata.yml index c0e058b49a..f9d22cf25f 100644 --- a/torchbenchmark/models/unet1d/metadata.yml +++ b/torchbenchmark/models/unet1d/metadata.yml @@ -4,5 +4,5 @@ devices: eval_benchmark: true eval_deterministic: false eval_nograd: true -train_benchmark: true +train_benchmark: false train_deterministic: false \ No newline at end of file