weco 0.2.18__py3-none-any.whl → 0.2.19__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/cli.py +50 -12
- {weco-0.2.18.dist-info → weco-0.2.19.dist-info}/METADATA +23 -15
- {weco-0.2.18.dist-info → weco-0.2.19.dist-info}/RECORD +7 -7
- {weco-0.2.18.dist-info → weco-0.2.19.dist-info}/WHEEL +0 -0
- {weco-0.2.18.dist-info → weco-0.2.19.dist-info}/entry_points.txt +0 -0
- {weco-0.2.18.dist-info → weco-0.2.19.dist-info}/licenses/LICENSE +0 -0
- {weco-0.2.18.dist-info → weco-0.2.19.dist-info}/top_level.txt +0 -0
weco/cli.py
CHANGED
|
@@ -247,29 +247,55 @@ def main() -> None:
|
|
|
247
247
|
|
|
248
248
|
# --- Run Command ---
|
|
249
249
|
run_parser = subparsers.add_parser(
|
|
250
|
-
"run", help="Run code optimization", formatter_class=argparse.RawDescriptionHelpFormatter
|
|
250
|
+
"run", help="Run code optimization", formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False
|
|
251
251
|
)
|
|
252
252
|
# Add arguments specific to the 'run' command to the run_parser
|
|
253
|
-
run_parser.add_argument("--source", type=str, required=True, help="Path to the source code file (e.g. optimize.py)")
|
|
254
253
|
run_parser.add_argument(
|
|
255
|
-
"
|
|
254
|
+
"-s",
|
|
255
|
+
"--source",
|
|
256
|
+
type=str,
|
|
257
|
+
required=True,
|
|
258
|
+
help="Path to the source code file that will be optimized (e.g., `optimize.py`)",
|
|
259
|
+
)
|
|
260
|
+
run_parser.add_argument(
|
|
261
|
+
"-c",
|
|
262
|
+
"--eval-command",
|
|
263
|
+
type=str,
|
|
264
|
+
required=True,
|
|
265
|
+
help="Command to run for evaluation (e.g. 'python eval.py --arg1=val1').",
|
|
266
|
+
)
|
|
267
|
+
run_parser.add_argument(
|
|
268
|
+
"-m",
|
|
269
|
+
"--metric",
|
|
270
|
+
type=str,
|
|
271
|
+
required=True,
|
|
272
|
+
help="Metric to optimize (e.g. 'accuracy', 'loss', 'f1_score') that is printed to the terminal by the eval command.",
|
|
256
273
|
)
|
|
257
|
-
run_parser.add_argument("--metric", type=str, required=True, help="Metric to optimize")
|
|
258
274
|
run_parser.add_argument(
|
|
259
|
-
"
|
|
275
|
+
"-g",
|
|
276
|
+
"--goal",
|
|
260
277
|
type=str,
|
|
261
|
-
choices=["
|
|
278
|
+
choices=["maximize", "max", "minimize", "min"],
|
|
262
279
|
required=True,
|
|
263
|
-
help="Specify '
|
|
280
|
+
help="Specify 'maximize'/'max' to maximize the metric or 'minimize'/'min' to minimize it.",
|
|
281
|
+
)
|
|
282
|
+
run_parser.add_argument("-n", "--steps", type=int, default=100, help="Number of steps to run. Defaults to 100.")
|
|
283
|
+
run_parser.add_argument(
|
|
284
|
+
"-M",
|
|
285
|
+
"--model",
|
|
286
|
+
type=str,
|
|
287
|
+
default=None,
|
|
288
|
+
help="Model to use for optimization. Defaults to `o4-mini` when `OPENAI_API_KEY` is set, `claude-3-7-sonnet-20250219` when `ANTHROPIC_API_KEY` is set, and `gemini-2.5-pro-exp-03-25` when `GEMINI_API_KEY` is set. When multiple keys are set, the priority is `OPENAI_API_KEY` > `ANTHROPIC_API_KEY` > `GEMINI_API_KEY`.",
|
|
264
289
|
)
|
|
265
|
-
run_parser.add_argument("--steps", type=int, required=True, help="Number of steps to run")
|
|
266
|
-
run_parser.add_argument("--model", type=str, required=True, help="Model to use for optimization")
|
|
267
|
-
run_parser.add_argument("--log-dir", type=str, default=".runs", help="Directory to store logs and results")
|
|
268
290
|
run_parser.add_argument(
|
|
291
|
+
"-l", "--log-dir", type=str, default=".runs", help="Directory to store logs and results. Defaults to `.runs`."
|
|
292
|
+
)
|
|
293
|
+
run_parser.add_argument(
|
|
294
|
+
"-i",
|
|
269
295
|
"--additional-instructions",
|
|
270
296
|
default=None,
|
|
271
297
|
type=str,
|
|
272
|
-
help="Description of additional instruction or path to a file containing additional instructions",
|
|
298
|
+
help="Description of additional instruction or path to a file containing additional instructions. Defaults to None.",
|
|
273
299
|
)
|
|
274
300
|
|
|
275
301
|
# --- Logout Command ---
|
|
@@ -328,8 +354,20 @@ def main() -> None:
|
|
|
328
354
|
# --- Configuration Loading ---
|
|
329
355
|
evaluation_command = args.eval_command
|
|
330
356
|
metric_name = args.metric
|
|
331
|
-
maximize = args.
|
|
357
|
+
maximize = args.goal in ["maximize", "max"]
|
|
332
358
|
steps = args.steps
|
|
359
|
+
# Determine the model to use
|
|
360
|
+
if args.model is None:
|
|
361
|
+
if "OPENAI_API_KEY" in llm_api_keys:
|
|
362
|
+
args.model = "o4-mini"
|
|
363
|
+
elif "ANTHROPIC_API_KEY" in llm_api_keys:
|
|
364
|
+
args.model = "claude-3-7-sonnet-20250219"
|
|
365
|
+
elif "GEMINI_API_KEY" in llm_api_keys:
|
|
366
|
+
args.model = "gemini-2.5-pro-exp-03-25"
|
|
367
|
+
else:
|
|
368
|
+
raise ValueError(
|
|
369
|
+
"No LLM API keys found in environment. Please set one of the following: OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY."
|
|
370
|
+
)
|
|
333
371
|
code_generator_config = {"model": args.model}
|
|
334
372
|
evaluator_config = {"model": args.model, "include_analysis": True}
|
|
335
373
|
search_policy_config = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: weco
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.19
|
|
4
4
|
Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
|
|
5
5
|
Author-email: Weco AI Team <contact@weco.ai>
|
|
6
6
|
License: MIT
|
|
@@ -98,9 +98,8 @@ pip install torch
|
|
|
98
98
|
weco run --source optimize.py \
|
|
99
99
|
--eval-command "python evaluate.py --solution-path optimize.py --device cpu" \
|
|
100
100
|
--metric speedup \
|
|
101
|
-
--maximize
|
|
101
|
+
--goal maximize \
|
|
102
102
|
--steps 15 \
|
|
103
|
-
--model gemini-2.5-pro-exp-03-25 \
|
|
104
103
|
--additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
|
|
105
104
|
```
|
|
106
105
|
|
|
@@ -108,18 +107,27 @@ weco run --source optimize.py \
|
|
|
108
107
|
|
|
109
108
|
---
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
### Arguments for `weco run`
|
|
111
|
+
|
|
112
|
+
**Required:**
|
|
113
|
+
|
|
114
|
+
| Argument | Description |
|
|
115
|
+
| :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
116
|
+
| `-s, --source` | Path to the source code file that will be optimized (e.g., `optimize.py`). |
|
|
117
|
+
| `-c, --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. |
|
|
118
|
+
| `-m, --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`. |
|
|
119
|
+
| `-g, --goal` | `maximize`/`max` to maximize the `--metric` or `minimize`/`min` to minimize it. |
|
|
120
|
+
|
|
121
|
+
<br>
|
|
122
|
+
|
|
123
|
+
**Optional:**
|
|
124
|
+
|
|
125
|
+
| Argument | Description | Default |
|
|
126
|
+
| :----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ |
|
|
127
|
+
| `-n, --steps` | Number of optimization steps (LLM iterations) to run. | 100 |
|
|
128
|
+
| `-M, --model` | Model identifier for the LLM to use (e.g., `gpt-4o`, `claude-3.5-sonnet`). | `o4-mini` when `OPENAI_API_KEY` is set; `claude-3-7-sonnet-20250219` when `ANTHROPIC_API_KEY` is set; `gemini-2.5-pro-exp-03-25` when `GEMINI_API_KEY` is set (priority: `OPENAI_API_KEY` > `ANTHROPIC_API_KEY` > `GEMINI_API_KEY`). |
|
|
129
|
+
| `-i, --additional-instructions`| Natural language description of specific instructions **or** path to a file containing detailed instructions to guide the LLM. | `None` |
|
|
130
|
+
| `-l, --log-dir` | Path to the directory to log intermediate steps and final optimization result. | `.runs/` |
|
|
123
131
|
|
|
124
132
|
---
|
|
125
133
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
weco/__init__.py,sha256=npWmRgLxfVK69GdyxIujnI87xqmPCBrZWxxAxL_QQOc,478
|
|
2
2
|
weco/api.py,sha256=lJJ0j0-bABiQXDlRb43fCo7ky0N_HwfZgFdMktRKQ90,6635
|
|
3
3
|
weco/auth.py,sha256=IPfiLthcNRkPyM8pWHTyDLvikw83sigacpY1PmeA03Y,2343
|
|
4
|
-
weco/cli.py,sha256=
|
|
4
|
+
weco/cli.py,sha256=eI468fxpMTfGPL-aX6EMYxh0NuaRxpaLVF_Jj2DiFhU,36383
|
|
5
5
|
weco/panels.py,sha256=pM_YGnmcXM_1CBcxo_EAzOV3g_4NFdLS4MqDqx7THbA,13563
|
|
6
6
|
weco/utils.py,sha256=LVTBo3dduJmhlbotcYoUW2nLx6IRtKs4eDFR52Qltcg,5244
|
|
7
|
-
weco-0.2.
|
|
8
|
-
weco-0.2.
|
|
9
|
-
weco-0.2.
|
|
10
|
-
weco-0.2.
|
|
11
|
-
weco-0.2.
|
|
12
|
-
weco-0.2.
|
|
7
|
+
weco-0.2.19.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
|
|
8
|
+
weco-0.2.19.dist-info/METADATA,sha256=3VBVsCqr7p332A10KsLr168GvOIKcCOWWfGDv8ViF7I,10729
|
|
9
|
+
weco-0.2.19.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
10
|
+
weco-0.2.19.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
|
|
11
|
+
weco-0.2.19.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
12
|
+
weco-0.2.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|