openevolve-bedrock 0.2.0__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.
- openevolve_bedrock-0.2.0/LICENSE +202 -0
- openevolve_bedrock-0.2.0/PKG-INFO +288 -0
- openevolve_bedrock-0.2.0/README.md +262 -0
- openevolve_bedrock-0.2.0/pyproject.toml +46 -0
- openevolve_bedrock-0.2.0/setup.cfg +4 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/__init__.py +43 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/__main__.py +10 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/cli.py +380 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/ledger.py +307 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/pool.py +283 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/pricing.example.yaml +29 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/provider.py +770 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock/stopping.py +139 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock.egg-info/PKG-INFO +288 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock.egg-info/SOURCES.txt +22 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock.egg-info/dependency_links.txt +1 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock.egg-info/entry_points.txt +2 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock.egg-info/requires.txt +8 -0
- openevolve_bedrock-0.2.0/src/openevolve_bedrock.egg-info/top_level.txt +1 -0
- openevolve_bedrock-0.2.0/tests/test_e2e_spawn.py +189 -0
- openevolve_bedrock-0.2.0/tests/test_kissat_example.py +315 -0
- openevolve_bedrock-0.2.0/tests/test_ledger_and_cli.py +295 -0
- openevolve_bedrock-0.2.0/tests/test_pool.py +207 -0
- openevolve_bedrock-0.2.0/tests/test_provider.py +620 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openevolve-bedrock
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Amazon Bedrock as the LLM backend for OpenEvolve (AlphaEvolve-class evolutionary coding), with a per-call cost ledger.
|
|
5
|
+
Author: Scott Friedman
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/scttfrdmn/openevolve-bedrock
|
|
8
|
+
Project-URL: Issues, https://github.com/scttfrdmn/openevolve-bedrock/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/scttfrdmn/openevolve-bedrock/blob/main/CHANGELOG.md
|
|
10
|
+
Keywords: openevolve,alphaevolve,bedrock,evolutionary,llm
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: openevolve>=0.4.0
|
|
19
|
+
Requires-Dist: boto3>=1.35
|
|
20
|
+
Requires-Dist: openai>=1.0
|
|
21
|
+
Requires-Dist: pyyaml>=6
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
24
|
+
Requires-Dist: numpy; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# openevolve-bedrock
|
|
28
|
+
|
|
29
|
+
Amazon Bedrock as the LLM backend for [OpenEvolve](https://github.com/algorithmicsuperintelligence/openevolve),
|
|
30
|
+
the open-source AlphaEvolve-class evolutionary coding agent — plus a per-call
|
|
31
|
+
usage ledger so a run reports what it cost, not just what it found.
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
llm:
|
|
35
|
+
provider: bedrock
|
|
36
|
+
api_base: aws://us-west-2
|
|
37
|
+
models:
|
|
38
|
+
- name: us.anthropic.claude-haiku-5-5 # breadth
|
|
39
|
+
weight: 0.8
|
|
40
|
+
- name: us.anthropic.claude-sonnet-5-5 # depth
|
|
41
|
+
weight: 0.2
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install openevolve-bedrock
|
|
46
|
+
oe-bedrock run initial_program.py evaluator.py --config config.yaml --iterations 100
|
|
47
|
+
oe-bedrock cost openevolve_output/ --pricing pricing.yaml --threshold 0.99
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## What it does
|
|
51
|
+
|
|
52
|
+
OpenEvolve's loop is unchanged: prompt sampler → weighted LLM ensemble →
|
|
53
|
+
your `evaluate()` → MAP-Elites archive with islands. This package replaces the
|
|
54
|
+
model calls and adds accounting:
|
|
55
|
+
|
|
56
|
+
| | |
|
|
57
|
+
|---|---|
|
|
58
|
+
| **Two transports** | `api_base: aws://<region>` uses the **Converse API** through boto3 (SigV4, IAM roles, instance profiles, or a Bedrock API key in `AWS_BEARER_TOKEN_BEDROCK`). An `https://` `api_base` uses Bedrock's **OpenAI-compatible Chat Completions** (`bedrock-mantle.<region>.api.aws/v1` or `bedrock-runtime.<region>.amazonaws.com/openai/v1`) with a Bedrock API key, or short-term keys minted from your AWS credentials when none is set. Same config, same ledger; swap the URL to compare endpoints. |
|
|
59
|
+
| **Any Bedrock model** | Any text model Bedrock serves, from any vendor: Claude, Nova, Llama, Mistral, DeepSeek, Qwen, OpenAI, Moonshot, Z.AI, MiniMax, xAI, Gemma, Nemotron… Models disagree on what a request may contain (cache point, `temperature`, thinking and reasoning fields), so the provider sends the current-generation shape and, when Bedrock rejects a field, drops or swaps it for that model, retries without spending a retry attempt, and remembers for the rest of the process. One warning per model and adaptation is logged. No model table to go stale. |
|
|
60
|
+
| **Prompt caching** | Converse transport adds a cache point after the system message; models that don't take one are detected on the first call. Cache hits require the system message to clear the model's minimum — 512 tokens on current Claude models, up to 4096 on some (Claude Haiku 4.5): put the stable problem description and instructions in `prompt.system_message`, not the user turn. Some models cache on their own (xAI Grok). `OE_BEDROCK_CACHE=off` disables the cache point. |
|
|
61
|
+
| **Throttle-aware retry** | `ThrottlingException`, 429, `ServiceUnavailable`, `ModelNotReady` and connection errors are retried with exponential backoff and jitter (`OE_BEDROCK_MAX_ATTEMPTS`, default 8). Throttles are counted in the ledger so you can see what your island parallelism is costing in wall-clock. |
|
|
62
|
+
| **Parameter hygiene** | `seed` is never sent (Bedrock rejects it); `top_p: null` is never sent (openevolve #414); `temperature`/`top_p` are dropped for models that reject them (current Claude, GPT-5.5/6.x, Grok, Kimi K3). `reasoning_effort` maps to Claude adaptive thinking with `output_config.effort` (falling back to a `budget_tokens` budget on models without adaptive thinking, e.g. Haiku 4.5; `OE_BEDROCK_THINKING_BUDGET=N` asks for a budget), and to `reasoning_effort` or `reasoning.effort` for other vendors, dropped where neither is accepted. |
|
|
63
|
+
| **Ledger** | One JSON line per call: model, transport, input/output/cache-read/cache-write tokens, latency, attempts, throttles, stop reason. Written with `O_APPEND` so OpenEvolve's worker processes share one file. Default location `<output_dir>/bedrock_ledger.jsonl`. |
|
|
64
|
+
| **Cost and $/result** | `oe-bedrock cost` prices the ledger from a `pricing.yaml` you fill from the Bedrock pricing page. `--threshold X --metric combined_score` finds the first checkpoint that reached X and reports spend up to that point. |
|
|
65
|
+
|
|
66
|
+
## Install
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install openevolve-bedrock # or: pip install -e . from a checkout
|
|
70
|
+
cp $(python -c 'import openevolve_bedrock,os;print(os.path.dirname(openevolve_bedrock.__file__))')/pricing.example.yaml pricing.yaml
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Fill `pricing.yaml` (USD per 1K tokens; cross-region prefixes `us.`/`eu.`/… are
|
|
74
|
+
matched automatically, but `us.` and `global.` profiles are priced differently,
|
|
75
|
+
so key the exact id to price it exactly). Prices are not shipped because they
|
|
76
|
+
change; the AWS Price List API (`AmazonBedrockFoundationModels`) has them per
|
|
77
|
+
region. The tool reports any model without `input`/`output` prices; empty
|
|
78
|
+
`cache_read`/`cache_write` count as 0.
|
|
79
|
+
|
|
80
|
+
Credentials: whatever boto3 finds (`AWS_PROFILE`, instance role, SSO), or a
|
|
81
|
+
Bedrock API key in `AWS_BEARER_TOKEN_BEDROCK`. The `https://` transport needs a
|
|
82
|
+
Bedrock API key; without one it signs short-term keys from the boto3
|
|
83
|
+
credentials (as `aws-bedrock-token-generator` does) and re-signs them every
|
|
84
|
+
15 minutes. Region from `api_base`,
|
|
85
|
+
`OE_BEDROCK_REGION`, or `AWS_REGION`.
|
|
86
|
+
|
|
87
|
+
## Run
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
oe-bedrock models --profiles # text models, profiles, lifecycle (LEGACY ...)
|
|
91
|
+
oe-bedrock models --profiles --vendor mistral # one vendor
|
|
92
|
+
oe-bedrock check --config config.yaml # one short call per model
|
|
93
|
+
oe-bedrock check --config config.yaml --cache-probe # ~5K-token system prompt twice: does the 2nd read the cache?
|
|
94
|
+
oe-bedrock run initial_program.py evaluator.py --config config.yaml --iterations 100
|
|
95
|
+
oe-bedrock cost openevolve_output/ --pricing pricing.yaml
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Stopping early
|
|
99
|
+
|
|
100
|
+
- `--target-score T` is OpenEvolve's own: stop once a program's
|
|
101
|
+
`combined_score` reaches T.
|
|
102
|
+
- `--budget-usd X --pricing pricing.yaml` stops once the run's ledger, priced
|
|
103
|
+
with that file, reaches $X. It is checked before each new iteration is
|
|
104
|
+
submitted. Iterations already in flight finish and are recorded, so the
|
|
105
|
+
overshoot is at most `2 × parallel_evaluations` calls. Every model in the
|
|
106
|
+
config must have a price, or the run refuses to start. Also settable as
|
|
107
|
+
`OE_BEDROCK_BUDGET_USD` / `OE_BEDROCK_PRICING`.
|
|
108
|
+
|
|
109
|
+
After either stop, the last checkpoint is the iteration where the run
|
|
110
|
+
stopped. On its own, OpenEvolve labels its final checkpoint with the maximum
|
|
111
|
+
iteration (`checkpoint_100` for a run that stopped at 57). OpenEvolve then logs
|
|
112
|
+
"stopped due to shutdown request", which is expected.
|
|
113
|
+
|
|
114
|
+
`oe-bedrock run` is OpenEvolve's own CLI with the provider registered and the
|
|
115
|
+
ledger pointed at the output directory; extra flags pass through. The Python API works
|
|
116
|
+
too — importing the package is the registration:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
import openevolve_bedrock # registers provider: bedrock
|
|
120
|
+
from openevolve import OpenEvolve
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
If you launch OpenEvolve some other way (`openevolve-run.py`, your own script)
|
|
124
|
+
and use process-parallel workers under the spawn start method (macOS default),
|
|
125
|
+
the workers must import this package too. Either put `import openevolve_bedrock`
|
|
126
|
+
at the top of the script that is `__main__`, or run `oe-bedrock install-hook`
|
|
127
|
+
once to add a `.pth` file that imports it in every interpreter of that environment.
|
|
128
|
+
|
|
129
|
+
### Mantle vs. Converse
|
|
130
|
+
|
|
131
|
+
Both endpoints bill the same per token. They differ in how throughput is
|
|
132
|
+
managed: `bedrock-runtime` has per-account RPM/TPM quotas; Mantle schedules and
|
|
133
|
+
queues for fair share with higher initial throughput, which suits the bursty
|
|
134
|
+
fan-out of island-parallel evolution. To compare on your account:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
llm:
|
|
138
|
+
provider: bedrock
|
|
139
|
+
api_base: https://bedrock-mantle.us-west-2.api.aws/v1
|
|
140
|
+
# api_key: "${AWS_BEARER_TOKEN_BEDROCK}" # optional; else minted from AWS credentials
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Everything else stays the same. `cost` reports throttles per run, so the
|
|
144
|
+
comparison is wall-clock and throttle count at fixed `parallel_evaluations`.
|
|
145
|
+
|
|
146
|
+
The transport is chosen per model, so one ensemble can mix them. Set
|
|
147
|
+
`api_base` on a model to override the `llm`-level one:
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
llm:
|
|
151
|
+
provider: bedrock
|
|
152
|
+
api_base: aws://us-west-2 # default: Converse
|
|
153
|
+
models:
|
|
154
|
+
- name: us.anthropic.claude-haiku-5-5 # Converse
|
|
155
|
+
weight: 0.6
|
|
156
|
+
- name: us.openai.gpt-6.1-sol # bedrock-runtime Chat Completions
|
|
157
|
+
weight: 0.2
|
|
158
|
+
api_base: https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1
|
|
159
|
+
- name: openai.gpt-oss-120b # Mantle Chat Completions
|
|
160
|
+
weight: 0.2
|
|
161
|
+
api_base: https://bedrock-mantle.us-west-2.api.aws/v1
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
All three share one set of AWS credentials and one ledger; `cost` breaks the
|
|
165
|
+
run down per model.
|
|
166
|
+
|
|
167
|
+
Notes on the OpenAI-compatible endpoints, from the
|
|
168
|
+
[Bedrock endpoint docs](https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html)
|
|
169
|
+
and live runs (2026-10-28):
|
|
170
|
+
|
|
171
|
+
- AWS recommends `https://bedrock-runtime.<region>.amazonaws.com/openai/v1`
|
|
172
|
+
for Chat Completions. It takes cross-region ids (`us.openai.gpt-6.1-sol`) and
|
|
173
|
+
versioned ids (`openai.gpt-oss-120b-1:0`), but has no `GET /models`.
|
|
174
|
+
- Mantle has no cross-region profiles; ids are unversioned
|
|
175
|
+
(`openai.gpt-oss-120b`) and `GET /v1/models` lists them. Its base path varies
|
|
176
|
+
by model: most are under `/v1`, some (GPT-6.1 Sol) under `/openai/v1`, and
|
|
177
|
+
the wrong one answers "isn't supported on this route". Each model card's
|
|
178
|
+
Programmatic Access table gives the URL. Claude isn't served on Mantle's Chat
|
|
179
|
+
Completions; use Converse.
|
|
180
|
+
- Mantle needs IAM `bedrock-mantle:CreateInference`; `bedrock-runtime` needs
|
|
181
|
+
`bedrock:InvokeModel`.
|
|
182
|
+
- Prompt caching depends on the model. GPT-5.6 and later cache automatically
|
|
183
|
+
(1,024-token minimum) and report `prompt_tokens_details.cached_tokens` and
|
|
184
|
+
`cache_write_tokens`; the ledger records both. gpt-oss, Qwen, GLM and
|
|
185
|
+
Devstral report no cache usage.
|
|
186
|
+
- On `bedrock-runtime`, gpt-oss returns its reasoning inline in `content` as a
|
|
187
|
+
leading `<reasoning>…</reasoning>` span; the provider strips it.
|
|
188
|
+
|
|
189
|
+
## Experiments the ledger is built for
|
|
190
|
+
|
|
191
|
+
`bench/matrix.py` runs one problem under several ensemble mixes and seeds,
|
|
192
|
+
checkpointing every 5 iterations, and writes two CSVs under `--out`:
|
|
193
|
+
|
|
194
|
+
- `results.csv`, a row per run: configured and realized mix, `best@N`, then
|
|
195
|
+
for each `--threshold` the iteration and $ at which it was first reached
|
|
196
|
+
(blank if never), then $ total, calls, throttles and wall time.
|
|
197
|
+
- `curves.csv`, a row per checkpoint per run: best-so-far, cumulative $ and
|
|
198
|
+
calls, seconds since the first call. This is the $/result curve: what each
|
|
199
|
+
extra dollar bought, which no single threshold shows.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
python bench/matrix.py examples/circle_packing --pricing pricing.yaml \
|
|
203
|
+
--iterations 100 --threshold 0.99 0.995 0.999 --seeds 1 2 3 \
|
|
204
|
+
--variant fast-only "haiku:1.0" \
|
|
205
|
+
--variant gpt-oss "gpt-oss:1.0" \
|
|
206
|
+
--variant 80-20 "haiku:0.8,sonnet:0.2" \
|
|
207
|
+
--variant 50-50 "haiku:0.5,sonnet:0.5"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Thresholds only affect scoring. Both CSVs are rebuilt from every run dir
|
|
211
|
+
under `--out`, so `--rescore` re-scores finished runs at other thresholds
|
|
212
|
+
without calling Bedrock. `--target-score` and `--budget-usd` are passed to
|
|
213
|
+
every run. A finished run is reused, so an interrupted matrix resumes; an
|
|
214
|
+
interrupted run's dir is moved aside (`*.interrupted-<time>`) and rerun from
|
|
215
|
+
scratch. In `--variant`, a model id that contains `:`
|
|
216
|
+
needs an explicit weight (`openai.gpt-oss-120b-1:0:1.0`); aliases don't.
|
|
217
|
+
|
|
218
|
+
Three measurements this makes cheap:
|
|
219
|
+
|
|
220
|
+
1. **Ensemble mix** — the paper's fast-heavy/strong-light split against all-fast
|
|
221
|
+
and 50/50, on iterations-to-threshold and $. OpenEvolve 0.4.0 seeds every
|
|
222
|
+
worker's ensemble RNG identically, so all workers draw the same model
|
|
223
|
+
sequence ([openevolve#554](https://github.com/algorithmicsuperintelligence/openevolve/issues/554)).
|
|
224
|
+
OpenEvolve 0.4.1 reseeds per iteration itself (`LLMEnsemble.reseed`). On
|
|
225
|
+
0.4.0 this package does the same from `(llm_seed, iteration)`. Either way,
|
|
226
|
+
runs are reproducible with independent draws. The `realized_mix`
|
|
227
|
+
column still reports what each run actually got: with 100 iterations a
|
|
228
|
+
0.2 weight can land anywhere from roughly 0.12 to 0.28.
|
|
229
|
+
2. **Endpoint** — same config with `--api-base` set to the Mantle URL; compare
|
|
230
|
+
throttles and wall-clock at the same island parallelism.
|
|
231
|
+
3. **Open-weight on Bedrock vs. local** — gpt-oss-120b ships its weights in
|
|
232
|
+
MXFP4, so Bedrock and a local server run the same weights and the
|
|
233
|
+
comparison is $/result and wall time alone, with no quantization
|
|
234
|
+
difference. Run it fast-only (`gpt-oss:1.0`) against Haiku fast-only to
|
|
235
|
+
isolate the model. The local side is any OpenAI-compatible server (vLLM,
|
|
236
|
+
llama.cpp) via a plain `api_base`.
|
|
237
|
+
|
|
238
|
+
`combined_score` for circle packing is `sum_radii / 2.635`, so `--threshold 0.99`
|
|
239
|
+
is 2.609, `0.995` is 2.622 and `1.0` is the AlphaEvolve figure.
|
|
240
|
+
|
|
241
|
+
## Configuration reference
|
|
242
|
+
|
|
243
|
+
| key | meaning |
|
|
244
|
+
|---|---|
|
|
245
|
+
| `llm.provider: bedrock` | required; may be set per model instead |
|
|
246
|
+
| `llm.api_base` | `aws://<region>` (Converse) or an `https://` OpenAI-compatible Bedrock endpoint |
|
|
247
|
+
| `llm.api_key` | Bedrock API key for the `https://` transport; `"${VAR}"` is resolved from the environment |
|
|
248
|
+
| `llm.models[].name` | model id or inference-profile id (`us.`, `eu.`, `global.` …) |
|
|
249
|
+
| `llm.models[].api_base`, `.api_key` | per-model override, e.g. to mix Converse and OpenAI-compatible models in one ensemble |
|
|
250
|
+
| `temperature`, `top_p`, `max_tokens`, `timeout`, `reasoning_effort` | as in OpenEvolve; `retries`/`retry_delay` are superseded by `OE_BEDROCK_MAX_ATTEMPTS` |
|
|
251
|
+
|
|
252
|
+
| environment | meaning |
|
|
253
|
+
|---|---|
|
|
254
|
+
| `OE_BEDROCK_REGION`, `OE_BEDROCK_PROFILE` | default region; boto3 profile |
|
|
255
|
+
| `OE_BEDROCK_CACHE` | `auto` (default) or `off` |
|
|
256
|
+
| `OE_BEDROCK_LEDGER` | ledger path, or `off` |
|
|
257
|
+
| `OE_BEDROCK_MAX_ATTEMPTS` | retry budget for throttles/transient errors (default 8) |
|
|
258
|
+
| `OE_BEDROCK_THINKING_BUDGET` | enable Claude extended thinking with this token budget |
|
|
259
|
+
| `OE_BEDROCK_BUDGET_USD`, `OE_BEDROCK_PRICING` | stop the run at this spend, priced with this file (same as `run --budget-usd --pricing`) |
|
|
260
|
+
| `AWS_BEARER_TOKEN_BEDROCK` | Bedrock API key (both transports; optional for `https://`, which can mint one) |
|
|
261
|
+
|
|
262
|
+
## Tests
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
pip install -e ".[dev]"
|
|
266
|
+
pytest # 50 tests, ~15 s, no AWS credentials needed
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`tests/test_e2e_spawn.py` runs a real 40-iteration OpenEvolve job twice with
|
|
270
|
+
process-parallel workers under the spawn start method against a fake Mantle
|
|
271
|
+
server that returns programs, reports usage and throws 429s at random — the
|
|
272
|
+
case that matters for macOS users and for the retry path. It asserts that
|
|
273
|
+
per-model call counts match the per-iteration seeding exactly and repeat
|
|
274
|
+
across runs.
|
|
275
|
+
|
|
276
|
+
## Not in scope (yet)
|
|
277
|
+
|
|
278
|
+
- Evaluator fan-out to EC2. OpenEvolve's `evaluate()` runs in local worker
|
|
279
|
+
processes; for expensive evaluators the next step is a shim that ships
|
|
280
|
+
candidates to a pool and returns metrics. The ledger already separates token
|
|
281
|
+
cost from everything else so the two tiers can be reported side by side.
|
|
282
|
+
- Bedrock batch inference. The loop is latency-bound per iteration, so batch
|
|
283
|
+
jobs don't fit without restructuring generation into offline waves.
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
Apache License 2.0 — Copyright 2026 Scott Friedman. OpenEvolve and the example
|
|
288
|
+
problems are Apache-2.0, Copyright Asankhaya Sharma; see `NOTICE`.
|