Enable User-Driven Early Termination and Caching in Autotuning#1361
Enable User-Driven Early Termination and Caching in Autotuning#1361hinriksnaer wants to merge 2 commits intopytorch:mainfrom
Conversation
oulgen
left a comment
There was a problem hiding this comment.
So I'm not entirely convinced that we should cache keyboard interrupted configs by default. Maybe we should prompt the user to ask whether they want to save it. Or maybe some checkpoint system similar to what @yf225 was thinking.
If I ctrl-C during autotune, i dont always want to keep that and having to find and delete the cache file might be annoying
|
Thanks for sharing @oulgen. Given that this is still in active development, I assume the best thing to do is to wait until the changes land and leverage that functionality to support early stopping. What do you think? |
|
Yes I think once the auto-checkpoint feature is in, we can build on top of it to automatically trigger a checkpoint save when user hits Ctrl-C, which will also print instructions on how to resume from the saved checkpoint. |
Implements #1331
Summary
Adds support for gracefully terminating autotuning early (via
CTRL+C) while saving the best configuration found so far. This allows users to stop autotuning when they see diminishing returns without losing progress.Implementation
_handle_early_termination()method toAutotuneCacheBasethat extracts the best benchmarked configautotuner.autotune()calls in both code paths (skip_cache and normal) withtry/except KeyboardInterruptUsers who want immediate termination can press
CTRL+Ctwice or usekill -9.Discussion
Using
trylike this never feels elegant enough to me. I did consider making this cleaner with a decorator, but I'd rather keep things simple for now and get some feedback before overcomplicating this.Are we good on
CTRL+Cinvoking this or do we want to consider something else? I am also not sure if we should prompt the user for this or guard this behind a flag.