weco 0.2.4__py3-none-any.whl → 0.2.6__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  # DO NOT EDIT
2
- __pkg_version__ = "0.2.4"
2
+ __pkg_version__ = "0.2.6"
3
3
  __api_version__ = "v1"
4
4
  __base_url__ = f"https://api.aide.weco.ai/{__api_version__}"
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(f"{__base_url__}/sessions/{session_id}", params={"include_history": include_history})
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(console=console, session_id=session_id, include_history=True)
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(console=console, session_id=session_id, include_history=True)
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
@@ -312,7 +321,12 @@ def main() -> None:
312
321
  _, best_solution_panel = solution_panels.get_display(current_step=steps)
313
322
 
314
323
  # Update the end optimization layout
315
- end_optimization_layout["summary"].update(summary_panel.get_display())
324
+ final_message = (
325
+ f"{summary_panel.metric_name.capitalize()} {'maximized' if summary_panel.maximize else 'minimized'}! Best solution {summary_panel.metric_name.lower()} = [green]{status_response['best_result']['metric_value']}[/] 🏆"
326
+ if best_solution_node is not None
327
+ else "[red] No solution found.[/]"
328
+ )
329
+ end_optimization_layout["summary"].update(summary_panel.get_display(final_message=final_message))
316
330
  end_optimization_layout["tree"].update(tree_panel.get_display())
317
331
  end_optimization_layout["best_solution"].update(best_solution_panel)
318
332
 
weco/panels.py CHANGED
@@ -12,7 +12,9 @@ class SummaryPanel:
12
12
  """Holds a summary of the optimization session."""
13
13
 
14
14
  def __init__(self, maximize: bool, metric_name: str, total_steps: int, model: str, session_id: str = None):
15
- self.goal = ("Maximizing" if maximize else "Minimizing") + f" {metric_name}..."
15
+ self.maximize = maximize
16
+ self.metric_name = metric_name
17
+ self.goal = ("Maximizing" if self.maximize else "Minimizing") + f" {self.metric_name}..."
16
18
  self.total_input_tokens = 0
17
19
  self.total_output_tokens = 0
18
20
  self.total_steps = total_steps
@@ -39,24 +41,28 @@ class SummaryPanel:
39
41
  self.total_input_tokens += usage["input_tokens"]
40
42
  self.total_output_tokens += usage["output_tokens"]
41
43
 
42
- def get_display(self) -> Panel:
44
+ def get_display(self, final_message: Optional[str] = None) -> Panel:
43
45
  """Create a summary panel with the relevant information."""
44
46
  layout = Layout(name="summary")
45
47
  summary_table = Table(show_header=False, box=None, padding=(0, 1))
46
48
  # Goal
47
- summary_table.add_row(f"[bold cyan]Goal:[/] {self.goal}")
49
+ if final_message is not None:
50
+ summary_table.add_row(f"[bold cyan]Result:[/] {final_message}")
51
+ else:
52
+ summary_table.add_row(f"[bold cyan]Goal:[/] {self.goal}")
53
+ summary_table.add_row("")
54
+ # Model used
55
+ summary_table.add_row(f"[bold cyan]Model:[/] {self.model}")
48
56
  summary_table.add_row("")
49
57
  # Log directory
50
58
  runs_dir = f".runs/{self.session_id}"
51
59
  summary_table.add_row(f"[bold cyan]Logs:[/] [blue underline]{runs_dir}[/]")
52
60
  summary_table.add_row("")
53
- # Model used
54
- summary_table.add_row(f"[bold cyan]Model:[/] [yellow]{self.model}[/]")
55
- summary_table.add_row("")
56
61
  # Token counts
57
62
  summary_table.add_row(
58
63
  f"[bold cyan]Tokens:[/] ↑[yellow]{format_number(self.total_input_tokens)}[/] ↓[yellow]{format_number(self.total_output_tokens)}[/] = [green]{format_number(self.total_input_tokens + self.total_output_tokens)}[/]"
59
64
  )
65
+ summary_table.add_row("")
60
66
  # Progress bar
61
67
  summary_table.add_row(self.progress)
62
68
 
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: weco
3
+ Version: 0.2.6
4
+ Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
5
+ Author-email: Weco AI Team <contact@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
+ [![Python](https://img.shields.io/badge/Python-3.12.0-blue)](https://www.python.org)
26
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
27
+ [![PyPI version](https://badge.fury.io/py/weco.svg)](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
+ ![image](https://github.com/user-attachments/assets/a6ed63fa-9c40-498e-aa98-a873e5786509)
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 simple operations**
103
+
104
+ ```bash
105
+ cd examples/hello-kernel-world
106
+ pip install torch
107
+ weco --source optimize.py \
108
+ --eval-command "python evaluate.py --solution-path optimize.py --device cpu" \
109
+ --metric speedup \
110
+ --maximize true \
111
+ --steps 15 \
112
+ --model claude-3-7-sonnet-20250219 \
113
+ --additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
114
+ ```
115
+
116
+ Note that if you have an NVIDIA gpu, change the device to `cuda`. If you are running this on Apple Silicon, set it to `mps`.
117
+
118
+ **Example 2: Optimizing MLX operations with instructions from a file**
119
+
120
+ Lets optimize a 2D convolution operation in [`mlx`](https://github.com/ml-explore/mlx) using [Metal](https://developer.apple.com/documentation/metal/). 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.
121
+
122
+ ```bash
123
+ cd examples/metal
124
+ pip install mlx
125
+ weco --source optimize.py \
126
+ --eval-command "python evaluate.py --solution-path optimize.py" \
127
+ --metric speedup \
128
+ --maximize true \
129
+ --steps 30 \
130
+ --model o3-mini \
131
+ --additional-instructions examples.rst
132
+ ```
133
+
134
+ **Example 3: Level Agnostic Optimization: Causal Self Attention with Triton & CUDA**
135
+
136
+ Given how useful causal multihead self attention is to transformers, we've seen its wide adoption across ML engineering and AI research. Its great to keep things at a high-level (in PyTorch) when doing research, but when moving to production you often need to write highly customized low-level kernels to make things run as fast as they can. The `weco` CLI can optimize kernels across a variety of different abstraction levels and frameworks. Example 2 uses Metal but lets explore two more frameworks:
137
+
138
+ 1. [Triton](https://github.com/triton-lang/triton)
139
+ ```bash
140
+ cd examples/triton
141
+ pip install torch triton
142
+ weco --source optimize.py \
143
+ --eval-command "python evaluate.py --solution-path optimize.py" \
144
+ --metric speedup \
145
+ --maximize true \
146
+ --steps 30 \
147
+ --model gemini-2.5-pro-preview-03-25 \
148
+ --additional-instructions "Use triton to optimize the code while ensuring a small max float diff. Maintain the same code format."
149
+ ```
150
+
151
+ 2. [CUDA](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html)
152
+ ```bash
153
+ cd examples/cuda
154
+ pip install torch
155
+ weco --source optimize.py \
156
+ --eval-command "python evaluate.py --solution-path optimize.py" \
157
+ --metric speedup \
158
+ --maximize true \
159
+ --steps 30 \
160
+ --model gemini-2.5-pro-preview-03-25 \
161
+ --additional-instructions guide.md
162
+ ```
163
+
164
+
165
+ ---
166
+
167
+ ### Command Line Arguments
168
+
169
+ | Argument | Description | Required |
170
+ | :-------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
171
+ | `--source` | Path to the source code file that will be optimized (e.g., `optimize.py`). | Yes |
172
+ | `--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 |
173
+ | `--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 |
174
+ | `--maximize` | Whether to maximize (`true`) or minimize (`false`) the metric. | Yes |
175
+ | `--steps` | Number of optimization steps (LLM iterations) to run. | Yes |
176
+ | `--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 |
177
+ | `--additional-instructions` | (Optional) Natural language description of specific instructions OR path to a file containing detailed instructions to guide the LLM. | No |
178
+
179
+ ---
180
+
181
+
182
+
183
+ ### Important Note on Evaluation
184
+
185
+ 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.
186
+
187
+ For example, if you set `--metric speedup`, your evaluation script (`eval.py` in the examples) should output a line like:
188
+
189
+ ```
190
+ speedup: 1.5
191
+ ```
192
+
193
+ or
194
+
195
+ ```
196
+ Final speedup value = 1.5
197
+ ```
198
+
199
+ Weco will parse this output to extract the numerical value (1.5 in this case) associated with the metric name ('speedup').
200
+
201
+
202
+ ## Contributing
203
+
204
+ We welcome contributions! To get started:
205
+
206
+ 1. **Fork and Clone the Repository:**
207
+ ```bash
208
+ git clone https://github.com/WecoAI/weco-cli.git
209
+ cd weco-cli
210
+ ```
211
+
212
+ 2. **Install Development Dependencies:**
213
+ ```bash
214
+ pip install -e ".[dev]"
215
+ ```
216
+
217
+ 3. **Create a Feature Branch:**
218
+ ```bash
219
+ git checkout -b feature/your-feature-name
220
+ ```
221
+
222
+ 4. **Make Your Changes:** Ensure your code adheres to our style guidelines and includes relevant tests.
223
+
224
+ 5. **Commit and Push** your changes, then open a pull request with a clear description of your enhancements.
225
+
226
+ ---
@@ -0,0 +1,11 @@
1
+ weco/__init__.py,sha256=a3RxrwZhsuinalG_NtT0maKLFXFbgmgXFahpFgcEtZQ,124
2
+ weco/api.py,sha256=8rIf2Fy3tN6GW7BG1CaggtfE9pW56I1erzwLCgawcVE,3511
3
+ weco/cli.py,sha256=6rGEm_L-WSkJIT-jgfFmf2i_DXkQn6ILhqYQlptLFew,17159
4
+ weco/panels.py,sha256=9gq5C43hgUmQgl6tW-f2dBbDjlsBKBatSaUVKeGm4Zw,12296
5
+ weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
6
+ weco-0.2.6.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
+ weco-0.2.6.dist-info/METADATA,sha256=Ih-nkHxq_SJKccYXoVHmxytElqG75BSU1DGAAC9ipkk,11581
8
+ weco-0.2.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
+ weco-0.2.6.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
+ weco-0.2.6.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
+ weco-0.2.6.dist-info/RECORD,,
@@ -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
- [![Python](https://img.shields.io/badge/Python-3.12.0-blue)](https://www.python.org)
26
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](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
- ![image](https://github.com/user-attachments/assets/a6ed63fa-9c40-498e-aa98-a873e5786509)
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
- ---
@@ -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