@@ -194,22 +194,28 @@ def normalize_args(self, *args: object, **kwargs: object) -> tuple[object, ...]:
194
194
def autotune (
195
195
self ,
196
196
args : Sequence [object ],
197
+ * ,
198
+ force : bool = False ,
197
199
** options : object ,
198
200
) -> Config :
199
201
"""
200
- Perform autotuning to find the optimal configuration for
201
- the kernel. This uses the default setting, you can call
202
- helion.autotune.* directly for more customization.
202
+ Perform autotuning to find the optimal configuration for the kernel. This uses the
203
+ default setting, you can call helion.autotune.* directly for more customization.
204
+
205
+ If config= or configs= is provided to helion.kernel(), the search will be restricted to
206
+ the provided configs. Use force=True to ignore the provided configs.
203
207
204
208
Mutates (the bound version of) self so that `__call__` will run the best config found.
205
209
206
210
:param args: Example arguments used for benchmarking during autotuning.
207
211
:type args: list[object]
212
+ :param force: If True, force full autotuning even if a config is provided.
213
+ :type force: bool
208
214
:return: The best configuration found during autotuning.
209
215
:rtype: Config
210
216
"""
211
217
args = self .normalize_args (* args )
212
- return self .bind (args ).autotune (args , ** options )
218
+ return self .bind (args ).autotune (args , force = force , ** options )
213
219
214
220
def __call__ (self , * args : object , ** kwargs : object ) -> object :
215
221
"""
@@ -278,8 +284,6 @@ def __init__(self, kernel: Kernel, args: tuple[object, ...]) -> None:
278
284
self .host_function : HostFunction = HostFunction (
279
285
self .kernel .fn , self .fake_args , constexpr_args
280
286
)
281
- if len (kernel .configs ) == 1 :
282
- self .set_config (kernel .configs [0 ])
283
287
284
288
@property
285
289
def settings (self ) -> Settings :
@@ -370,24 +374,34 @@ def _debug_str(self) -> str:
370
374
def autotune (
371
375
self ,
372
376
args : Sequence [object ],
377
+ * ,
378
+ force : bool = False ,
373
379
** kwargs : object ,
374
380
) -> Config :
375
381
"""
376
- Perform autotuning to find the optimal configuration for
377
- the kernel. This uses the default setting, you can call
378
- helion.autotune.* directly for more customization.
382
+ Perform autotuning to find the optimal configuration for the kernel. This uses the
383
+ default setting, you can call helion.autotune.* directly for more customization.
384
+
385
+ If config= or configs= is provided to helion.kernel(), the search will be restricted to
386
+ the provided configs. Use force=True to ignore the provided configs.
379
387
380
388
Mutates self so that `__call__` will run the best config found.
381
389
382
390
:param args: Example arguments used for benchmarking during autotuning.
383
391
:type args: list[object]
392
+ :param force: If True, force full autotuning even if a config is provided.
393
+ :type force: bool
384
394
:return: The best configuration found during autotuning.
385
395
:rtype: Config
386
396
"""
387
- if self .kernel .configs :
388
- from ..autotuner import FiniteSearch
397
+ force = force or self .settings .force_autotune
398
+ if not force and self .kernel .configs :
399
+ if len (self .kernel .configs ) == 1 :
400
+ (config ,) = self .kernel .configs
401
+ else :
402
+ from ..autotuner import FiniteSearch
389
403
390
- config = FiniteSearch (self , args , self .configs ).autotune ()
404
+ config = FiniteSearch (self , args , self .configs ).autotune ()
391
405
else :
392
406
from ..autotuner import DifferentialEvolutionSearch
393
407
0 commit comments