weco 0.2.3__tar.gz → 0.2.4__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.
- {weco-0.2.3 → weco-0.2.4}/.github/workflows/release.yml +2 -2
- {weco-0.2.3 → weco-0.2.4}/PKG-INFO +5 -5
- {weco-0.2.3 → weco-0.2.4}/README.md +4 -4
- {weco-0.2.3 → weco-0.2.4}/examples/simple-mlx/evaluate.py +1 -1
- {weco-0.2.3 → weco-0.2.4}/pyproject.toml +1 -1
- {weco-0.2.3 → weco-0.2.4}/weco/__init__.py +1 -1
- {weco-0.2.3 → weco-0.2.4}/weco/cli.py +50 -45
- {weco-0.2.3 → weco-0.2.4}/weco/panels.py +9 -7
- {weco-0.2.3 → weco-0.2.4}/weco/utils.py +8 -4
- {weco-0.2.3 → weco-0.2.4}/weco.egg-info/PKG-INFO +5 -5
- {weco-0.2.3 → weco-0.2.4}/.github/workflows/lint.yml +0 -0
- {weco-0.2.3 → weco-0.2.4}/.gitignore +0 -0
- {weco-0.2.3 → weco-0.2.4}/LICENSE +0 -0
- {weco-0.2.3 → weco-0.2.4}/examples/simple-mlx/metal-examples.rst +0 -0
- {weco-0.2.3 → weco-0.2.4}/examples/simple-mlx/optimize.py +0 -0
- {weco-0.2.3 → weco-0.2.4}/examples/simple-torch/evaluate.py +0 -0
- {weco-0.2.3 → weco-0.2.4}/examples/simple-torch/optimize.py +0 -0
- {weco-0.2.3 → weco-0.2.4}/setup.cfg +0 -0
- {weco-0.2.3 → weco-0.2.4}/weco/api.py +0 -0
- {weco-0.2.3 → weco-0.2.4}/weco.egg-info/SOURCES.txt +0 -0
- {weco-0.2.3 → weco-0.2.4}/weco.egg-info/dependency_links.txt +0 -0
- {weco-0.2.3 → weco-0.2.4}/weco.egg-info/entry_points.txt +0 -0
- {weco-0.2.3 → weco-0.2.4}/weco.egg-info/requires.txt +0 -0
- {weco-0.2.3 → weco-0.2.4}/weco.egg-info/top_level.txt +0 -0
|
@@ -90,7 +90,7 @@ jobs:
|
|
|
90
90
|
GITHUB_TOKEN: ${{ github.token }}
|
|
91
91
|
run: >-
|
|
92
92
|
gh release create
|
|
93
|
-
'v0.2.
|
|
93
|
+
'v0.2.4'
|
|
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.
|
|
105
|
+
'v0.2.4' dist/**
|
|
106
106
|
--repo '${{ github.repository }}'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: weco
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
|
|
5
5
|
Author-email: Weco AI Team <dhruv@weco.ai>
|
|
6
6
|
License: MIT
|
|
@@ -88,19 +88,19 @@ weco --source examples/simple-torch/optimize.py \
|
|
|
88
88
|
--metric speedup \
|
|
89
89
|
--maximize true \
|
|
90
90
|
--steps 15 \
|
|
91
|
-
--model
|
|
91
|
+
--model o3-mini \
|
|
92
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
93
|
```
|
|
94
94
|
|
|
95
|
-
|
|
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
96
|
```bash
|
|
97
97
|
weco --source examples/simple-mlx/optimize.py \
|
|
98
98
|
--eval-command "python examples/simple-mlx/evaluate.py --solution-path examples/simple-mlx/optimize.py" \
|
|
99
99
|
--metric speedup \
|
|
100
100
|
--maximize true \
|
|
101
101
|
--steps 30 \
|
|
102
|
-
--model
|
|
103
|
-
--additional-instructions
|
|
102
|
+
--model o3-mini \
|
|
103
|
+
--additional-instructions examples/simple-mlx/metal-examples.rst
|
|
104
104
|
```
|
|
105
105
|
---
|
|
106
106
|
|
|
@@ -66,19 +66,19 @@ weco --source examples/simple-torch/optimize.py \
|
|
|
66
66
|
--metric speedup \
|
|
67
67
|
--maximize true \
|
|
68
68
|
--steps 15 \
|
|
69
|
-
--model
|
|
69
|
+
--model o3-mini \
|
|
70
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
71
|
```
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
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:
|
|
74
74
|
```bash
|
|
75
75
|
weco --source examples/simple-mlx/optimize.py \
|
|
76
76
|
--eval-command "python examples/simple-mlx/evaluate.py --solution-path examples/simple-mlx/optimize.py" \
|
|
77
77
|
--metric speedup \
|
|
78
78
|
--maximize true \
|
|
79
79
|
--steps 30 \
|
|
80
|
-
--model
|
|
81
|
-
--additional-instructions
|
|
80
|
+
--model o3-mini \
|
|
81
|
+
--additional-instructions examples/simple-mlx/metal-examples.rst
|
|
82
82
|
```
|
|
83
83
|
---
|
|
84
84
|
|
|
@@ -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.
|
|
13
|
+
version = "0.2.4"
|
|
14
14
|
license = {text = "MIT"}
|
|
15
15
|
requires-python = ">=3.12"
|
|
16
16
|
dependencies = ["requests", "rich"]
|
|
@@ -104,54 +104,59 @@ def main() -> None:
|
|
|
104
104
|
api_keys=api_keys,
|
|
105
105
|
)
|
|
106
106
|
|
|
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
107
|
# Define the refresh rate
|
|
153
108
|
refresh_rate = 4
|
|
154
109
|
with Live(layout, refresh_per_second=refresh_rate, screen=True) as live:
|
|
110
|
+
# Define the runs directory (.runs/<session-id>)
|
|
111
|
+
session_id = session_response["session_id"]
|
|
112
|
+
runs_dir = pathlib.Path(".runs") / session_id
|
|
113
|
+
runs_dir.mkdir(parents=True, exist_ok=True)
|
|
114
|
+
|
|
115
|
+
# Save the original code (.runs/<session-id>/original.py)
|
|
116
|
+
runs_copy_source_fp = runs_dir / "original.py"
|
|
117
|
+
write_to_path(fp=runs_copy_source_fp, content=source_code)
|
|
118
|
+
|
|
119
|
+
# Write the code string to the source file path
|
|
120
|
+
# Do this after the original code is saved
|
|
121
|
+
write_to_path(fp=source_fp, content=session_response["code"])
|
|
122
|
+
|
|
123
|
+
# Update the panels with the initial solution
|
|
124
|
+
# Add session id now that we have it
|
|
125
|
+
summary_panel.session_id = session_id
|
|
126
|
+
# Set the step of the progress bar
|
|
127
|
+
summary_panel.set_step(step=0)
|
|
128
|
+
# Update the token counts
|
|
129
|
+
summary_panel.update_token_counts(usage=session_response["usage"])
|
|
130
|
+
# Update the plan
|
|
131
|
+
plan_panel.update(plan=session_response["plan"])
|
|
132
|
+
# Build the metric tree
|
|
133
|
+
tree_panel.build_metric_tree(
|
|
134
|
+
nodes=[
|
|
135
|
+
{
|
|
136
|
+
"solution_id": session_response["solution_id"],
|
|
137
|
+
"parent_id": None,
|
|
138
|
+
"code": session_response["code"],
|
|
139
|
+
"step": 0,
|
|
140
|
+
"metric_value": None,
|
|
141
|
+
"is_buggy": False,
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
)
|
|
145
|
+
# Set the current solution as unevaluated since we haven't run the evaluation function and fed it back to the model yet
|
|
146
|
+
tree_panel.set_unevaluated_node(node_id=session_response["solution_id"])
|
|
147
|
+
# Update the solution panels with the initial solution and get the panel displays
|
|
148
|
+
solution_panels.update(
|
|
149
|
+
current_node=Node(
|
|
150
|
+
id=session_response["solution_id"],
|
|
151
|
+
parent_id=None,
|
|
152
|
+
code=session_response["code"],
|
|
153
|
+
metric=None,
|
|
154
|
+
is_buggy=False,
|
|
155
|
+
),
|
|
156
|
+
best_node=None,
|
|
157
|
+
)
|
|
158
|
+
current_solution_panel, best_solution_panel = solution_panels.get_display(current_step=0)
|
|
159
|
+
|
|
155
160
|
# Update the entire layout
|
|
156
161
|
smooth_update(
|
|
157
162
|
live=live,
|
|
@@ -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"
|
|
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("
|
|
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(
|
|
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="
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: weco
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
|
|
5
5
|
Author-email: Weco AI Team <dhruv@weco.ai>
|
|
6
6
|
License: MIT
|
|
@@ -88,19 +88,19 @@ weco --source examples/simple-torch/optimize.py \
|
|
|
88
88
|
--metric speedup \
|
|
89
89
|
--maximize true \
|
|
90
90
|
--steps 15 \
|
|
91
|
-
--model
|
|
91
|
+
--model o3-mini \
|
|
92
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
93
|
```
|
|
94
94
|
|
|
95
|
-
|
|
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
96
|
```bash
|
|
97
97
|
weco --source examples/simple-mlx/optimize.py \
|
|
98
98
|
--eval-command "python examples/simple-mlx/evaluate.py --solution-path examples/simple-mlx/optimize.py" \
|
|
99
99
|
--metric speedup \
|
|
100
100
|
--maximize true \
|
|
101
101
|
--steps 30 \
|
|
102
|
-
--model
|
|
103
|
-
--additional-instructions
|
|
102
|
+
--model o3-mini \
|
|
103
|
+
--additional-instructions examples/simple-mlx/metal-examples.rst
|
|
104
104
|
```
|
|
105
105
|
---
|
|
106
106
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|