From f91a510287c328725f24d42e3ec9db13957dedfe Mon Sep 17 00:00:00 2001 From: lspindler Date: Tue, 12 Aug 2025 14:57:47 +0200 Subject: [PATCH 1/3] Enable Convolution AutoTuning --- comfy/ops.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/comfy/ops.py b/comfy/ops.py index 2cc9bbc27..3b576bd1b 100644 --- a/comfy/ops.py +++ b/comfy/ops.py @@ -26,6 +26,9 @@ import contextlib cast_to = comfy.model_management.cast_to #TODO: remove once no more references +if torch.cuda.is_available() and torch.backends.cudnn.is_available(): + torch.backends.cudnn.benchmark = True + def cast_to_input(weight, input, non_blocking=False, copy=True): return comfy.model_management.cast_to(weight, input.dtype, input.device, non_blocking=non_blocking, copy=copy) From b6d8805d000fd508a49fa3c18c72fb11f5c5977e Mon Sep 17 00:00:00 2001 From: lspindler Date: Tue, 12 Aug 2025 14:57:47 +0200 Subject: [PATCH 2/3] Enable Convolution AutoTuning --- comfy/ops.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/comfy/ops.py b/comfy/ops.py index 18e7db705..30c3fdf44 100644 --- a/comfy/ops.py +++ b/comfy/ops.py @@ -52,6 +52,9 @@ except (ModuleNotFoundError, TypeError): cast_to = comfy.model_management.cast_to #TODO: remove once no more references +if torch.cuda.is_available() and torch.backends.cudnn.is_available(): + torch.backends.cudnn.benchmark = True + def cast_to_input(weight, input, non_blocking=False, copy=True): return comfy.model_management.cast_to(weight, input.dtype, input.device, non_blocking=non_blocking, copy=copy) From 771b337e8983aaf78db21a793f6648994f6b6e6f Mon Sep 17 00:00:00 2001 From: lspindler Date: Fri, 22 Aug 2025 10:12:23 +0200 Subject: [PATCH 3/3] Make Convolution AutoTuning opt-in for now --- comfy/cli_args.py | 1 + comfy/ops.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/comfy/cli_args.py b/comfy/cli_args.py index de3e85c08..72eeaea9a 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -143,6 +143,7 @@ class PerformanceFeature(enum.Enum): Fp16Accumulation = "fp16_accumulation" Fp8MatrixMultiplication = "fp8_matrix_mult" CublasOps = "cublas_ops" + AutoTune = "autotune" parser.add_argument("--fast", nargs="*", type=PerformanceFeature, help="Enable some untested and potentially quality deteriorating optimizations. --fast with no arguments enables everything. You can pass a list specific optimizations if you only want to enable specific ones. Current valid optimizations: fp16_accumulation fp8_matrix_mult cublas_ops") diff --git a/comfy/ops.py b/comfy/ops.py index 30c3fdf44..55e958adb 100644 --- a/comfy/ops.py +++ b/comfy/ops.py @@ -52,7 +52,7 @@ except (ModuleNotFoundError, TypeError): cast_to = comfy.model_management.cast_to #TODO: remove once no more references -if torch.cuda.is_available() and torch.backends.cudnn.is_available(): +if torch.cuda.is_available() and torch.backends.cudnn.is_available() and PerformanceFeature.AutoTune in args.fast: torch.backends.cudnn.benchmark = True def cast_to_input(weight, input, non_blocking=False, copy=True):