diff --git a/CHANGELOG.md b/CHANGELOG.md index d04db3059..d3f0e9f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ - **Torch**: - for cuda environemnts set default to `torch==2.6.0+cu126` - - add torch tunable ops and their max duration - *set in settings -> backend settings -> torch* + - add support for torch **tunable ops**, this can speed up operations by up to 10-30% on some platforms + *set in settings -> backend settings -> torch* and *paths -> tunable ops cache* - **Fixes**: - photomaker with offloading - photomaker with refine diff --git a/modules/devices.py b/modules/devices.py index db3ba3f89..03790f9e1 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -295,9 +295,12 @@ def set_cuda_tunable(): if opts.torch_tunable_ops != 'default': torch.cuda.tunable.enable(opts.torch_tunable_ops == 'true') torch.cuda.tunable.tuning_enable(opts.torch_tunable_ops == 'true') - # torch.cuda.tunable.set_max_tuning_duration(100) + torch.cuda.tunable.set_max_tuning_duration(1000) # set to high value as actual is min(duration, iterations) torch.cuda.tunable.set_max_tuning_iterations(opts.torch_tunable_limit) - # log.debug(f'Torce tunable: enabled={torch.cuda.tunable.is_enabled()} tuning={torch.cuda.tunable.tuning_is_enabled()} iterations={torch.cuda.tunable.get_max_tuning_iterations()} duration={torch.cuda.tunable.get_max_tuning_duration()}') + fn = os.path.join(opts.tunable_dir, 'tunable.csv') + torch.cuda.tunable.set_filename(fn) + if torch.cuda.tunable.is_enabled(): + log.debug(f'Torce tunable: enabled={torch.cuda.tunable.is_enabled()} tuning={torch.cuda.tunable.tuning_is_enabled()} iterations={torch.cuda.tunable.get_max_tuning_iterations()} duration={torch.cuda.tunable.get_max_tuning_duration()} fn="{fn}"') except Exception: pass diff --git a/modules/paths.py b/modules/paths.py index 134bcd2ab..9261990db 100644 --- a/modules/paths.py +++ b/modules/paths.py @@ -109,6 +109,7 @@ def create_paths(opts): create_path(fix_path('unet_dir')) create_path(fix_path('te_dir')) create_path(fix_path('lora_dir')) + create_path(fix_path('tunable_dir')) create_path(fix_path('embeddings_dir')) create_path(fix_path('hypernetwork_dir')) create_path(fix_path('onnx_temp_dir')) diff --git a/modules/shared.py b/modules/shared.py index 269627af0..faca98a91 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -665,6 +665,7 @@ options_templates.update(options_section(('system-paths', "System Paths"), { "ckpt_dir": OptionInfo(os.path.join(paths.models_path, 'Stable-diffusion'), "Folder with stable diffusion models", folder=True), "diffusers_dir": OptionInfo(os.path.join(paths.models_path, 'Diffusers'), "Folder with Huggingface models", folder=True), "hfcache_dir": OptionInfo(default_hfcache_dir, "Folder for Huggingface cache", folder=True), + "tunable_dir": OptionInfo(os.path.join(paths.models_path, 'tunable'), "Folder for Tunable ops cache", folder=True), "vae_dir": OptionInfo(os.path.join(paths.models_path, 'VAE'), "Folder with VAE files", folder=True), "unet_dir": OptionInfo(os.path.join(paths.models_path, 'UNET'), "Folder with UNET files", folder=True), "te_dir": OptionInfo(os.path.join(paths.models_path, 'Text-encoder'), "Folder with Text encoder files", folder=True),