PyTorch Optimization
Optimize the speed of simple operation in PyTorch
You can:
- Follow along here
- Checkout the files from GitHub
- Run the Colab Notebook (recommended)
Setup
If you haven't already, follow the Installation guide to install the Weco CLI. Otherwise, install the CLI using pip
:
Google AI Studio has a free API usage quota. Create a key here to use weco
for free.
Install the dependencies of the scripts shown in subsequent sections.
Create the Baseline to Optimize
Create a file called optimize.py
with the following code:
Create the Evaluation Script
Create a file called evaluate.py
with the following code:
Run Weco
Now run Weco to optimize your code:
Here's what you can expect to see (keep an eye on that Best Solution
panel):

Note: If you have an NVIDIA GPU, change the device in the
--eval-command
tocuda
. If you are running this on Apple Silicon, set it tomps
.
For more examples, visit the Examples section.