weco 0.2.4__py3-none-any.whl → 0.2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- weco/__init__.py +1 -1
- weco/api.py +8 -2
- weco/cli.py +11 -2
- weco-0.2.5.dist-info/METADATA +189 -0
- weco-0.2.5.dist-info/RECORD +11 -0
- weco-0.2.4.dist-info/METADATA +0 -141
- weco-0.2.4.dist-info/RECORD +0 -11
- {weco-0.2.4.dist-info → weco-0.2.5.dist-info}/WHEEL +0 -0
- {weco-0.2.4.dist-info → weco-0.2.5.dist-info}/entry_points.txt +0 -0
- {weco-0.2.4.dist-info → weco-0.2.5.dist-info}/licenses/LICENSE +0 -0
- {weco-0.2.4.dist-info → weco-0.2.5.dist-info}/top_level.txt +0 -0
weco/__init__.py
CHANGED
weco/api.py
CHANGED
|
@@ -29,6 +29,7 @@ def start_optimization_session(
|
|
|
29
29
|
search_policy_config: Dict[str, Any],
|
|
30
30
|
additional_instructions: str = None,
|
|
31
31
|
api_keys: Dict[str, Any] = {},
|
|
32
|
+
timeout: int = 800,
|
|
32
33
|
) -> Dict[str, Any]:
|
|
33
34
|
"""Start the optimization session."""
|
|
34
35
|
with console.status("[bold green]Starting Optimization..."):
|
|
@@ -47,6 +48,7 @@ def start_optimization_session(
|
|
|
47
48
|
},
|
|
48
49
|
"metadata": {"client_name": "cli", "client_version": __pkg_version__, **api_keys},
|
|
49
50
|
},
|
|
51
|
+
timeout=timeout,
|
|
50
52
|
)
|
|
51
53
|
response.raise_for_status()
|
|
52
54
|
return response.json()
|
|
@@ -60,6 +62,7 @@ def evaluate_feedback_then_suggest_next_solution(
|
|
|
60
62
|
execution_output: str,
|
|
61
63
|
additional_instructions: str = None,
|
|
62
64
|
api_keys: Dict[str, Any] = {},
|
|
65
|
+
timeout: int = 800,
|
|
63
66
|
) -> Dict[str, Any]:
|
|
64
67
|
"""Evaluate the feedback and suggest the next solution."""
|
|
65
68
|
try:
|
|
@@ -70,6 +73,7 @@ def evaluate_feedback_then_suggest_next_solution(
|
|
|
70
73
|
"additional_instructions": additional_instructions,
|
|
71
74
|
"metadata": {**api_keys},
|
|
72
75
|
},
|
|
76
|
+
timeout=timeout,
|
|
73
77
|
)
|
|
74
78
|
response.raise_for_status()
|
|
75
79
|
return response.json()
|
|
@@ -78,11 +82,13 @@ def evaluate_feedback_then_suggest_next_solution(
|
|
|
78
82
|
|
|
79
83
|
|
|
80
84
|
def get_optimization_session_status(
|
|
81
|
-
console: rich.console.Console, session_id: str, include_history: bool = False
|
|
85
|
+
console: rich.console.Console, session_id: str, include_history: bool = False, timeout: int = 800
|
|
82
86
|
) -> Dict[str, Any]:
|
|
83
87
|
"""Get the current status of the optimization session."""
|
|
84
88
|
try:
|
|
85
|
-
response = requests.get(
|
|
89
|
+
response = requests.get(
|
|
90
|
+
f"{__base_url__}/sessions/{session_id}", params={"include_history": include_history}, timeout=timeout
|
|
91
|
+
)
|
|
86
92
|
response.raise_for_status()
|
|
87
93
|
return response.json()
|
|
88
94
|
except requests.exceptions.HTTPError as e:
|
weco/cli.py
CHANGED
|
@@ -79,6 +79,8 @@ def main() -> None:
|
|
|
79
79
|
source_code = read_from_path(fp=source_fp, is_json=False)
|
|
80
80
|
# Read API keys
|
|
81
81
|
api_keys = read_api_keys_from_env()
|
|
82
|
+
# API request timeout
|
|
83
|
+
timeout = 800
|
|
82
84
|
|
|
83
85
|
# Initialize panels
|
|
84
86
|
summary_panel = SummaryPanel(maximize=maximize, metric_name=metric_name, total_steps=steps, model=args.model)
|
|
@@ -102,6 +104,7 @@ def main() -> None:
|
|
|
102
104
|
search_policy_config=search_policy_config,
|
|
103
105
|
additional_instructions=additional_instructions,
|
|
104
106
|
api_keys=api_keys,
|
|
107
|
+
timeout=timeout,
|
|
105
108
|
)
|
|
106
109
|
|
|
107
110
|
# Define the refresh rate
|
|
@@ -192,6 +195,7 @@ def main() -> None:
|
|
|
192
195
|
execution_output=term_out,
|
|
193
196
|
additional_instructions=additional_instructions,
|
|
194
197
|
api_keys=api_keys,
|
|
198
|
+
timeout=timeout,
|
|
195
199
|
)
|
|
196
200
|
# Save next solution (.runs/<session-id>/step_<step>.py)
|
|
197
201
|
write_to_path(fp=runs_dir / f"step_{step}.py", content=eval_and_next_solution_response["code"])
|
|
@@ -201,7 +205,9 @@ def main() -> None:
|
|
|
201
205
|
|
|
202
206
|
# Get the optimization session status for
|
|
203
207
|
# the best solution, its score, and the history to plot the tree
|
|
204
|
-
status_response = get_optimization_session_status(
|
|
208
|
+
status_response = get_optimization_session_status(
|
|
209
|
+
console=console, session_id=session_id, include_history=True, timeout=timeout
|
|
210
|
+
)
|
|
205
211
|
|
|
206
212
|
# Update the step of the progress bar
|
|
207
213
|
summary_panel.set_step(step=step)
|
|
@@ -281,6 +287,7 @@ def main() -> None:
|
|
|
281
287
|
execution_output=term_out,
|
|
282
288
|
additional_instructions=additional_instructions,
|
|
283
289
|
api_keys=api_keys,
|
|
290
|
+
timeout=timeout,
|
|
284
291
|
)
|
|
285
292
|
|
|
286
293
|
# Update the progress bar
|
|
@@ -290,7 +297,9 @@ def main() -> None:
|
|
|
290
297
|
# No need to update the plan panel since we have finished the optimization
|
|
291
298
|
# Get the optimization session status for
|
|
292
299
|
# the best solution, its score, and the history to plot the tree
|
|
293
|
-
status_response = get_optimization_session_status(
|
|
300
|
+
status_response = get_optimization_session_status(
|
|
301
|
+
console=console, session_id=session_id, include_history=True, timeout=timeout
|
|
302
|
+
)
|
|
294
303
|
# Build the metric tree
|
|
295
304
|
tree_panel.build_metric_tree(nodes=status_response["history"])
|
|
296
305
|
# No need to set any solution to unevaluated since we have finished the optimization
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: weco
|
|
3
|
+
Version: 0.2.5
|
|
4
|
+
Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
|
|
5
|
+
Author-email: Weco AI Team <dhruv@weco.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/WecoAI/weco-cli
|
|
8
|
+
Keywords: AI,Code Optimization,Code Generation
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests
|
|
16
|
+
Requires-Dist: rich
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: ruff; extra == "dev"
|
|
19
|
+
Requires-Dist: build; extra == "dev"
|
|
20
|
+
Requires-Dist: setuptools_scm; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# Weco CLI – Code Optimizer for Machine Learning Engineers
|
|
24
|
+
|
|
25
|
+
[](https://www.python.org)
|
|
26
|
+
[](LICENSE)
|
|
27
|
+
[](https://badge.fury.io/py/weco)
|
|
28
|
+
|
|
29
|
+
`weco` is a command-line interface for interacting with Weco AI's code optimizer, powered by [AI-Driven Exploration](https://arxiv.org/abs/2502.13138). It helps you automate the improvement of your code for tasks like GPU kernel optimization, feature engineering, model development, and prompt engineering.
|
|
30
|
+
|
|
31
|
+
https://github.com/user-attachments/assets/cb724ef1-bff6-4757-b457-d3b2201ede81
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
|
|
37
|
+
The `weco` CLI leverages a tree search approach guided by Large Language Models (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.
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Example Use Cases
|
|
44
|
+
|
|
45
|
+
Here's how `weco` can be applied to common ML engineering tasks:
|
|
46
|
+
|
|
47
|
+
* **GPU Kernel Optimization:**
|
|
48
|
+
* **Goal:** Improve the speed or efficiency of low-level GPU code.
|
|
49
|
+
* **How:** `weco` iteratively refines CUDA, Triton, Metal, or other kernel code specified in your `--source` file.
|
|
50
|
+
* **`--eval-command`:** Typically runs a script that compiles the kernel, executes it, and benchmarks performance (e.g., latency, throughput).
|
|
51
|
+
* **`--metric`:** Examples include `latency`, `throughput`, `TFLOPS`, `memory_bandwidth`. Optimize to `minimize` latency or `maximize` throughput.
|
|
52
|
+
|
|
53
|
+
* **Feature Engineering:**
|
|
54
|
+
* **Goal:** Discover better data transformations or feature combinations for your machine learning models.
|
|
55
|
+
* **How:** `weco` explores different processing steps or parameters within your feature transformation code (`--source`).
|
|
56
|
+
* **`--eval-command`:** Executes a script that applies the features, trains/validates a model using those features, and prints a performance score.
|
|
57
|
+
* **`--metric`:** Examples include `accuracy`, `AUC`, `F1-score`, `validation_loss`. Usually optimized to `maximize` accuracy/AUC/F1 or `minimize` loss.
|
|
58
|
+
|
|
59
|
+
* **Model Development:**
|
|
60
|
+
* **Goal:** Tune hyperparameters or experiment with small architectural changes directly within your model's code.
|
|
61
|
+
* **How:** `weco` modifies hyperparameter values (like learning rate, layer sizes if defined in the code) or structural elements in your model definition (`--source`).
|
|
62
|
+
* **`--eval-command`:** Runs your model training and evaluation script, printing the key performance indicator.
|
|
63
|
+
* **`--metric`:** Examples include `validation_accuracy`, `test_loss`, `inference_time`, `perplexity`. Optimize according to the metric's nature (e.g., `maximize` accuracy, `minimize` loss).
|
|
64
|
+
|
|
65
|
+
* **Prompt Engineering:**
|
|
66
|
+
* **Goal:** Refine prompts used within larger systems (e.g., for LLM interactions) to achieve better or more consistent outputs.
|
|
67
|
+
* **How:** `weco` modifies prompt templates, examples, or instructions stored in the `--source` file.
|
|
68
|
+
* **`--eval-command`:** Executes a script that uses the prompt, generates an output, evaluates that output against desired criteria (e.g., using another LLM, checking for keywords, format validation), and prints a score.
|
|
69
|
+
* **`--metric`:** Examples include `quality_score`, `relevance`, `task_success_rate`, `format_adherence`. Usually optimized to `maximize`.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Setup
|
|
75
|
+
|
|
76
|
+
1. **Install the Package:**
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install weco
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. **Configure API Keys:**
|
|
83
|
+
|
|
84
|
+
Set the appropriate environment variables for your desired language model provider:
|
|
85
|
+
|
|
86
|
+
- **OpenAI:** `export OPENAI_API_KEY="your_key_here"`
|
|
87
|
+
- **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"`
|
|
88
|
+
- **Google DeepMind:** `export GEMINI_API_KEY="your_key_here"` (Google AI Studio has a free API usage quota. Create a key [here](https://aistudio.google.com/apikey) to use weco for free.)
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Usage
|
|
93
|
+
<div style="background-color: #fff3cd; border: 1px solid #ffeeba; padding: 15px; border-radius: 4px; margin-bottom: 15px;">
|
|
94
|
+
<strong>⚠️ Warning: Code Modification</strong><br>
|
|
95
|
+
<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.
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### Examples
|
|
101
|
+
|
|
102
|
+
**Example 1: Optimizing PyTorch operations**
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
weco --source examples/simple-torch/optimize.py \
|
|
106
|
+
--eval-command "python examples/simple-torch/evaluate.py --solution-path examples/simple-torch/optimize.py --device mps" \
|
|
107
|
+
--metric speedup \
|
|
108
|
+
--maximize true \
|
|
109
|
+
--steps 15 \
|
|
110
|
+
--model o3-mini \
|
|
111
|
+
--additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Example 2: Optimizing MLX operations with instructions from a file**
|
|
115
|
+
|
|
116
|
+
Sometimes, additional context or instructions are too complex for a single command-line string. You can provide a path to a file containing these instructions.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
weco --source examples/simple-mlx/optimize.py \
|
|
120
|
+
--eval-command "python examples/simple-mlx/evaluate.py --solution-path examples/simple-mlx/optimize.py" \
|
|
121
|
+
--metric speedup \
|
|
122
|
+
--maximize true \
|
|
123
|
+
--steps 30 \
|
|
124
|
+
--model o3-mini \
|
|
125
|
+
--additional-instructions examples/simple-mlx/metal-examples.rst
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### Command Line Arguments
|
|
131
|
+
|
|
132
|
+
| Argument | Description | Required |
|
|
133
|
+
| :-------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
|
|
134
|
+
| `--source` | Path to the source code file that will be optimized (e.g., `optimize.py`). | Yes |
|
|
135
|
+
| `--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. | Yes |
|
|
136
|
+
| `--metric` | The name of the metric you want to optimize (e.g., 'accuracy', 'speedup', 'loss'). This metric name should match what's printed by your `--eval-command`. | Yes |
|
|
137
|
+
| `--maximize` | Whether to maximize (`true`) or minimize (`false`) the metric. | Yes |
|
|
138
|
+
| `--steps` | Number of optimization steps (LLM iterations) to run. | Yes |
|
|
139
|
+
| `--model` | Model identifier for the LLM to use (e.g., `gpt-4o`, `claude-3.5-sonnet`). Recommended models to try include `o3-mini`, `claude-3-haiku`, and `gemini-2.5-pro-exp-03-25`. | Yes |
|
|
140
|
+
| `--additional-instructions` | (Optional) Natural language description of specific instructions OR path to a file containing detailed instructions to guide the LLM. | No |
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Important Note on Evaluation
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
For example, if you set `--metric speedup`, your evaluation script (`eval.py` in the examples) should output a line like:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
speedup: 1.5
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
or
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
Final speedup value = 1.5
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Weco will parse this output to extract the numerical value (1.5 in this case) associated with the metric name ('speedup').
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
## Contributing
|
|
166
|
+
|
|
167
|
+
We welcome contributions! To get started:
|
|
168
|
+
|
|
169
|
+
1. **Fork and Clone the Repository:**
|
|
170
|
+
```bash
|
|
171
|
+
git clone https://github.com/WecoAI/weco-cli.git
|
|
172
|
+
cd weco-cli
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
2. **Install Development Dependencies:**
|
|
176
|
+
```bash
|
|
177
|
+
pip install -e ".[dev]"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
3. **Create a Feature Branch:**
|
|
181
|
+
```bash
|
|
182
|
+
git checkout -b feature/your-feature-name
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
4. **Make Your Changes:** Ensure your code adheres to our style guidelines and includes relevant tests.
|
|
186
|
+
|
|
187
|
+
5. **Commit and Push** your changes, then open a pull request with a clear description of your enhancements.
|
|
188
|
+
|
|
189
|
+
---
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
weco/__init__.py,sha256=uqfsknG6Jxky4ddpuNn9SYN2lWNJloPDykqCjcmU1UQ,124
|
|
2
|
+
weco/api.py,sha256=8rIf2Fy3tN6GW7BG1CaggtfE9pW56I1erzwLCgawcVE,3511
|
|
3
|
+
weco/cli.py,sha256=rb01pl0Q8sLKBpZ9Qtlz044pEppJAa8CJkv2XM9zzFo,16753
|
|
4
|
+
weco/panels.py,sha256=5HrDrYzx_vDjV41mlZmOOZYxdJIXD5RzBBNKXxUOLEY,12022
|
|
5
|
+
weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
|
|
6
|
+
weco-0.2.5.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
|
|
7
|
+
weco-0.2.5.dist-info/METADATA,sha256=bjW2DWItTu3y_lmLllZIRz43hh5vMCi_u4FXW5eKz5E,9863
|
|
8
|
+
weco-0.2.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
9
|
+
weco-0.2.5.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
|
|
10
|
+
weco-0.2.5.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
11
|
+
weco-0.2.5.dist-info/RECORD,,
|
weco-0.2.4.dist-info/METADATA
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: weco
|
|
3
|
-
Version: 0.2.4
|
|
4
|
-
Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
|
|
5
|
-
Author-email: Weco AI Team <dhruv@weco.ai>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/WecoAI/weco-cli
|
|
8
|
-
Keywords: AI,Code Optimization,Code Generation
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Requires-Python: >=3.12
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: requests
|
|
16
|
-
Requires-Dist: rich
|
|
17
|
-
Provides-Extra: dev
|
|
18
|
-
Requires-Dist: ruff; extra == "dev"
|
|
19
|
-
Requires-Dist: build; extra == "dev"
|
|
20
|
-
Requires-Dist: setuptools_scm; extra == "dev"
|
|
21
|
-
Dynamic: license-file
|
|
22
|
-
|
|
23
|
-
# Weco CLI – Code Optimizer for Machine Learning Engineers
|
|
24
|
-
|
|
25
|
-
[](https://www.python.org)
|
|
26
|
-
[](LICENSE)
|
|
27
|
-
|
|
28
|
-
`weco` is a command-line interface for interacting with Weco AI's code optimizer, powerred by [AI-Driven Exploration](https://arxiv.org/abs/2502.13138).
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
https://github.com/user-attachments/assets/cb724ef1-bff6-4757-b457-d3b2201ede81
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Overview
|
|
39
|
-
|
|
40
|
-
The weco CLI leverages a tree search approach with LLMs to iteratively improve your code.
|
|
41
|
-
|
|
42
|
-

|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## Setup
|
|
49
|
-
|
|
50
|
-
1. **Install the Package:**
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
pip install weco
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
2. **Configure API Keys:**
|
|
57
|
-
|
|
58
|
-
Set the appropriate environment variables for your language model provider:
|
|
59
|
-
|
|
60
|
-
- **OpenAI:** `export OPENAI_API_KEY="your_key_here"`
|
|
61
|
-
- **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"`
|
|
62
|
-
- **Google DeepMind:** `export GEMINI_API_KEY="your_key_here"`
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Usage
|
|
67
|
-
|
|
68
|
-
### Command Line Arguments
|
|
69
|
-
|
|
70
|
-
| Argument | Description | Required |
|
|
71
|
-
|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|----------|
|
|
72
|
-
| `--source` | Path to the Python source code that will be optimized (e.g. optimize.py). | Yes |
|
|
73
|
-
| `--eval-command` | Command to run for evaluation (e.g. 'python eval.py --arg1=val1'). | Yes |
|
|
74
|
-
| `--metric` | Metric to optimize. | Yes |
|
|
75
|
-
| `--maximize` | Whether to maximize ('true') or minimize ('false') the metric. | Yes |
|
|
76
|
-
| `--steps` | Number of optimization steps to run. | Yes |
|
|
77
|
-
| `--model` | Model to use for optimization. | Yes |
|
|
78
|
-
| `--additional-instructions` | (Optional) Description of additional instructions OR path to a file containing additional instructions. | No |
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
### Example
|
|
83
|
-
|
|
84
|
-
Optimizing common operations in pytorch:
|
|
85
|
-
```bash
|
|
86
|
-
weco --source examples/simple-torch/optimize.py \
|
|
87
|
-
--eval-command "python examples/simple-torch/evaluate.py --solution-path examples/simple-torch/optimize.py --device mps" \
|
|
88
|
-
--metric speedup \
|
|
89
|
-
--maximize true \
|
|
90
|
-
--steps 15 \
|
|
91
|
-
--model o3-mini \
|
|
92
|
-
--additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Sometimes we have a bit more context we'd like to provide. Its not easy to fit all of this in a string like shown above with `additional-instructions`. Thats why you can also provide a path to any file you'd like to me read as in context. In this example, we optimize the same operations using mlx and metal with additional instructions:
|
|
96
|
-
```bash
|
|
97
|
-
weco --source examples/simple-mlx/optimize.py \
|
|
98
|
-
--eval-command "python examples/simple-mlx/evaluate.py --solution-path examples/simple-mlx/optimize.py" \
|
|
99
|
-
--metric speedup \
|
|
100
|
-
--maximize true \
|
|
101
|
-
--steps 30 \
|
|
102
|
-
--model o3-mini \
|
|
103
|
-
--additional-instructions examples/simple-mlx/metal-examples.rst
|
|
104
|
-
```
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## Supported Providers
|
|
108
|
-
|
|
109
|
-
The CLI supports the following model providers:
|
|
110
|
-
|
|
111
|
-
- **OpenAI:** Set your API key using `OPENAI_API_KEY`.
|
|
112
|
-
- **Anthropic:** Set your API key using `ANTHROPIC_API_KEY`.
|
|
113
|
-
- **Google DeepMind:** Set your API key using `GEMINI_API_KEY`.
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## Contributing
|
|
118
|
-
|
|
119
|
-
We welcome contributions! To get started:
|
|
120
|
-
|
|
121
|
-
1. **Fork and Clone the Repository:**
|
|
122
|
-
```bash
|
|
123
|
-
git clone https://github.com/WecoAI/weco-cli.git
|
|
124
|
-
cd weco-cli
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
2. **Install Development Dependencies:**
|
|
128
|
-
```bash
|
|
129
|
-
pip install -e ".[dev]"
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
3. **Create a Feature Branch:**
|
|
133
|
-
```bash
|
|
134
|
-
git checkout -b feature/your-feature-name
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
4. **Make Your Changes:** Ensure your code adheres to our style guidelines and includes relevant tests.
|
|
138
|
-
|
|
139
|
-
5. **Commit and Push** your changes, then open a pull request with a clear description of your enhancements.
|
|
140
|
-
|
|
141
|
-
---
|
weco-0.2.4.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
weco/__init__.py,sha256=5TUzMXAo2-PEbB3T_z4hNMJpe1yYKi36KZIeo5s1TCI,124
|
|
2
|
-
weco/api.py,sha256=JHAm60sO51Y2tzLnyAAFv9OLm75o_RNWeoK-gYF4VHE,3342
|
|
3
|
-
weco/cli.py,sha256=daKXAnwjnvUptaVA8nShzJiO9piU91c24s294rzu2d4,16492
|
|
4
|
-
weco/panels.py,sha256=5HrDrYzx_vDjV41mlZmOOZYxdJIXD5RzBBNKXxUOLEY,12022
|
|
5
|
-
weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
|
|
6
|
-
weco-0.2.4.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
|
|
7
|
-
weco-0.2.4.dist-info/METADATA,sha256=T2f_Fa3CdnfX1nwPFCbpY6a3lGYWx5BudSw4lcKxdCg,5518
|
|
8
|
-
weco-0.2.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
9
|
-
weco-0.2.4.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
|
|
10
|
-
weco-0.2.4.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
11
|
-
weco-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|