weco 0.2.3__tar.gz → 0.2.5__tar.gz

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.
@@ -90,7 +90,7 @@ jobs:
90
90
  GITHUB_TOKEN: ${{ github.token }}
91
91
  run: >-
92
92
  gh release create
93
- 'v0.2.3'
93
+ 'v0.2.5'
94
94
  --repo '${{ github.repository }}'
95
95
  --notes ""
96
96
 
@@ -102,5 +102,5 @@ jobs:
102
102
  # sigstore-produced signatures and certificates.
103
103
  run: >-
104
104
  gh release upload
105
- 'v0.2.3' dist/**
105
+ 'v0.2.5' dist/**
106
106
  --repo '${{ github.repository }}'
weco-0.2.5/PKG-INFO ADDED
@@ -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
+ [![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 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
+ ---
weco-0.2.5/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # Weco CLI – Code Optimizer for Machine Learning Engineers
2
+
3
+ [![Python](https://img.shields.io/badge/Python-3.12.0-blue)](https://www.python.org)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
5
+ [![PyPI version](https://badge.fury.io/py/weco.svg)](https://badge.fury.io/py/weco)
6
+
7
+ `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.
8
+
9
+ https://github.com/user-attachments/assets/cb724ef1-bff6-4757-b457-d3b2201ede81
10
+
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ 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.
16
+
17
+ ![image](https://github.com/user-attachments/assets/a6ed63fa-9c40-498e-aa98-a873e5786509)
18
+
19
+ ---
20
+
21
+ ## Example Use Cases
22
+
23
+ Here's how `weco` can be applied to common ML engineering tasks:
24
+
25
+ * **GPU Kernel Optimization:**
26
+ * **Goal:** Improve the speed or efficiency of low-level GPU code.
27
+ * **How:** `weco` iteratively refines CUDA, Triton, Metal, or other kernel code specified in your `--source` file.
28
+ * **`--eval-command`:** Typically runs a script that compiles the kernel, executes it, and benchmarks performance (e.g., latency, throughput).
29
+ * **`--metric`:** Examples include `latency`, `throughput`, `TFLOPS`, `memory_bandwidth`. Optimize to `minimize` latency or `maximize` throughput.
30
+
31
+ * **Feature Engineering:**
32
+ * **Goal:** Discover better data transformations or feature combinations for your machine learning models.
33
+ * **How:** `weco` explores different processing steps or parameters within your feature transformation code (`--source`).
34
+ * **`--eval-command`:** Executes a script that applies the features, trains/validates a model using those features, and prints a performance score.
35
+ * **`--metric`:** Examples include `accuracy`, `AUC`, `F1-score`, `validation_loss`. Usually optimized to `maximize` accuracy/AUC/F1 or `minimize` loss.
36
+
37
+ * **Model Development:**
38
+ * **Goal:** Tune hyperparameters or experiment with small architectural changes directly within your model's code.
39
+ * **How:** `weco` modifies hyperparameter values (like learning rate, layer sizes if defined in the code) or structural elements in your model definition (`--source`).
40
+ * **`--eval-command`:** Runs your model training and evaluation script, printing the key performance indicator.
41
+ * **`--metric`:** Examples include `validation_accuracy`, `test_loss`, `inference_time`, `perplexity`. Optimize according to the metric's nature (e.g., `maximize` accuracy, `minimize` loss).
42
+
43
+ * **Prompt Engineering:**
44
+ * **Goal:** Refine prompts used within larger systems (e.g., for LLM interactions) to achieve better or more consistent outputs.
45
+ * **How:** `weco` modifies prompt templates, examples, or instructions stored in the `--source` file.
46
+ * **`--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.
47
+ * **`--metric`:** Examples include `quality_score`, `relevance`, `task_success_rate`, `format_adherence`. Usually optimized to `maximize`.
48
+
49
+ ---
50
+
51
+
52
+ ## Setup
53
+
54
+ 1. **Install the Package:**
55
+
56
+ ```bash
57
+ pip install weco
58
+ ```
59
+
60
+ 2. **Configure API Keys:**
61
+
62
+ Set the appropriate environment variables for your desired language model provider:
63
+
64
+ - **OpenAI:** `export OPENAI_API_KEY="your_key_here"`
65
+ - **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"`
66
+ - **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.)
67
+
68
+ ---
69
+
70
+ ## Usage
71
+ <div style="background-color: #fff3cd; border: 1px solid #ffeeba; padding: 15px; border-radius: 4px; margin-bottom: 15px;">
72
+ <strong>⚠️ Warning: Code Modification</strong><br>
73
+ <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.
74
+ </div>
75
+
76
+ ---
77
+
78
+ ### Examples
79
+
80
+ **Example 1: Optimizing PyTorch operations**
81
+
82
+ ```bash
83
+ weco --source examples/simple-torch/optimize.py \
84
+ --eval-command "python examples/simple-torch/evaluate.py --solution-path examples/simple-torch/optimize.py --device mps" \
85
+ --metric speedup \
86
+ --maximize true \
87
+ --steps 15 \
88
+ --model o3-mini \
89
+ --additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
90
+ ```
91
+
92
+ **Example 2: Optimizing MLX operations with instructions from a file**
93
+
94
+ 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.
95
+
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
+
108
+ ### Command Line Arguments
109
+
110
+ | Argument | Description | Required |
111
+ | :-------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
112
+ | `--source` | Path to the source code file that will be optimized (e.g., `optimize.py`). | Yes |
113
+ | `--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 |
114
+ | `--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 |
115
+ | `--maximize` | Whether to maximize (`true`) or minimize (`false`) the metric. | Yes |
116
+ | `--steps` | Number of optimization steps (LLM iterations) to run. | Yes |
117
+ | `--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 |
118
+ | `--additional-instructions` | (Optional) Natural language description of specific instructions OR path to a file containing detailed instructions to guide the LLM. | No |
119
+
120
+ ---
121
+
122
+
123
+
124
+ ### Important Note on Evaluation
125
+
126
+ 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.
127
+
128
+ For example, if you set `--metric speedup`, your evaluation script (`eval.py` in the examples) should output a line like:
129
+
130
+ ```
131
+ speedup: 1.5
132
+ ```
133
+
134
+ or
135
+
136
+ ```
137
+ Final speedup value = 1.5
138
+ ```
139
+
140
+ Weco will parse this output to extract the numerical value (1.5 in this case) associated with the metric name ('speedup').
141
+
142
+
143
+ ## Contributing
144
+
145
+ We welcome contributions! To get started:
146
+
147
+ 1. **Fork and Clone the Repository:**
148
+ ```bash
149
+ git clone https://github.com/WecoAI/weco-cli.git
150
+ cd weco-cli
151
+ ```
152
+
153
+ 2. **Install Development Dependencies:**
154
+ ```bash
155
+ pip install -e ".[dev]"
156
+ ```
157
+
158
+ 3. **Create a Feature Branch:**
159
+ ```bash
160
+ git checkout -b feature/your-feature-name
161
+ ```
162
+
163
+ 4. **Make Your Changes:** Ensure your code adheres to our style guidelines and includes relevant tests.
164
+
165
+ 5. **Commit and Push** your changes, then open a pull request with a clear description of your enhancements.
166
+
167
+ ---
@@ -66,7 +66,7 @@ def bench(f, inputs, n_warmup, n_rep):
66
66
  t_avg = 0.0
67
67
  for _ in range(n_rep):
68
68
  # Clear cache before timing
69
- mx.metal.clear_cache()
69
+ mx.clear_cache()
70
70
 
71
71
  start_time = time.time()
72
72
  result = f(inputs)
@@ -10,7 +10,7 @@ authors = [
10
10
  ]
11
11
  description = "Documentation for `weco`, a CLI for using Weco AI's code optimizer."
12
12
  readme = "README.md"
13
- version = "0.2.3"
13
+ version = "0.2.5"
14
14
  license = {text = "MIT"}
15
15
  requires-python = ">=3.12"
16
16
  dependencies = ["requests", "rich"]
@@ -1,4 +1,4 @@
1
1
  # DO NOT EDIT
2
- __pkg_version__ = "0.2.3"
2
+ __pkg_version__ = "0.2.5"
3
3
  __api_version__ = "v1"
4
4
  __base_url__ = f"https://api.aide.weco.ai/{__api_version__}"
@@ -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:
@@ -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,56 +104,62 @@ 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
- # Define the runs directory (.runs/<session-id>)
108
- session_id = session_response["session_id"]
109
- runs_dir = pathlib.Path(".runs") / session_id
110
- runs_dir.mkdir(parents=True, exist_ok=True)
111
-
112
- # Save the original code (.runs/<session-id>/original.py)
113
- runs_copy_source_fp = runs_dir / "original.py"
114
- write_to_path(fp=runs_copy_source_fp, content=source_code)
115
-
116
- # Write the code string to the source file path
117
- # Do this after the original code is saved
118
- write_to_path(fp=source_fp, content=session_response["code"])
119
-
120
- # Update the panels with the initial solution
121
- # Add session id now that we have it
122
- summary_panel.session_id = session_id
123
- # Set the step of the progress bar
124
- summary_panel.set_step(step=0)
125
- # Update the token counts
126
- summary_panel.update_token_counts(usage=session_response["usage"])
127
- # Update the plan
128
- plan_panel.update(plan=session_response["plan"])
129
- # Build the metric tree
130
- tree_panel.build_metric_tree(
131
- nodes=[
132
- {
133
- "solution_id": session_response["solution_id"],
134
- "parent_id": None,
135
- "code": session_response["code"],
136
- "step": 0,
137
- "metric_value": None,
138
- "is_buggy": False,
139
- }
140
- ]
141
- )
142
- # Set the current solution as unevaluated since we haven't run the evaluation function and fed it back to the model yet
143
- tree_panel.set_unevaluated_node(node_id=session_response["solution_id"])
144
- # Update the solution panels with the initial solution and get the panel displays
145
- solution_panels.update(
146
- current_node=Node(
147
- id=session_response["solution_id"], parent_id=None, code=session_response["code"], metric=None, is_buggy=False
148
- ),
149
- best_node=None,
150
- )
151
- current_solution_panel, best_solution_panel = solution_panels.get_display(current_step=0)
152
110
  # Define the refresh rate
153
111
  refresh_rate = 4
154
112
  with Live(layout, refresh_per_second=refresh_rate, screen=True) as live:
113
+ # Define the runs directory (.runs/<session-id>)
114
+ session_id = session_response["session_id"]
115
+ runs_dir = pathlib.Path(".runs") / session_id
116
+ runs_dir.mkdir(parents=True, exist_ok=True)
117
+
118
+ # Save the original code (.runs/<session-id>/original.py)
119
+ runs_copy_source_fp = runs_dir / "original.py"
120
+ write_to_path(fp=runs_copy_source_fp, content=source_code)
121
+
122
+ # Write the code string to the source file path
123
+ # Do this after the original code is saved
124
+ write_to_path(fp=source_fp, content=session_response["code"])
125
+
126
+ # Update the panels with the initial solution
127
+ # Add session id now that we have it
128
+ summary_panel.session_id = session_id
129
+ # Set the step of the progress bar
130
+ summary_panel.set_step(step=0)
131
+ # Update the token counts
132
+ summary_panel.update_token_counts(usage=session_response["usage"])
133
+ # Update the plan
134
+ plan_panel.update(plan=session_response["plan"])
135
+ # Build the metric tree
136
+ tree_panel.build_metric_tree(
137
+ nodes=[
138
+ {
139
+ "solution_id": session_response["solution_id"],
140
+ "parent_id": None,
141
+ "code": session_response["code"],
142
+ "step": 0,
143
+ "metric_value": None,
144
+ "is_buggy": False,
145
+ }
146
+ ]
147
+ )
148
+ # Set the current solution as unevaluated since we haven't run the evaluation function and fed it back to the model yet
149
+ tree_panel.set_unevaluated_node(node_id=session_response["solution_id"])
150
+ # Update the solution panels with the initial solution and get the panel displays
151
+ solution_panels.update(
152
+ current_node=Node(
153
+ id=session_response["solution_id"],
154
+ parent_id=None,
155
+ code=session_response["code"],
156
+ metric=None,
157
+ is_buggy=False,
158
+ ),
159
+ best_node=None,
160
+ )
161
+ current_solution_panel, best_solution_panel = solution_panels.get_display(current_step=0)
162
+
155
163
  # Update the entire layout
156
164
  smooth_update(
157
165
  live=live,
@@ -187,6 +195,7 @@ def main() -> None:
187
195
  execution_output=term_out,
188
196
  additional_instructions=additional_instructions,
189
197
  api_keys=api_keys,
198
+ timeout=timeout,
190
199
  )
191
200
  # Save next solution (.runs/<session-id>/step_<step>.py)
192
201
  write_to_path(fp=runs_dir / f"step_{step}.py", content=eval_and_next_solution_response["code"])
@@ -196,7 +205,9 @@ def main() -> None:
196
205
 
197
206
  # Get the optimization session status for
198
207
  # the best solution, its score, and the history to plot the tree
199
- 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
+ )
200
211
 
201
212
  # Update the step of the progress bar
202
213
  summary_panel.set_step(step=step)
@@ -276,6 +287,7 @@ def main() -> None:
276
287
  execution_output=term_out,
277
288
  additional_instructions=additional_instructions,
278
289
  api_keys=api_keys,
290
+ timeout=timeout,
279
291
  )
280
292
 
281
293
  # Update the progress bar
@@ -285,7 +297,9 @@ def main() -> None:
285
297
  # No need to update the plan panel since we have finished the optimization
286
298
  # Get the optimization session status for
287
299
  # the best solution, its score, and the history to plot the tree
288
- 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
+ )
289
303
  # Build the metric tree
290
304
  tree_panel.build_metric_tree(nodes=status_response["history"])
291
305
  # No need to set any solution to unevaluated since we have finished the optimization
@@ -12,7 +12,7 @@ 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.goal = ("Maximizing" if maximize else "Minimizing") + f" {metric_name}..."
16
16
  self.total_input_tokens = 0
17
17
  self.total_output_tokens = 0
18
18
  self.total_steps = total_steps
@@ -48,10 +48,10 @@ class SummaryPanel:
48
48
  summary_table.add_row("")
49
49
  # Log directory
50
50
  runs_dir = f".runs/{self.session_id}"
51
- summary_table.add_row(f"[bold cyan]Logs:[/] [blue]{runs_dir}[/]")
51
+ summary_table.add_row(f"[bold cyan]Logs:[/] [blue underline]{runs_dir}[/]")
52
52
  summary_table.add_row("")
53
53
  # Model used
54
- summary_table.add_row(f"[bold cyan]Model:[/] {self.model}")
54
+ summary_table.add_row(f"[bold cyan]Model:[/] [yellow]{self.model}[/]")
55
55
  summary_table.add_row("")
56
56
  # Token counts
57
57
  summary_table.add_row(
@@ -197,7 +197,7 @@ class MetricTreePanel:
197
197
  # best node
198
198
  color = "green"
199
199
  style = "bold"
200
- text = f"🏆 {node.metric:.3f}"
200
+ text = f"{node.metric:.3f} 🏆"
201
201
  elif node.metric is None:
202
202
  # metric not extracted from evaluated solution
203
203
  color = "yellow"
@@ -214,7 +214,7 @@ class MetricTreePanel:
214
214
  for child in node.children:
215
215
  append_rec(child, subtree)
216
216
 
217
- tree = Tree("solutions")
217
+ tree = Tree("🌳")
218
218
  for n in self.metric_tree.get_draft_nodes():
219
219
  append_rec(n, tree)
220
220
 
@@ -223,7 +223,9 @@ class MetricTreePanel:
223
223
  def get_display(self) -> Panel:
224
224
  """Get a panel displaying the solution tree."""
225
225
  # Make sure the metric tree is built before calling build_rich_tree
226
- return Panel(self._build_rich_tree(), title="[bold]🌳 Exploring...", border_style="green", expand=True, padding=(0, 1))
226
+ return Panel(
227
+ self._build_rich_tree(), title="[bold]🔎 Exploring Solutions...", border_style="green", expand=True, padding=(0, 1)
228
+ )
227
229
 
228
230
 
229
231
  class EvaluationOutputPanel:
@@ -242,7 +244,7 @@ class EvaluationOutputPanel:
242
244
 
243
245
  def get_display(self) -> Panel:
244
246
  """Create a panel displaying the evaluation output with truncation if needed."""
245
- return Panel(self.output, title="[bold]📋 Evaluation Output", border_style="red", expand=True, padding=(0, 1))
247
+ return Panel(self.output, title="[bold]📋 Evaluation Output", border_style="blue", expand=True, padding=(0, 1))
246
248
 
247
249
 
248
250
  class SolutionPanels:
@@ -28,10 +28,14 @@ def read_additional_instructions(additional_instructions: str | None) -> str | N
28
28
 
29
29
  # Try interpreting as a path first
30
30
  potential_path = pathlib.Path(additional_instructions)
31
- if potential_path.exists() and potential_path.is_file():
32
- return read_from_path(potential_path, is_json=False) # type: ignore # read_from_path returns str when is_json=False
33
- else:
34
- # If it's not a valid file path, return the string itself
31
+ try:
32
+ if potential_path.exists() and potential_path.is_file():
33
+ return read_from_path(potential_path, is_json=False) # type: ignore # read_from_path returns str when is_json=False
34
+ else:
35
+ # If it's not a valid file path, return the string itself
36
+ return additional_instructions
37
+ except OSError:
38
+ # If the path can't be read, return the string itself
35
39
  return additional_instructions
36
40
 
37
41
 
@@ -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
+ [![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 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
+ ---
weco-0.2.3/PKG-INFO DELETED
@@ -1,141 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: weco
3
- Version: 0.2.3
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
- Optimizing these same using mlx and metal:
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.3/README.md DELETED
@@ -1,119 +0,0 @@
1
- # Weco CLI – Code Optimizer for Machine Learning Engineers
2
-
3
- [![Python](https://img.shields.io/badge/Python-3.12.0-blue)](https://www.python.org)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
5
-
6
- `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).
7
-
8
-
9
-
10
- https://github.com/user-attachments/assets/cb724ef1-bff6-4757-b457-d3b2201ede81
11
-
12
-
13
-
14
- ---
15
-
16
- ## Overview
17
-
18
- The weco CLI leverages a tree search approach with LLMs to iteratively improve your code.
19
-
20
- ![image](https://github.com/user-attachments/assets/a6ed63fa-9c40-498e-aa98-a873e5786509)
21
-
22
-
23
-
24
- ---
25
-
26
- ## Setup
27
-
28
- 1. **Install the Package:**
29
-
30
- ```bash
31
- pip install weco
32
- ```
33
-
34
- 2. **Configure API Keys:**
35
-
36
- Set the appropriate environment variables for your language model provider:
37
-
38
- - **OpenAI:** `export OPENAI_API_KEY="your_key_here"`
39
- - **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"`
40
- - **Google DeepMind:** `export GEMINI_API_KEY="your_key_here"`
41
-
42
- ---
43
-
44
- ## Usage
45
-
46
- ### Command Line Arguments
47
-
48
- | Argument | Description | Required |
49
- |-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|----------|
50
- | `--source` | Path to the Python source code that will be optimized (e.g. optimize.py). | Yes |
51
- | `--eval-command` | Command to run for evaluation (e.g. 'python eval.py --arg1=val1'). | Yes |
52
- | `--metric` | Metric to optimize. | Yes |
53
- | `--maximize` | Whether to maximize ('true') or minimize ('false') the metric. | Yes |
54
- | `--steps` | Number of optimization steps to run. | Yes |
55
- | `--model` | Model to use for optimization. | Yes |
56
- | `--additional-instructions` | (Optional) Description of additional instructions OR path to a file containing additional instructions. | No |
57
-
58
- ---
59
-
60
- ### Example
61
-
62
- Optimizing common operations in pytorch:
63
- ```bash
64
- weco --source examples/simple-torch/optimize.py \
65
- --eval-command "python examples/simple-torch/evaluate.py --solution-path examples/simple-torch/optimize.py --device mps" \
66
- --metric speedup \
67
- --maximize true \
68
- --steps 15 \
69
- --model "o3-mini" \
70
- --additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
71
- ```
72
-
73
- Optimizing these same using mlx and metal:
74
- ```bash
75
- weco --source examples/simple-mlx/optimize.py \
76
- --eval-command "python examples/simple-mlx/evaluate.py --solution-path examples/simple-mlx/optimize.py" \
77
- --metric speedup \
78
- --maximize true \
79
- --steps 30 \
80
- --model "o3-mini" \
81
- --additional-instructions "examples/simple-mlx/metal-examples.rst"
82
- ```
83
- ---
84
-
85
- ## Supported Providers
86
-
87
- The CLI supports the following model providers:
88
-
89
- - **OpenAI:** Set your API key using `OPENAI_API_KEY`.
90
- - **Anthropic:** Set your API key using `ANTHROPIC_API_KEY`.
91
- - **Google DeepMind:** Set your API key using `GEMINI_API_KEY`.
92
-
93
- ---
94
-
95
- ## Contributing
96
-
97
- We welcome contributions! To get started:
98
-
99
- 1. **Fork and Clone the Repository:**
100
- ```bash
101
- git clone https://github.com/WecoAI/weco-cli.git
102
- cd weco-cli
103
- ```
104
-
105
- 2. **Install Development Dependencies:**
106
- ```bash
107
- pip install -e ".[dev]"
108
- ```
109
-
110
- 3. **Create a Feature Branch:**
111
- ```bash
112
- git checkout -b feature/your-feature-name
113
- ```
114
-
115
- 4. **Make Your Changes:** Ensure your code adheres to our style guidelines and includes relevant tests.
116
-
117
- 5. **Commit and Push** your changes, then open a pull request with a clear description of your enhancements.
118
-
119
- ---
@@ -1,141 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: weco
3
- Version: 0.2.3
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
- Optimizing these same using mlx and metal:
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
- ---
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes