shipyard-rl 0.1.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.
Files changed (121) hide show
  1. shipyard_rl-0.1.0/.env.example +48 -0
  2. shipyard_rl-0.1.0/.gitignore +26 -0
  3. shipyard_rl-0.1.0/LICENSE +202 -0
  4. shipyard_rl-0.1.0/PKG-INFO +100 -0
  5. shipyard_rl-0.1.0/README.md +52 -0
  6. shipyard_rl-0.1.0/pyproject.toml +110 -0
  7. shipyard_rl-0.1.0/recipes/README.md +50 -0
  8. shipyard_rl-0.1.0/recipes/dapo/README.md +18 -0
  9. shipyard_rl-0.1.0/recipes/dapo/run.toml +32 -0
  10. shipyard_rl-0.1.0/recipes/dapo/trainer.py +108 -0
  11. shipyard_rl-0.1.0/recipes/dapo-async/README.md +18 -0
  12. shipyard_rl-0.1.0/recipes/dapo-async/run.toml +36 -0
  13. shipyard_rl-0.1.0/recipes/dapo-async/trainer.py +155 -0
  14. shipyard_rl-0.1.0/recipes/gepa/README.md +18 -0
  15. shipyard_rl-0.1.0/recipes/gepa/modules/PROMPT.md +1 -0
  16. shipyard_rl-0.1.0/recipes/gepa/reflect.py +109 -0
  17. shipyard_rl-0.1.0/recipes/gepa/run.toml +34 -0
  18. shipyard_rl-0.1.0/recipes/gepa/trainer.py +219 -0
  19. shipyard_rl-0.1.0/recipes/grpo/README.md +18 -0
  20. shipyard_rl-0.1.0/recipes/grpo/run.toml +24 -0
  21. shipyard_rl-0.1.0/recipes/grpo/trainer.py +53 -0
  22. shipyard_rl-0.1.0/recipes/opd/README.md +18 -0
  23. shipyard_rl-0.1.0/recipes/opd/run.toml +28 -0
  24. shipyard_rl-0.1.0/recipes/opd/trainer.py +56 -0
  25. shipyard_rl-0.1.0/recipes/rft-async/README.md +19 -0
  26. shipyard_rl-0.1.0/recipes/rft-async/run.toml +40 -0
  27. shipyard_rl-0.1.0/recipes/rft-async/trainer.py +127 -0
  28. shipyard_rl-0.1.0/src/shipyard/README.md +24 -0
  29. shipyard_rl-0.1.0/src/shipyard/__init__.py +18 -0
  30. shipyard_rl-0.1.0/src/shipyard/cli.py +291 -0
  31. shipyard_rl-0.1.0/src/shipyard/config.py +410 -0
  32. shipyard_rl-0.1.0/src/shipyard/groups.py +289 -0
  33. shipyard_rl-0.1.0/src/shipyard/jobs/README.md +27 -0
  34. shipyard_rl-0.1.0/src/shipyard/jobs/__init__.py +1 -0
  35. shipyard_rl-0.1.0/src/shipyard/jobs/admit.py +134 -0
  36. shipyard_rl-0.1.0/src/shipyard/jobs/engine.py +497 -0
  37. shipyard_rl-0.1.0/src/shipyard/jobs/file.py +280 -0
  38. shipyard_rl-0.1.0/src/shipyard/jobs/harnesses.py +255 -0
  39. shipyard_rl-0.1.0/src/shipyard/jobs/hooks.py +90 -0
  40. shipyard_rl-0.1.0/src/shipyard/jobs/modules.py +327 -0
  41. shipyard_rl-0.1.0/src/shipyard/jobs/progress.py +53 -0
  42. shipyard_rl-0.1.0/src/shipyard/jobs/runner.py +230 -0
  43. shipyard_rl-0.1.0/src/shipyard/jobs/secrets.py +113 -0
  44. shipyard_rl-0.1.0/src/shipyard/jobs/together.py +562 -0
  45. shipyard_rl-0.1.0/src/shipyard/model.py +177 -0
  46. shipyard_rl-0.1.0/src/shipyard/models/README.md +21 -0
  47. shipyard_rl-0.1.0/src/shipyard/models/__init__.py +0 -0
  48. shipyard_rl-0.1.0/src/shipyard/models/backends.py +317 -0
  49. shipyard_rl-0.1.0/src/shipyard/models/clients/__init__.py +37 -0
  50. shipyard_rl-0.1.0/src/shipyard/models/clients/tinker.py +421 -0
  51. shipyard_rl-0.1.0/src/shipyard/models/clients/together.py +439 -0
  52. shipyard_rl-0.1.0/src/shipyard/models/endpoints.py +388 -0
  53. shipyard_rl-0.1.0/src/shipyard/py.typed +0 -0
  54. shipyard_rl-0.1.0/src/shipyard/records.py +198 -0
  55. shipyard_rl-0.1.0/src/shipyard/run/README.md +24 -0
  56. shipyard_rl-0.1.0/src/shipyard/run/__init__.py +0 -0
  57. shipyard_rl-0.1.0/src/shipyard/run/checkpoint.py +93 -0
  58. shipyard_rl-0.1.0/src/shipyard/run/costs.py +178 -0
  59. shipyard_rl-0.1.0/src/shipyard/run/data.py +183 -0
  60. shipyard_rl-0.1.0/src/shipyard/run/directory.py +243 -0
  61. shipyard_rl-0.1.0/src/shipyard/run/dry.py +197 -0
  62. shipyard_rl-0.1.0/src/shipyard/run/files.py +90 -0
  63. shipyard_rl-0.1.0/src/shipyard/run/logs.py +304 -0
  64. shipyard_rl-0.1.0/src/shipyard/state.py +39 -0
  65. shipyard_rl-0.1.0/src/shipyard/trainer.py +572 -0
  66. shipyard_rl-0.1.0/tests/__init__.py +0 -0
  67. shipyard_rl-0.1.0/tests/conftest.py +73 -0
  68. shipyard_rl-0.1.0/tests/fakes.py +329 -0
  69. shipyard_rl-0.1.0/tests/modules/bare/skills/solving/SKILL.md +3 -0
  70. shipyard_rl-0.1.0/tests/modules/unknown/skills/solving/README.md +3 -0
  71. shipyard_rl-0.1.0/tests/modules/valid/skills/solving/SKILL.md +8 -0
  72. shipyard_rl-0.1.0/tests/modules/valid/skills/solving/examples/worked.md +3 -0
  73. shipyard_rl-0.1.0/tests/runs.py +67 -0
  74. shipyard_rl-0.1.0/tests/service.py +241 -0
  75. shipyard_rl-0.1.0/tests/tasks/fixture/alpha/environment/Dockerfile +2 -0
  76. shipyard_rl-0.1.0/tests/tasks/fixture/alpha/instruction.md +1 -0
  77. shipyard_rl-0.1.0/tests/tasks/fixture/alpha/task.toml +4 -0
  78. shipyard_rl-0.1.0/tests/tasks/fixture/alpha/tests/test.sh +3 -0
  79. shipyard_rl-0.1.0/tests/tasks/fixture/beta/environment/Dockerfile +2 -0
  80. shipyard_rl-0.1.0/tests/tasks/fixture/beta/instruction.md +1 -0
  81. shipyard_rl-0.1.0/tests/tasks/fixture/beta/task.toml +4 -0
  82. shipyard_rl-0.1.0/tests/tasks/fixture/beta/tests/test.sh +3 -0
  83. shipyard_rl-0.1.0/tests/test_admit.py +252 -0
  84. shipyard_rl-0.1.0/tests/test_checkpoint.py +76 -0
  85. shipyard_rl-0.1.0/tests/test_connect.py +187 -0
  86. shipyard_rl-0.1.0/tests/test_costs.py +119 -0
  87. shipyard_rl-0.1.0/tests/test_dapo_async.py +142 -0
  88. shipyard_rl-0.1.0/tests/test_dry.py +131 -0
  89. shipyard_rl-0.1.0/tests/test_endpoints.py +373 -0
  90. shipyard_rl-0.1.0/tests/test_engine.py +719 -0
  91. shipyard_rl-0.1.0/tests/test_evaluation.py +219 -0
  92. shipyard_rl-0.1.0/tests/test_file_harness.py +598 -0
  93. shipyard_rl-0.1.0/tests/test_files.py +53 -0
  94. shipyard_rl-0.1.0/tests/test_harnesses.py +118 -0
  95. shipyard_rl-0.1.0/tests/test_hooks.py +166 -0
  96. shipyard_rl-0.1.0/tests/test_init.py +67 -0
  97. shipyard_rl-0.1.0/tests/test_lender.py +135 -0
  98. shipyard_rl-0.1.0/tests/test_logs.py +226 -0
  99. shipyard_rl-0.1.0/tests/test_losses.py +128 -0
  100. shipyard_rl-0.1.0/tests/test_model.py +198 -0
  101. shipyard_rl-0.1.0/tests/test_modules.py +705 -0
  102. shipyard_rl-0.1.0/tests/test_overrides.py +147 -0
  103. shipyard_rl-0.1.0/tests/test_pack.py +202 -0
  104. shipyard_rl-0.1.0/tests/test_pi_turn_cap.py +66 -0
  105. shipyard_rl-0.1.0/tests/test_progress.py +84 -0
  106. shipyard_rl-0.1.0/tests/test_proxy_lanes.py +141 -0
  107. shipyard_rl-0.1.0/tests/test_records.py +308 -0
  108. shipyard_rl-0.1.0/tests/test_renderers.py +172 -0
  109. shipyard_rl-0.1.0/tests/test_rft_async.py +129 -0
  110. shipyard_rl-0.1.0/tests/test_rollout.py +302 -0
  111. shipyard_rl-0.1.0/tests/test_secrets.py +266 -0
  112. shipyard_rl-0.1.0/tests/test_session.py +112 -0
  113. shipyard_rl-0.1.0/tests/test_slots.py +186 -0
  114. shipyard_rl-0.1.0/tests/test_spawn.py +156 -0
  115. shipyard_rl-0.1.0/tests/test_substeps.py +70 -0
  116. shipyard_rl-0.1.0/tests/test_tinker.py +227 -0
  117. shipyard_rl-0.1.0/tests/test_tinker_servers.py +154 -0
  118. shipyard_rl-0.1.0/tests/test_together.py +558 -0
  119. shipyard_rl-0.1.0/tests/test_together_sandbox.py +715 -0
  120. shipyard_rl-0.1.0/tests/test_trainer.py +1212 -0
  121. shipyard_rl-0.1.0/tests/test_trial_lifecycle.py +76 -0
@@ -0,0 +1,48 @@
1
+ # Copy to `.env` in the directory you run from, and uncomment what you use.
2
+ # Every line is commented on purpose: an uncommented `KEY=` still sets KEY, to nothing.
3
+ # A variable already set in the shell wins over the file; a key assigned twice keeps the
4
+ # last one.
5
+
6
+ # A model served from Tinker
7
+ # TINKER_API_KEY=
8
+ # Another server that speaks the Tinker API, for every model that names none; unset: Thinking
9
+ # Machines' Tinker
10
+ # TINKER_BASE_URL=
11
+ # A model that names its own server, [models.<role>] base_url, names the variable that holds
12
+ # that server's key as api_key_env, such as:
13
+ # SPINDLE_API_KEY=
14
+
15
+ # Modal, where the recipes run their trials: these two, unless its CLI holds a login
16
+ # (`uvx modal setup`)
17
+ # MODAL_TOKEN_ID=
18
+ # MODAL_TOKEN_SECRET=
19
+
20
+ # Optional: the proxy fetches the model's tokenizer from Hugging Face
21
+ # HF_TOKEN=
22
+
23
+ # Together: a model on its post-training, [models.<role>] provider = "together", and
24
+ # trials in its sandboxes, [rollout] sandbox = "together"
25
+ # TOGETHER_API_KEY=
26
+
27
+ # A model its provider serves: [models.<role>] provider, such as a recipe's reflector
28
+ # ANTHROPIC_API_KEY=
29
+ # OPENAI_API_KEY=
30
+
31
+ # Other sandboxes: only the ones you use; Harbor reads these. Beam and Blaxel also take their
32
+ # own CLI's login, and Daytona a JWT with an organization id.
33
+ # DAYTONA_API_KEY=
34
+ # E2B_API_KEY=
35
+ # RUNLOOP_API_KEY=
36
+ # BEAM_TOKEN=
37
+ # BL_WORKSPACE=
38
+ # BL_API_KEY=
39
+
40
+ # The proxy's two tokens; unset, each run makes its own. Never in [agent] env.
41
+ # HARNESS_PROXY_TOKEN=
42
+ # HARNESS_PROXY_CONTROL_TOKEN=
43
+
44
+ # Where runs live; unset: ./runs
45
+ # SHIPYARD_RUNS=
46
+
47
+ # A blueprint with [logging.wandb]: its key, unless `wandb login` holds one
48
+ # WANDB_API_KEY=
@@ -0,0 +1,26 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ dist/
7
+ build/
8
+ *.egg-info/
9
+ /runs/
10
+ /jobs/
11
+ /tasks/
12
+ .env
13
+ .DS_Store
14
+ /site/
15
+ /legacy/
16
+ MAP.md
17
+ experiments/
18
+ .claude
19
+ .agents
20
+ docs/*
21
+ !docs/adr/
22
+ mkdocs.yml
23
+ skills-lock.json
24
+ uv.lock
25
+ reports/
26
+ research_notes/
@@ -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,100 @@
1
+ Metadata-Version: 2.5
2
+ Name: shipyard-rl
3
+ Version: 0.1.0
4
+ Summary: Post-training on Harbor jobs: a config sets up a run, and a run is its record.
5
+ Project-URL: Repository, https://github.com/ghidav/shipyard
6
+ Project-URL: Issues, https://github.com/ghidav/shipyard/issues
7
+ Author: Davide Ghilardi
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: agents,cispo,dapo,gepa,grpo,harbor,llm,post-training,reinforcement-learning,tinker
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: harbor[modal]<0.25,>=0.23
22
+ Requires-Dist: harness-proxy==0.1.0
23
+ Requires-Dist: litellm>=1.103
24
+ Requires-Dist: pydantic>=2.9
25
+ Requires-Dist: python-dotenv>=1.0
26
+ Requires-Dist: rich>=14.1
27
+ Requires-Dist: shortuuid>=1.0.13
28
+ Requires-Dist: tinker-cookbook<0.7,>=0.6
29
+ Requires-Dist: tinker<0.39,>=0.38
30
+ Requires-Dist: tomli-w>=1.0
31
+ Requires-Dist: typer>=0.16
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
34
+ Requires-Dist: pytest>=8.3; extra == 'dev'
35
+ Requires-Dist: ruff>=0.8; extra == 'dev'
36
+ Provides-Extra: docs
37
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
38
+ Requires-Dist: mkdocs>=1.6; extra == 'docs'
39
+ Provides-Extra: gepa
40
+ Requires-Dist: gepa>=0.1.4; extra == 'gepa'
41
+ Provides-Extra: together
42
+ Requires-Dist: dockerfile-parse>=2.0.1; extra == 'together'
43
+ Requires-Dist: harness-proxy[together]==0.1.0; extra == 'together'
44
+ Requires-Dist: together-sandbox<5,>=4.1; extra == 'together'
45
+ Provides-Extra: wandb
46
+ Requires-Dist: wandb>=0.21; extra == 'wandb'
47
+ Description-Content-Type: text/markdown
48
+
49
+ # Shipyard
50
+
51
+ Post-training framework for AI agents on Harbor tasks.
52
+
53
+ ## Installation
54
+
55
+ Requires **Python 3.12+** and [uv](https://github.com/astral-sh/uv):
56
+
57
+ ```sh
58
+ uv tool install shipyard-rl
59
+ ```
60
+
61
+ ## Quickstart
62
+
63
+ The recipes train on [Tinker](https://thinkingmachines.ai/tinker/) and run their trials in [Modal](https://modal.com)'s sandboxes, whose calls reach the model through a Cloudflare tunnel this machine opens: install [`cloudflared`](https://github.com/cloudflare/cloudflared), or keep Docker running.
64
+
65
+ ```sh
66
+ shipyard init # copy the recipes and .env.example here
67
+ cp .env.example .env # then set TINKER_API_KEY in .env
68
+ uvx modal setup # log in to Modal, or set its keys in .env
69
+ uvx harbor@0.24.0 datasets download reasoning-gym-easy -o tasks # the recipes' tasks, in tasks/reasoning-gym-easy/
70
+ shipyard run recipes/dapo # the run writes runs/dapo__<id>/
71
+ ```
72
+
73
+ As shipped, the run takes about 1 h 45 min and costs about $20: $15 of Tinker and $5 of Modal, measured in November 2026. Add `--recipe.steps 1` to stop after the first step, about 10 minutes and under $2.
74
+
75
+ > [!IMPORTANT]
76
+ > Add `--dry` to see every setting the run would use, with each default `run.toml` leaves marked, and to check the run without starting it.
77
+
78
+ > [!TIP]
79
+ > For anything longer than a smoke test, start the run on a cloud VM rather than a laptop, for example in US East, and inside `tmux` so it outlives your SSH session. Every model call passes through the proxy on the machine that started the run, and that machine uploads each update's training data, so a laptop's distance, uplink and sleep slow or stall the whole run.
80
+
81
+ ## Customizing
82
+
83
+
84
+ - **Settings:** a recipe's settings can be updated in its `run.toml` (model, harnesses, data, learning rate, LoRA rank, ...); you can overwrite them using `--table.key VALUE` on `shipyard run`.
85
+ - **Algorithm:** a recipe defines a `trainer.py` where it subclasses `Trainer` and writes `step` from the primitives `draw`, `rollout` and `update`, giving the sequences their advantages in between; the core holds no algorithm of its own (see [`src/shipyard`](src/shipyard/README.md)).
86
+ - **Recipes:** GRPO, DAPO (also with its rollouts overlapping its updates), rejection-sampling fine-tuning, on-policy distillation and GEPA, in [`recipes/`](recipes/README.md).
87
+
88
+ The trainer updates on exactly what the agent sampled: `harness-proxy` serves the model to the harnesses, and records every call's token ids and logprobs.
89
+
90
+ ## Layout
91
+
92
+ ```
93
+ src/shipyard/ the Trainer API, with models/, jobs/ and run/
94
+ packages/harness-proxy/ serves the agent to its harnesses, and records every call
95
+ recipes/ the built-in recipes
96
+ ```
97
+
98
+ ## License
99
+
100
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,52 @@
1
+ # Shipyard
2
+
3
+ Post-training framework for AI agents on Harbor tasks.
4
+
5
+ ## Installation
6
+
7
+ Requires **Python 3.12+** and [uv](https://github.com/astral-sh/uv):
8
+
9
+ ```sh
10
+ uv tool install shipyard-rl
11
+ ```
12
+
13
+ ## Quickstart
14
+
15
+ The recipes train on [Tinker](https://thinkingmachines.ai/tinker/) and run their trials in [Modal](https://modal.com)'s sandboxes, whose calls reach the model through a Cloudflare tunnel this machine opens: install [`cloudflared`](https://github.com/cloudflare/cloudflared), or keep Docker running.
16
+
17
+ ```sh
18
+ shipyard init # copy the recipes and .env.example here
19
+ cp .env.example .env # then set TINKER_API_KEY in .env
20
+ uvx modal setup # log in to Modal, or set its keys in .env
21
+ uvx harbor@0.24.0 datasets download reasoning-gym-easy -o tasks # the recipes' tasks, in tasks/reasoning-gym-easy/
22
+ shipyard run recipes/dapo # the run writes runs/dapo__<id>/
23
+ ```
24
+
25
+ As shipped, the run takes about 1 h 45 min and costs about $20: $15 of Tinker and $5 of Modal, measured in November 2026. Add `--recipe.steps 1` to stop after the first step, about 10 minutes and under $2.
26
+
27
+ > [!IMPORTANT]
28
+ > Add `--dry` to see every setting the run would use, with each default `run.toml` leaves marked, and to check the run without starting it.
29
+
30
+ > [!TIP]
31
+ > For anything longer than a smoke test, start the run on a cloud VM rather than a laptop, for example in US East, and inside `tmux` so it outlives your SSH session. Every model call passes through the proxy on the machine that started the run, and that machine uploads each update's training data, so a laptop's distance, uplink and sleep slow or stall the whole run.
32
+
33
+ ## Customizing
34
+
35
+
36
+ - **Settings:** a recipe's settings can be updated in its `run.toml` (model, harnesses, data, learning rate, LoRA rank, ...); you can overwrite them using `--table.key VALUE` on `shipyard run`.
37
+ - **Algorithm:** a recipe defines a `trainer.py` where it subclasses `Trainer` and writes `step` from the primitives `draw`, `rollout` and `update`, giving the sequences their advantages in between; the core holds no algorithm of its own (see [`src/shipyard`](src/shipyard/README.md)).
38
+ - **Recipes:** GRPO, DAPO (also with its rollouts overlapping its updates), rejection-sampling fine-tuning, on-policy distillation and GEPA, in [`recipes/`](recipes/README.md).
39
+
40
+ The trainer updates on exactly what the agent sampled: `harness-proxy` serves the model to the harnesses, and records every call's token ids and logprobs.
41
+
42
+ ## Layout
43
+
44
+ ```
45
+ src/shipyard/ the Trainer API, with models/, jobs/ and run/
46
+ packages/harness-proxy/ serves the agent to its harnesses, and records every call
47
+ recipes/ the built-in recipes
48
+ ```
49
+
50
+ ## License
51
+
52
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,110 @@
1
+ [project]
2
+ name = "shipyard-rl"
3
+ version = "0.1.0"
4
+ description = "Post-training on Harbor jobs: a config sets up a run, and a run is its record."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Davide Ghilardi" }]
9
+ keywords = [
10
+ "post-training",
11
+ "reinforcement-learning",
12
+ "llm",
13
+ "agents",
14
+ "harbor",
15
+ "tinker",
16
+ "dapo",
17
+ "grpo",
18
+ "cispo",
19
+ "gepa",
20
+ ]
21
+ # The license is the SPDX expression above: PEP 639 retires the `License ::` classifiers
22
+ # once `license` is an expression, and an index may refuse a file carrying both.
23
+ classifiers = [
24
+ "Development Status :: 3 - Alpha",
25
+ "Intended Audience :: Developers",
26
+ "Intended Audience :: Science/Research",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3 :: Only",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
32
+ "Typing :: Typed",
33
+ ]
34
+ requires-python = ">=3.12"
35
+ dependencies = [
36
+ "pydantic>=2.9",
37
+ "typer>=0.16",
38
+ "rich>=14.1",
39
+ "shortuuid>=1.0.13",
40
+ "python-dotenv>=1.0",
41
+ # harbor[modal]: the recipes run their trials in Modal's sandboxes.
42
+ "harbor[modal]>=0.23,<0.25",
43
+ # tinker: below 0.39, the first minor no run has used, since a minor can change its API.
44
+ "tinker>=0.38,<0.39",
45
+ # tinker-cookbook: 0.6 is the first to tokenize Inkling 2 Small with its own tokenizer.
46
+ "tinker-cookbook>=0.6,<0.7",
47
+ # harness-proxy: the release this one was built and tested with, since the records
48
+ # the two exchange carry no version.
49
+ "harness-proxy==0.1.0",
50
+ "litellm>=1.103",
51
+ "tomli-w>=1.0",
52
+ ]
53
+
54
+ [project.urls]
55
+ Repository = "https://github.com/ghidav/shipyard"
56
+ Issues = "https://github.com/ghidav/shipyard/issues"
57
+
58
+ [project.scripts]
59
+ shipyard = "shipyard.cli:app"
60
+
61
+ [project.optional-dependencies]
62
+ dev = ["pytest>=8.3", "pytest-asyncio>=0.24", "ruff>=0.8"]
63
+ # The reference in docs/: `uv run --extra docs mkdocs serve`, or `uvx zensical serve -f mkdocs.yml`.
64
+ docs = ["mkdocs>=1.6", "mkdocs-material>=9.5"]
65
+ wandb = ["wandb>=0.21"]
66
+ # Together: a model on its post-training, `provider = "together"` in its `[models.<role>]`,
67
+ # and trials in its sandboxes, `[rollout] sandbox = "together"`.
68
+ # dockerfile-parse: Harbor reads a task's WORKDIR with it, and lists it only under its own sandboxes.
69
+ together = ["harness-proxy[together]==0.1.0", "together-sandbox>=4.1,<5", "dockerfile-parse>=2.0.1"]
70
+ gepa = [
71
+ "gepa>=0.1.4",
72
+ ]
73
+
74
+ [build-system]
75
+ requires = ["hatchling"]
76
+ build-backend = "hatchling.build"
77
+
78
+ [tool.hatch.build.targets.wheel]
79
+ packages = ["src/shipyard"]
80
+
81
+ # What `shipyard init` copies into the directory it runs in.
82
+ [tool.hatch.build.targets.wheel.force-include]
83
+ "recipes" = "shipyard/recipes"
84
+ ".env.example" = "shipyard/env.example"
85
+
86
+ [tool.hatch.build.targets.sdist]
87
+ only-include = ["src", "tests", "recipes", ".env.example", "README.md", "LICENSE", "pyproject.toml"]
88
+
89
+ [tool.uv.workspace]
90
+ members = ["packages/harness-proxy"]
91
+
92
+ [tool.uv.sources]
93
+ harness-proxy = { workspace = true }
94
+
95
+ [tool.pytest.ini_options]
96
+ testpaths = ["tests", "packages/harness-proxy/tests"]
97
+ # The proxy's fakes (`proxies`) live with its tests; shipyard's tests import them too.
98
+ pythonpath = ["src", "packages/harness-proxy/src", "packages/harness-proxy/tests"]
99
+ asyncio_mode = "auto"
100
+
101
+ [tool.ruff]
102
+ line-length = 100
103
+ src = ["src", "tests", "packages/harness-proxy/src", "packages/harness-proxy/tests"]
104
+
105
+ [tool.ruff.lint]
106
+ select = ["E", "F", "I", "UP", "B"]
107
+
108
+ [tool.ruff.lint.per-file-ignores]
109
+ # It runs in a trial's sandbox, on whatever Python is there, 3.8 or later: no newer syntax.
110
+ "src/shipyard/jobs/runner.py" = ["UP"]
@@ -0,0 +1,50 @@
1
+ # Recipes
2
+
3
+ Each folder is a recipe: a `run.toml` with every setting, and a `trainer.py` whose `Trainer` subclass holds the algorithm. `shipyard init` copies them into `./recipes`.
4
+
5
+ | Recipe | Algorithm | Models | Loss |
6
+ | --- | --- | --- | --- |
7
+ | [`grpo`](grpo/) | GRPO: each reward less its group's mean, groups of equal rewards skipped | `agent`, trained | `importance_sampling` |
8
+ | [`dapo`](dapo/) | DAPO: an overlong penalty, rewards normalized in the group, every prompt weighing the same, dynamic sampling | `agent`, trained | `ppo`, clipped asymmetrically |
9
+ | [`dapo-async`](dapo-async/) | `dapo`'s algorithm with its rollouts overlapping its updates: workers keep groups rolling out, and each step takes them in the order they finished | `agent`, trained | `ppo`, clipped asymmetrically |
10
+ | [`rft-async`](rft-async/) | Rejection-sampling fine-tuning, its sampling overlapping its updates: the agent learns the correct rollouts, a teacher's or its own, every kept token weighing the same | `agent`, trained; `teacher` (optional) | `cross_entropy` |
11
+ | [`opd`](opd/) | On-policy distillation: each token's advantage is the teacher's logprob minus the agent's | `agent`, trained; `teacher` | `importance_sampling` |
12
+ | [`gepa`](gepa/) | GEPA: a search over the prompt and skills, with no weight update; needs `shipyard-rl[gepa]` | `agent`; `reflector` | none |
13
+
14
+ Each folder's `README.md` says what its recipe needs. A recipe is its `run.toml` and its `trainer.py` together: the core holds no algorithm of its own.
15
+
16
+ ## Writing one
17
+
18
+ Subclass `Trainer` and write `step` from [the primitives](../src/shipyard/README.md), and `evaluate` if the config has a test set. Read the models the config names in `__init__`, and mark the ones the recipe trains. Declare the recipe's own keys as a `Recipe`, such as the harness it runs and its group size, and what a resume must restore as a `State`:
19
+
20
+ ```python
21
+ class MyTrainer(Trainer):
22
+ class Recipe(Trainer.Recipe):
23
+ harness: Harness # no default, so run.toml must set it
24
+ group_size: int
25
+ coef: float
26
+
27
+ def __init__(self, config: Config, directory: Path) -> None:
28
+ super().__init__(config, directory)
29
+ self.agent = self.models["agent"] # [models.agent]
30
+ self.agent.training = True
31
+
32
+ async def step(self) -> None:
33
+ groups = await self.rollout(
34
+ self.draw(),
35
+ model=self.agent,
36
+ harness=self.recipe.harness,
37
+ attempts=self.recipe.group_size,
38
+ modules=self.state.modules,
39
+ )
40
+ ... # give the sequences their advantages
41
+ await self.update(self.agent, groups)
42
+ ```
43
+
44
+ A recipe that wants several harnesses or renderers runs several rollouts, at once with `asyncio.gather`, and puts their groups together as it means them.
45
+
46
+ ```bash
47
+ shipyard run recipes/opd # the folder: its run.toml and trainer.py
48
+ shipyard run my.toml recipes/dapo/trainer.py --root runs # or both, named
49
+ shipyard resume runs/opd__a1b2c3d --tag step-100 # a new run from that checkpoint
50
+ ```
@@ -0,0 +1,18 @@
1
+ # DAPO (`dapo`)
2
+
3
+ DAPO ([Yu et al., 2025](https://arxiv.org/abs/2503.14476)): each trial's reward, less a soft penalty near the end of its token budget, is normalized within its group; the loss is `ppo`, clipped asymmetrically and averaged per prompt; and a step keeps drawing batches until a batch's worth of groups have something to teach.
4
+
5
+ | | |
6
+ | --- | --- |
7
+ | **Agent** | `[models.agent]`: `Qwen/Qwen3.5-9B` on Tinker, trained; through `pi`, `[recipe] harness` |
8
+ | **Data** | `reasoning-gym-easy`: 10 steps of 8 tasks, 8 trials each, in a substep for each task kept |
9
+ | **Sandbox** | Modal (set `[rollout] sandbox = "docker"` to run trials on this machine) |
10
+ | **Needs** | `TINKER_API_KEY`; a Modal login for the sandboxes (`uvx modal setup`), and `cloudflared` or a running Docker for the tunnel that carries their calls to this machine |
11
+ | **`[recipe]`** | `harness`, `group_size`, `clip_low`, `clip_high`, `overlong_penalty`, `overlong_buffer`; `overlong_budget` (optional: unset, the model's context) |
12
+
13
+ ```sh
14
+ uvx harbor@0.24.0 datasets download reasoning-gym-easy -o tasks
15
+ shipyard run recipes/dapo
16
+ ```
17
+
18
+ `run.toml` holds every setting; `trainer.py` holds the algorithm, step by step.
@@ -0,0 +1,32 @@
1
+ # DAPO on Reasoning Gym's easy split: 10 steps of 8 tasks, 8 trials each, a short run to raise
2
+ # `steps` from. Run it with trainer.py.
3
+ [models.agent]
4
+ model = "Qwen/Qwen3.5-9B"
5
+ learning_rate = 2e-5
6
+ lora_rank = 32
7
+ max_tokens = 8192
8
+
9
+ [data]
10
+ train = "reasoning-gym-easy"
11
+ batch_size = 8
12
+
13
+ [rollout]
14
+ sandbox = "modal"
15
+ concurrency = 32
16
+ setup_timeout = 900
17
+
18
+ [recipe]
19
+ steps = 10
20
+ harness = "pi@0.85.1"
21
+ group_size = 8
22
+ # The paper's 16 mini-batches a step, at most one for each group a step keeps, and its
23
+ # clip-higher: 0.2 below 1, 0.28 above.
24
+ substeps = 16
25
+ clip_low = 0.2
26
+ clip_high = 0.28
27
+ # Eq. 13's -1 on Harbor's 0 to 1 scale, over the last fifth of the token budget.
28
+ overlong_penalty = 0.5
29
+ overlong_buffer = 0.2
30
+
31
+ [checkpoints]
32
+ every = 10