Name | weco JSON |
Version |
0.2.27
JSON |
| download |
home_page | None |
Summary | Documentation for `weco`, a CLI for using Weco AI's code optimizer. |
upload_time | 2025-09-03 16:50:19 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2025 Weco AI
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. |
keywords |
ai
code optimization
code generation
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<div align="center">
<div align="center">
<img src="assets/weco.svg" alt="Weco Logo" width="120" height="120" style="margin-bottom: 20px;">
<h1>Weco: The Platform for Self-Improving Code</h1>
</div>
[](https://www.python.org)
[](https://badge.fury.io/py/weco)
[](https://docs.weco.ai/)
[](https://pepy.tech/projects/weco)
[](https://arxiv.org/abs/2502.13138)
[](https://colab.research.google.com/github/WecoAI/weco-cli/blob/main/examples/hello-kernel-world/colab_notebook_walkthrough.ipynb)
`pip install weco`
</div>
---
Weco systematically optimizes your code, guided directly by your evaluation metrics.
Example applications include:
- **GPU Kernel Optimization**: Reimplement PyTorch functions using [CUDA](/examples/cuda/README.md) or [Triton](/examples/triton/README.md), optimizing for `latency`, `throughput`, or `memory_bandwidth`.
- **Model Development**: Tune feature transformations, architectures or [the whole training pipeline](/examples/spaceship-titanic/README.md), optimizing for `validation_accuracy`, `AUC`, or `Sharpe Ratio`.
- **Prompt Engineering**: Refine prompts for LLMs (e.g., for [math problems](/examples/prompt/README.md)), optimizing for `win_rate`, `relevance`, or `format_adherence`

---
## Overview
The `weco` CLI leverages a tree search approach guided by LLMs to iteratively explore and refine your code. It automatically applies changes, runs your evaluation script, parses the results, and proposes further improvements based on the specified goal.

---
## Setup
1. **Install the Package:**
```bash
pip install weco>=0.2.18
```
2. **Set Up LLM API Keys (Required):**
`weco` requires API keys for the LLMs it uses internally. You **must** provide these keys via environment variables:
- **OpenAI:** `export OPENAI_API_KEY="your_key_here"` (Create your OpenAI API key [here](https://platform.openai.com/api-keys))
- **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"` (Create your Anthropic API key [here](https://console.anthropic.com/settings/keys))
- **Google:** `export GEMINI_API_KEY="your_key_here"` (Google AI Studio has a free API usage quota. Create your Gemini API key [here](https://aistudio.google.com/apikey) to use `weco` for free.)
---
## Get Started
### Quick Start (Recommended for New Users)
The easiest way to get started with Weco is to use the **interactive copilot**. Simply navigate to your project directory and run:
```bash
weco
```
Or specify a project path:
```bash
weco /path/to/your/project
```
This launches Weco's interactive copilot that will:
1. **Analyze your codebase** using AI to understand your project structure and identify optimization opportunities
2. **Suggest specific optimizations** tailored to your code (e.g., GPU kernel optimization, model improvements, prompt engineering)
3. **Generate evaluation scripts** automatically or help you configure existing ones
4. **Set up the complete optimization pipeline** with appropriate metrics and commands
5. **Run the optimization** or provide you with the exact command to execute
<div style="background-color: #fff3cd; border: 1px solid #ffeeba; padding: 15px; border-radius: 4px; margin-bottom: 15px;">
<strong>⚠️ Warning: Code Modification</strong><br>
<code>weco</code> directly modifies the file specified by <code>--source</code> during the optimization process. It is <strong>strongly recommended</strong> to use version control (like Git) to track changes and revert if needed. Alternatively, ensure you have a backup of your original file before running the command. Upon completion, the file will contain the best-performing version of the code found during the run.
</div>
### Manual Setup
**Configure optimization parameters yourself** - If you need precise control over the optimization parameters, you can use the direct `weco run` command:
**Example: Optimizing Simple PyTorch Operations**
```bash
# Navigate to the example directory
cd examples/hello-kernel-world
# Install dependencies
pip install torch
# Run Weco with manual configuration
weco run --source optimize.py \
--eval-command "python evaluate.py --solution-path optimize.py --device cpu" \
--metric speedup \
--goal maximize \
--steps 15 \
--additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
```
**Note:** If you have an NVIDIA GPU, change the device in the `--eval-command` to `cuda`. If you are running this on Apple Silicon, set it to `mps`.
For more advanced examples, including [Triton](/examples/triton/README.md), [CUDA kernel optimization](/examples/cuda/README.md), [ML model optimization](/examples/spaceship-titanic/README.md), and [prompt engineering for math problems](examples/prompt/README.md), please see the `README.md` files within the corresponding subdirectories under the [`examples/`](examples/) folder.
---
### Arguments for `weco run`
**Required:**
| Argument | Description | Example |
| :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
| `-s, --source` | Path to the source code file that will be optimized. | `-s model.py` |
| `-c, --eval-command`| Command to run for evaluating the code in `--source`. This command should print the target `--metric` and its value to the terminal (stdout/stderr). See note below. | `-c "python eval.py"` |
| `-m, --metric` | The name of the metric you want to optimize (e.g., 'accuracy', 'speedup', 'loss'). This metric name does not need to match what's printed by your `--eval-command` exactly (e.g., its okay to use "speedup" instead of "Speedup:"). | `-m speedup` |
| `-g, --goal` | `maximize`/`max` to maximize the `--metric` or `minimize`/`min` to minimize it. | `-g maximize` |
<br>
**Optional:**
| Argument | Description | Default | Example |
| :----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------ |
| `-n, --steps` | Number of optimization steps (LLM iterations) to run. | 100 | `-n 50` |
| `-M, --model` | Model identifier for the LLM to use (e.g., `o4-mini`, `claude-sonnet-4-0`). | `o4-mini` when `OPENAI_API_KEY` is set; `claude-sonnet-4-0` when `ANTHROPIC_API_KEY` is set; `gemini-2.5-pro` when `GEMINI_API_KEY` is set. | `-M o4-mini` |
| `-i, --additional-instructions`| Natural language description of specific instructions **or** path to a file containing detailed instructions to guide the LLM. | `None` | `-i instructions.md` or `-i "Optimize the model for faster inference"`|
| `-l, --log-dir` | Path to the directory to log intermediate steps and final optimization result. | `.runs/` | `-l ./logs/` |
| `--eval-timeout` | Timeout in seconds for each step in evaluation. | No timeout (unlimited) | `--eval-timeout 3600` |
| `--save-logs` | Save execution output from each optimization step to disk. Creates timestamped directories with raw output files and a JSONL index for tracking execution history. | `False` | `--save-logs` |
---
### Authentication & Dashboard
Weco offers both **anonymous** and **authenticated** usage:
#### Anonymous Usage
You can use Weco without creating an account by providing LLM API keys via environment variables. This is perfect for trying out Weco or for users who prefer not to create accounts.
#### Authenticated Usage (Recommended)
To save your optimization runs and view them on the Weco dashboard, you can log in using Weco's secure device authentication flow:
1. **During onboarding**: When you run `weco` for the first time, you'll be prompted to log in or skip
2. **Manual login**: Use `weco logout` to clear credentials, then run `weco` again to re-authenticate
3. **Device flow**: Weco will open your browser automatically and guide you through a secure OAuth-style authentication

**Benefits of authenticated usage:**
- **Run history**: View all your optimization runs on the Weco dashboard
- **Progress tracking**: Monitor long-running optimizations remotely
- **Enhanced support**: Get better assistance with your optimization challenges
---
## Command Reference
### Basic Usage Patterns
| Command | Description | When to Use |
|---------|-------------|-------------|
| `weco` | Launch interactive onboarding | **Recommended for beginners** - Analyzes your codebase and guides you through setup |
| `weco /path/to/project` | Launch onboarding for specific project | When working with a project in a different directory |
| `weco run [options]` | Direct optimization execution | **For advanced users** - When you know exactly what to optimize and how |
| `weco logout` | Clear authentication credentials | To switch accounts or troubleshoot authentication issues |
### Model Selection
You can specify which LLM model to use with the `-M` or `--model` flag:
```bash
# Use with onboarding
weco --model gpt-4o
# Use with direct execution
weco run --model claude-3.5-sonnet --source optimize.py [other options...]
```
**Available models:**
- `gpt-4o`, `o4-mini` (requires `OPENAI_API_KEY`)
- `claude-3.5-sonnet`, `claude-sonnet-4-20250514` (requires `ANTHROPIC_API_KEY`)
- `gemini-2.5-pro` (requires `GEMINI_API_KEY`)
If no model is specified, Weco automatically selects the best available model based on your API keys.
---
### Performance & Expectations
Weco, powered by the AIDE algorithm, optimizes code iteratively based on your evaluation results. Achieving significant improvements, especially on complex research-level tasks, often requires substantial exploration time.
The following plot from the independent [Research Engineering Benchmark (RE-Bench)](https://metr.org/AI_R_D_Evaluation_Report.pdf) report shows the performance of AIDE (the algorithm behind Weco) on challenging ML research engineering tasks over different time budgets.
<p align="center">
<img src="https://github.com/user-attachments/assets/ff0e471d-2f50-4e2d-b718-874862f533df" alt="RE-Bench Performance Across Time" width="60%"/>
</p>
As shown, AIDE demonstrates strong performance gains over time, surpassing lower human expert percentiles within hours and continuing to improve. This highlights the potential of evaluation-driven optimization but also indicates that reaching high levels of performance comparable to human experts on difficult benchmarks can take considerable time (tens of hours in this specific benchmark, corresponding to many `--steps` in the Weco CLI). Factor this into your planning when setting the number of `--steps` for your optimization runs.
---
### Saving Execution Logs
When using the `--save-logs` flag, Weco saves the execution output from each optimization step to help with debugging and analysis. The logs are organized as follows:
```
.runs/
└── <source-file-name>/
└── <run-uuid>/
├── exec_output.jsonl # Index file with metadata for each step
├── outputs/
│ ├── step_0.out.txt # Raw output from initial evaluation
│ ├── step_1.out.txt # Raw output from step 1
│ ├── step_2.out.txt # Raw output from step 2
│ └── ...
├── step_0.py # Code snapshot from initial evaluation
├── step_1.py # Code snapshot from step 1
├── step_2.py # Code snapshot from step 2
└── ...
```
Each run is organized under the source file name (e.g., `spaceship-titanic` for `spaceship-titanic.py`) and a unique UUID. The `outputs/` directory and `exec_output.jsonl` file are only created when the `--save-logs` flag is used.
The `exec_output.jsonl` file contains one JSON object per line with:
- `step`: The optimization step number
- `timestamp`: When the execution occurred
- `output_file`: Relative path to the full output file
- `output_length`: Total length of the output
This is particularly useful for:
- Debugging why certain optimizations fail
- Analyzing patterns in evaluation results
- Keeping records of long-running optimization sessions
- Troubleshooting evaluation script issues
---
### Important Note on Evaluation
The command specified by `--eval-command` is crucial. It's responsible for executing the potentially modified code from `--source` and assessing its performance. **This command MUST print the metric you specified with `--metric` along with its numerical value to the terminal (standard output or standard error).** Weco reads this output to understand how well each code version performs and guide the optimization process.
For example, if you set `--metric speedup`, your evaluation script (`eval.py` in the examples) should output a line like:
```
speedup: 1.5
```
or
```
Final speedup value = 1.5
```
Weco will parse this output to extract the numerical value (1.5 in this case) associated with the metric name ('speedup').
**Note on Output Truncation:** When evaluation output exceeds 51,000 characters, Weco truncates it to show the first 25,000 and last 25,000 characters. For best results, ensure your evaluation script prints the metric value near the end of its output.
## Supported Models
Weco supports the following LLM models:
### OpenAI Models
- `gpt-5` (recommended)
- `gpt-5-mini`
- `gpt-5-nano`
- `o3-pro` (recommended)
- `o3` (recommended)
- `o4-mini` (recommended)
- `o3-mini`
- `o1-pro`
- `o1`
- `gpt-4.1`
- `gpt-4.1-mini`
- `gpt-4.1-nano`
- `gpt-4o`
- `gpt-4o-mini`
- `codex-mini-latest`
### Anthropic Models
- `claude-opus-4-1`
- `claude-opus-4-0`
- `claude-sonnet-4-0`
- `claude-3-7-sonnet-latest`
### Gemini Models
- `gemini-2.5-pro`
- `gemini-2.5-flash`
- `gemini-2.5-flash-lite`
You can specify any of these models using the `-M` or `--model` flag. Ensure you have the corresponding API key set as an environment variable for the model provider you wish to use.
---
## Contributing
We welcome contributions! Please see [contributing.md](contributing.md) for detailed guidelines on how to contribute to this project.
---
Raw data
{
"_id": null,
"home_page": null,
"name": "weco",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "AI, Code Optimization, Code Generation",
"author": null,
"author_email": "Weco AI Team <contact@weco.ai>",
"download_url": "https://files.pythonhosted.org/packages/d3/bd/5957232a7d2ebe5dd2559131734099a1eb989472134129c36e4a83dfbd0f/weco-0.2.27.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n\n<div align=\"center\">\n <img src=\"assets/weco.svg\" alt=\"Weco Logo\" width=\"120\" height=\"120\" style=\"margin-bottom: 20px;\">\n <h1>Weco: The Platform for Self-Improving Code</h1>\n</div>\n\n[](https://www.python.org)\n[](https://badge.fury.io/py/weco)\n[](https://docs.weco.ai/)\n[](https://pepy.tech/projects/weco)\n[](https://arxiv.org/abs/2502.13138)\n[](https://colab.research.google.com/github/WecoAI/weco-cli/blob/main/examples/hello-kernel-world/colab_notebook_walkthrough.ipynb)\n\n`pip install weco`\n\n</div>\n\n---\n\nWeco systematically optimizes your code, guided directly by your evaluation metrics.\n\nExample applications include:\n\n- **GPU Kernel Optimization**: Reimplement PyTorch functions using [CUDA](/examples/cuda/README.md) or [Triton](/examples/triton/README.md), optimizing for `latency`, `throughput`, or `memory_bandwidth`.\n- **Model Development**: Tune feature transformations, architectures or [the whole training pipeline](/examples/spaceship-titanic/README.md), optimizing for `validation_accuracy`, `AUC`, or `Sharpe Ratio`.\n- **Prompt Engineering**: Refine prompts for LLMs (e.g., for [math problems](/examples/prompt/README.md)), optimizing for `win_rate`, `relevance`, or `format_adherence`\n\n\n\n---\n\n## Overview\n\nThe `weco` CLI leverages a tree search approach guided by LLMs to iteratively explore and refine your code. It automatically applies changes, runs your evaluation script, parses the results, and proposes further improvements based on the specified goal.\n\n\n\n---\n\n## Setup\n\n1. **Install the Package:**\n\n ```bash\n pip install weco>=0.2.18\n ```\n\n2. **Set Up LLM API Keys (Required):**\n\n `weco` requires API keys for the LLMs it uses internally. You **must** provide these keys via environment variables:\n\n - **OpenAI:** `export OPENAI_API_KEY=\"your_key_here\"` (Create your OpenAI API key [here](https://platform.openai.com/api-keys))\n - **Anthropic:** `export ANTHROPIC_API_KEY=\"your_key_here\"` (Create your Anthropic API key [here](https://console.anthropic.com/settings/keys))\n - **Google:** `export GEMINI_API_KEY=\"your_key_here\"` (Google AI Studio has a free API usage quota. Create your Gemini API key [here](https://aistudio.google.com/apikey) to use `weco` for free.)\n\n---\n\n## Get Started\n\n### Quick Start (Recommended for New Users)\n\nThe easiest way to get started with Weco is to use the **interactive copilot**. Simply navigate to your project directory and run:\n\n```bash\nweco\n```\n\nOr specify a project path:\n\n```bash\nweco /path/to/your/project\n```\n\nThis launches Weco's interactive copilot that will:\n\n1. **Analyze your codebase** using AI to understand your project structure and identify optimization opportunities\n2. **Suggest specific optimizations** tailored to your code (e.g., GPU kernel optimization, model improvements, prompt engineering)\n3. **Generate evaluation scripts** automatically or help you configure existing ones\n4. **Set up the complete optimization pipeline** with appropriate metrics and commands\n5. **Run the optimization** or provide you with the exact command to execute\n\n<div style=\"background-color: #fff3cd; border: 1px solid #ffeeba; padding: 15px; border-radius: 4px; margin-bottom: 15px;\">\n <strong>\u26a0\ufe0f Warning: Code Modification</strong><br>\n <code>weco</code> directly modifies the file specified by <code>--source</code> during the optimization process. It is <strong>strongly recommended</strong> to use version control (like Git) to track changes and revert if needed. Alternatively, ensure you have a backup of your original file before running the command. Upon completion, the file will contain the best-performing version of the code found during the run.\n</div>\n\n### Manual Setup\n\n**Configure optimization parameters yourself** - If you need precise control over the optimization parameters, you can use the direct `weco run` command:\n\n**Example: Optimizing Simple PyTorch Operations**\n\n```bash\n# Navigate to the example directory\ncd examples/hello-kernel-world\n\n# Install dependencies\npip install torch\n\n# Run Weco with manual configuration\nweco run --source optimize.py \\\n --eval-command \"python evaluate.py --solution-path optimize.py --device cpu\" \\\n --metric speedup \\\n --goal maximize \\\n --steps 15 \\\n --additional-instructions \"Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code.\"\n```\n\n**Note:** If you have an NVIDIA GPU, change the device in the `--eval-command` to `cuda`. If you are running this on Apple Silicon, set it to `mps`.\n\nFor more advanced examples, including [Triton](/examples/triton/README.md), [CUDA kernel optimization](/examples/cuda/README.md), [ML model optimization](/examples/spaceship-titanic/README.md), and [prompt engineering for math problems](examples/prompt/README.md), please see the `README.md` files within the corresponding subdirectories under the [`examples/`](examples/) folder.\n\n---\n\n### Arguments for `weco run`\n\n**Required:**\n\n| Argument | Description | Example |\n| :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |\n| `-s, --source` | Path to the source code file that will be optimized. | `-s model.py` |\n| `-c, --eval-command`| Command to run for evaluating the code in `--source`. This command should print the target `--metric` and its value to the terminal (stdout/stderr). See note below. | `-c \"python eval.py\"` |\n| `-m, --metric` | The name of the metric you want to optimize (e.g., 'accuracy', 'speedup', 'loss'). This metric name does not need to match what's printed by your `--eval-command` exactly (e.g., its okay to use \"speedup\" instead of \"Speedup:\"). | `-m speedup` |\n| `-g, --goal` | `maximize`/`max` to maximize the `--metric` or `minimize`/`min` to minimize it. | `-g maximize` |\n\n<br>\n\n**Optional:**\n\n| Argument | Description | Default | Example |\n| :----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------ |\n| `-n, --steps` | Number of optimization steps (LLM iterations) to run. | 100 | `-n 50` |\n| `-M, --model` | Model identifier for the LLM to use (e.g., `o4-mini`, `claude-sonnet-4-0`). | `o4-mini` when `OPENAI_API_KEY` is set; `claude-sonnet-4-0` when `ANTHROPIC_API_KEY` is set; `gemini-2.5-pro` when `GEMINI_API_KEY` is set. | `-M o4-mini` |\n| `-i, --additional-instructions`| Natural language description of specific instructions **or** path to a file containing detailed instructions to guide the LLM. | `None` | `-i instructions.md` or `-i \"Optimize the model for faster inference\"`|\n| `-l, --log-dir` | Path to the directory to log intermediate steps and final optimization result. | `.runs/` | `-l ./logs/` |\n| `--eval-timeout` | Timeout in seconds for each step in evaluation. | No timeout (unlimited) | `--eval-timeout 3600` |\n| `--save-logs` | Save execution output from each optimization step to disk. Creates timestamped directories with raw output files and a JSONL index for tracking execution history. | `False` | `--save-logs` |\n\n---\n\n### Authentication & Dashboard\n\nWeco offers both **anonymous** and **authenticated** usage:\n\n#### Anonymous Usage\nYou can use Weco without creating an account by providing LLM API keys via environment variables. This is perfect for trying out Weco or for users who prefer not to create accounts.\n\n#### Authenticated Usage (Recommended)\nTo save your optimization runs and view them on the Weco dashboard, you can log in using Weco's secure device authentication flow:\n\n1. **During onboarding**: When you run `weco` for the first time, you'll be prompted to log in or skip\n2. **Manual login**: Use `weco logout` to clear credentials, then run `weco` again to re-authenticate\n3. **Device flow**: Weco will open your browser automatically and guide you through a secure OAuth-style authentication\n\n\n\n**Benefits of authenticated usage:**\n- **Run history**: View all your optimization runs on the Weco dashboard\n- **Progress tracking**: Monitor long-running optimizations remotely\n- **Enhanced support**: Get better assistance with your optimization challenges\n\n---\n\n## Command Reference\n\n### Basic Usage Patterns\n\n| Command | Description | When to Use |\n|---------|-------------|-------------|\n| `weco` | Launch interactive onboarding | **Recommended for beginners** - Analyzes your codebase and guides you through setup |\n| `weco /path/to/project` | Launch onboarding for specific project | When working with a project in a different directory |\n| `weco run [options]` | Direct optimization execution | **For advanced users** - When you know exactly what to optimize and how |\n| `weco logout` | Clear authentication credentials | To switch accounts or troubleshoot authentication issues |\n\n### Model Selection\n\nYou can specify which LLM model to use with the `-M` or `--model` flag:\n\n```bash\n# Use with onboarding\nweco --model gpt-4o\n\n# Use with direct execution\nweco run --model claude-3.5-sonnet --source optimize.py [other options...]\n```\n\n**Available models:**\n- `gpt-4o`, `o4-mini` (requires `OPENAI_API_KEY`)\n- `claude-3.5-sonnet`, `claude-sonnet-4-20250514` (requires `ANTHROPIC_API_KEY`)\n- `gemini-2.5-pro` (requires `GEMINI_API_KEY`)\n\nIf no model is specified, Weco automatically selects the best available model based on your API keys.\n\n---\n\n### Performance & Expectations\n\nWeco, powered by the AIDE algorithm, optimizes code iteratively based on your evaluation results. Achieving significant improvements, especially on complex research-level tasks, often requires substantial exploration time.\n\nThe following plot from the independent [Research Engineering Benchmark (RE-Bench)](https://metr.org/AI_R_D_Evaluation_Report.pdf) report shows the performance of AIDE (the algorithm behind Weco) on challenging ML research engineering tasks over different time budgets.\n\n<p align=\"center\">\n<img src=\"https://github.com/user-attachments/assets/ff0e471d-2f50-4e2d-b718-874862f533df\" alt=\"RE-Bench Performance Across Time\" width=\"60%\"/>\n</p>\n\nAs shown, AIDE demonstrates strong performance gains over time, surpassing lower human expert percentiles within hours and continuing to improve. This highlights the potential of evaluation-driven optimization but also indicates that reaching high levels of performance comparable to human experts on difficult benchmarks can take considerable time (tens of hours in this specific benchmark, corresponding to many `--steps` in the Weco CLI). Factor this into your planning when setting the number of `--steps` for your optimization runs.\n\n---\n\n### Saving Execution Logs\n\nWhen using the `--save-logs` flag, Weco saves the execution output from each optimization step to help with debugging and analysis. The logs are organized as follows:\n\n```\n.runs/\n\u2514\u2500\u2500 <source-file-name>/\n \u2514\u2500\u2500 <run-uuid>/\n \u251c\u2500\u2500 exec_output.jsonl # Index file with metadata for each step\n \u251c\u2500\u2500 outputs/\n \u2502 \u251c\u2500\u2500 step_0.out.txt # Raw output from initial evaluation\n \u2502 \u251c\u2500\u2500 step_1.out.txt # Raw output from step 1\n \u2502 \u251c\u2500\u2500 step_2.out.txt # Raw output from step 2\n \u2502 \u2514\u2500\u2500 ...\n \u251c\u2500\u2500 step_0.py # Code snapshot from initial evaluation\n \u251c\u2500\u2500 step_1.py # Code snapshot from step 1\n \u251c\u2500\u2500 step_2.py # Code snapshot from step 2\n \u2514\u2500\u2500 ...\n```\n\nEach run is organized under the source file name (e.g., `spaceship-titanic` for `spaceship-titanic.py`) and a unique UUID. The `outputs/` directory and `exec_output.jsonl` file are only created when the `--save-logs` flag is used.\n\nThe `exec_output.jsonl` file contains one JSON object per line with:\n- `step`: The optimization step number\n- `timestamp`: When the execution occurred\n- `output_file`: Relative path to the full output file\n- `output_length`: Total length of the output\n\nThis is particularly useful for:\n- Debugging why certain optimizations fail\n- Analyzing patterns in evaluation results\n- Keeping records of long-running optimization sessions\n- Troubleshooting evaluation script issues\n\n---\n\n### Important Note on Evaluation\n\nThe command specified by `--eval-command` is crucial. It's responsible for executing the potentially modified code from `--source` and assessing its performance. **This command MUST print the metric you specified with `--metric` along with its numerical value to the terminal (standard output or standard error).** Weco reads this output to understand how well each code version performs and guide the optimization process.\n\nFor example, if you set `--metric speedup`, your evaluation script (`eval.py` in the examples) should output a line like:\n\n```\nspeedup: 1.5\n```\n\nor\n\n```\nFinal speedup value = 1.5\n```\n\nWeco will parse this output to extract the numerical value (1.5 in this case) associated with the metric name ('speedup').\n\n**Note on Output Truncation:** When evaluation output exceeds 51,000 characters, Weco truncates it to show the first 25,000 and last 25,000 characters. For best results, ensure your evaluation script prints the metric value near the end of its output.\n\n## Supported Models\n\nWeco supports the following LLM models:\n\n### OpenAI Models\n- `gpt-5` (recommended)\n- `gpt-5-mini`\n- `gpt-5-nano`\n- `o3-pro` (recommended)\n- `o3` (recommended)\n- `o4-mini` (recommended)\n- `o3-mini`\n- `o1-pro`\n- `o1`\n- `gpt-4.1`\n- `gpt-4.1-mini`\n- `gpt-4.1-nano`\n- `gpt-4o`\n- `gpt-4o-mini`\n- `codex-mini-latest`\n\n### Anthropic Models\n- `claude-opus-4-1`\n- `claude-opus-4-0`\n- `claude-sonnet-4-0`\n- `claude-3-7-sonnet-latest`\n\n### Gemini Models\n- `gemini-2.5-pro`\n- `gemini-2.5-flash`\n- `gemini-2.5-flash-lite`\n\nYou can specify any of these models using the `-M` or `--model` flag. Ensure you have the corresponding API key set as an environment variable for the model provider you wish to use.\n\n---\n\n## Contributing\n\nWe welcome contributions! Please see [contributing.md](contributing.md) for detailed guidelines on how to contribute to this project.\n\n---\n",
"bugtrack_url": null,
"license": "Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n \n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n \n 1. Definitions.\n \n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n \n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n \n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n \n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n \n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n \n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n \n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n \n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n \n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n \n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n \n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n \n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n \n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n \n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n \n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n \n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n \n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n \n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n \n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n \n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n \n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n \n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n \n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n \n END OF TERMS AND CONDITIONS\n \n APPENDIX: How to apply the Apache License to your work.\n \n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n \n Copyright 2025 Weco AI\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.",
"summary": "Documentation for `weco`, a CLI for using Weco AI's code optimizer.",
"version": "0.2.27",
"project_urls": {
"Homepage": "https://github.com/WecoAI/weco-cli"
},
"split_keywords": [
"ai",
" code optimization",
" code generation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a52d68de999f532fa720e86c123c1e14e537f9e458cb56800b8df8e29935bf3a",
"md5": "abeba9ea0354784caed0e3ea271c2389",
"sha256": "ba9d217179568201576cd195a536c10dc33cafb1f98ab57ba0c0f44caf4e0931"
},
"downloads": -1,
"filename": "weco-0.2.27-py3-none-any.whl",
"has_sig": false,
"md5_digest": "abeba9ea0354784caed0e3ea271c2389",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 47126,
"upload_time": "2025-09-03T16:50:17",
"upload_time_iso_8601": "2025-09-03T16:50:17.762523Z",
"url": "https://files.pythonhosted.org/packages/a5/2d/68de999f532fa720e86c123c1e14e537f9e458cb56800b8df8e29935bf3a/weco-0.2.27-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d3bd5957232a7d2ebe5dd2559131734099a1eb989472134129c36e4a83dfbd0f",
"md5": "15d6f9968e1833f1acb56cf561c624c0",
"sha256": "e38bb447cf27eb17452417a60a9a7ad230f8944f2a9f4a5e7a1d32e40e7c902f"
},
"downloads": -1,
"filename": "weco-0.2.27.tar.gz",
"has_sig": false,
"md5_digest": "15d6f9968e1833f1acb56cf561c624c0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 39477341,
"upload_time": "2025-09-03T16:50:19",
"upload_time_iso_8601": "2025-09-03T16:50:19.900934Z",
"url": "https://files.pythonhosted.org/packages/d3/bd/5957232a7d2ebe5dd2559131734099a1eb989472134129c36e4a83dfbd0f/weco-0.2.27.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-03 16:50:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "WecoAI",
"github_project": "weco-cli",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "weco"
}