weco 0.2.5__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.5"
2
+ __pkg_version__ = "0.2.6"
3
3
  __api_version__ = "v1"
4
4
  __base_url__ = f"https://api.aide.weco.ai/{__api_version__}"
weco/cli.py CHANGED
@@ -321,7 +321,12 @@ def main() -> None:
321
321
  _, best_solution_panel = solution_panels.get_display(current_step=steps)
322
322
 
323
323
  # Update the end optimization layout
324
- 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))
325
330
  end_optimization_layout["tree"].update(tree_panel.get_display())
326
331
  end_optimization_layout["best_solution"].update(best_solution_panel)
327
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
 
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weco
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
5
- Author-email: Weco AI Team <dhruv@weco.ai>
5
+ Author-email: Weco AI Team <contact@weco.ai>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/WecoAI/weco-cli
8
8
  Keywords: AI,Code Optimization,Code Generation
@@ -99,32 +99,69 @@ Here's how `weco` can be applied to common ML engineering tasks:
99
99
 
100
100
  ### Examples
101
101
 
102
- **Example 1: Optimizing PyTorch operations**
102
+ **Example 1: Optimizing PyTorch simple operations**
103
103
 
104
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" \
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" \
107
109
  --metric speedup \
108
110
  --maximize true \
109
111
  --steps 15 \
110
- --model o3-mini \
112
+ --model claude-3-7-sonnet-20250219 \
111
113
  --additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
112
114
  ```
113
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
+
114
118
  **Example 2: Optimizing MLX operations with instructions from a file**
115
119
 
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.
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.
117
121
 
118
122
  ```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" \
123
+ cd examples/metal
124
+ pip install mlx
125
+ weco --source optimize.py \
126
+ --eval-command "python evaluate.py --solution-path optimize.py" \
121
127
  --metric speedup \
122
128
  --maximize true \
123
129
  --steps 30 \
124
130
  --model o3-mini \
125
- --additional-instructions examples/simple-mlx/metal-examples.rst
131
+ --additional-instructions examples.rst
126
132
  ```
127
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
+
128
165
  ---
129
166
 
130
167
  ### Command Line Arguments
@@ -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,11 +0,0 @@
1
- weco/__init__.py,sha256=uqfsknG6Jxky4ddpuNn9SYN2lWNJloPDykqCjcmU1UQ,124
2
- weco/api.py,sha256=8rIf2Fy3tN6GW7BG1CaggtfE9pW56I1erzwLCgawcVE,3511
3
- weco/cli.py,sha256=rb01pl0Q8sLKBpZ9Qtlz044pEppJAa8CJkv2XM9zzFo,16753
4
- weco/panels.py,sha256=5HrDrYzx_vDjV41mlZmOOZYxdJIXD5RzBBNKXxUOLEY,12022
5
- weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
6
- weco-0.2.5.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
- weco-0.2.5.dist-info/METADATA,sha256=bjW2DWItTu3y_lmLllZIRz43hh5vMCi_u4FXW5eKz5E,9863
8
- weco-0.2.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
- weco-0.2.5.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
- weco-0.2.5.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
- weco-0.2.5.dist-info/RECORD,,
File without changes