Weco Logo
Weco Docs

Hello, World!

Here is the quickest way to get started with Weco.

This tutorial demonstrates core features of Weco by speeding up a simple PyTorch module.

Open In Colab

Prerequisites: You'll need a terminal and Python 3.8 or newer.

Install Weco

pip install weco

Download the example project

git clone https://github.com/WecoAI/weco-cli.git
cd weco-cli/examples/hello-world/
pip install -r requirements.txt

Run the optimization

weco run --source module.py \
    --eval-command "python evaluate.py --path module.py" \
    --metric speedup \
    --goal maximize \
    --steps 10 \
    --additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."

Weco will now run 10 iterations to optimize module.py. At each iteration, it will:

  1. Generate an improved version of the module and update the file
  2. Run evaluate.py to measure the speedup
  3. Use the results to propose the next optimization

After 10 iterations, module.py will contain the fastest version discovered.

Weco can optimize any code file, not just kernels. In the next page, you'll learn how to set up your own optimization.

Watch the optimization in action

In CLI

Watch Weco speed up the kernel in action:

Weco Optimization Example

In Browser

We also provide a dashboard that you can use to visualize and interact with the optimization process.

See the example optimization run here.

Hello world dashboard

🎯 Next Step: Optimize Your Own Code

Great job! You've successfully run Weco on an example project. Now it's time to apply it to your own code.

In the next guide, you'll learn:

  • ✅ How to create evaluation scripts for your code
  • ✅ Step-by-step instructions to optimize your own projects
  • ✅ Best practices for getting the best results from Weco

On this page