gatedtrain 0.3.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 (59) hide show
  1. gatedtrain-0.3.0/LICENSE +202 -0
  2. gatedtrain-0.3.0/MANIFEST.in +8 -0
  3. gatedtrain-0.3.0/NOTICE +4 -0
  4. gatedtrain-0.3.0/PKG-INFO +239 -0
  5. gatedtrain-0.3.0/README.md +206 -0
  6. gatedtrain-0.3.0/THIRD_PARTY_NOTICES.md +48 -0
  7. gatedtrain-0.3.0/pyproject.toml +63 -0
  8. gatedtrain-0.3.0/setup.cfg +4 -0
  9. gatedtrain-0.3.0/src/gatedtrain/__init__.py +16 -0
  10. gatedtrain-0.3.0/src/gatedtrain/__main__.py +7 -0
  11. gatedtrain-0.3.0/src/gatedtrain/backends/__init__.py +6 -0
  12. gatedtrain-0.3.0/src/gatedtrain/backends/nemo_evaluator.py +34 -0
  13. gatedtrain-0.3.0/src/gatedtrain/backends/nemo_rl.py +182 -0
  14. gatedtrain-0.3.0/src/gatedtrain/canonical.py +236 -0
  15. gatedtrain-0.3.0/src/gatedtrain/cli.py +370 -0
  16. gatedtrain-0.3.0/src/gatedtrain/constraints.py +811 -0
  17. gatedtrain-0.3.0/src/gatedtrain/errors.py +32 -0
  18. gatedtrain-0.3.0/src/gatedtrain/ext/__init__.py +29 -0
  19. gatedtrain-0.3.0/src/gatedtrain/ext/arm.py +360 -0
  20. gatedtrain-0.3.0/src/gatedtrain/ext/collect.py +815 -0
  21. gatedtrain-0.3.0/src/gatedtrain/ext/conformance.py +198 -0
  22. gatedtrain-0.3.0/src/gatedtrain/ext/executor.py +14 -0
  23. gatedtrain-0.3.0/src/gatedtrain/ext/fill.py +150 -0
  24. gatedtrain-0.3.0/src/gatedtrain/ext/from_nel.py +255 -0
  25. gatedtrain-0.3.0/src/gatedtrain/ext/launch.py +2057 -0
  26. gatedtrain-0.3.0/src/gatedtrain/ext/merge.py +182 -0
  27. gatedtrain-0.3.0/src/gatedtrain/ext/registry.py +179 -0
  28. gatedtrain-0.3.0/src/gatedtrain/ext/rowkit.py +55 -0
  29. gatedtrain-0.3.0/src/gatedtrain/ext/sdk.py +315 -0
  30. gatedtrain-0.3.0/src/gatedtrain/ext/smoke.py +162 -0
  31. gatedtrain-0.3.0/src/gatedtrain/families/__init__.py +5 -0
  32. gatedtrain-0.3.0/src/gatedtrain/families/diffusers_lora.py +312 -0
  33. gatedtrain-0.3.0/src/gatedtrain/families/flow_grpo.py +643 -0
  34. gatedtrain-0.3.0/src/gatedtrain/families/nemo_rl.py +35 -0
  35. gatedtrain-0.3.0/src/gatedtrain/gates.py +1002 -0
  36. gatedtrain-0.3.0/src/gatedtrain/impact.py +348 -0
  37. gatedtrain-0.3.0/src/gatedtrain/items.py +94 -0
  38. gatedtrain-0.3.0/src/gatedtrain/ledger.py +247 -0
  39. gatedtrain-0.3.0/src/gatedtrain/registration.py +1086 -0
  40. gatedtrain-0.3.0/src/gatedtrain/renamed.py +89 -0
  41. gatedtrain-0.3.0/src/gatedtrain/report.py +380 -0
  42. gatedtrain-0.3.0/src/gatedtrain/runner.py +561 -0
  43. gatedtrain-0.3.0/src/gatedtrain/spec.py +409 -0
  44. gatedtrain-0.3.0/src/gatedtrain/stubs/__init__.py +19 -0
  45. gatedtrain-0.3.0/src/gatedtrain/stubs/evaluator.py +88 -0
  46. gatedtrain-0.3.0/src/gatedtrain/stubs/model.py +120 -0
  47. gatedtrain-0.3.0/src/gatedtrain/stubs/task.py +85 -0
  48. gatedtrain-0.3.0/src/gatedtrain/stubs/trainer.py +203 -0
  49. gatedtrain-0.3.0/src/gatedtrain/testing/__init__.py +16 -0
  50. gatedtrain-0.3.0/src/gatedtrain/testing/ext.py +87 -0
  51. gatedtrain-0.3.0/src/gatedtrain/testing/support.py +108 -0
  52. gatedtrain-0.3.0/src/gatedtrain/testing/synthetic.py +463 -0
  53. gatedtrain-0.3.0/src/gatedtrain/tierb.py +1047 -0
  54. gatedtrain-0.3.0/src/gatedtrain.egg-info/PKG-INFO +239 -0
  55. gatedtrain-0.3.0/src/gatedtrain.egg-info/SOURCES.txt +57 -0
  56. gatedtrain-0.3.0/src/gatedtrain.egg-info/dependency_links.txt +1 -0
  57. gatedtrain-0.3.0/src/gatedtrain.egg-info/entry_points.txt +2 -0
  58. gatedtrain-0.3.0/src/gatedtrain.egg-info/requires.txt +8 -0
  59. gatedtrain-0.3.0/src/gatedtrain.egg-info/top_level.txt +1 -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,8 @@
1
+ # The source distribution holds the package, its metadata and the legal files. The test suite, demo data, fixtures,
2
+ # specifications and docs stay in the repository: the tests need the full checkout (fixtures, demo, design set).
3
+ include LICENSE NOTICE THIRD_PARTY_NOTICES.md README.md pyproject.toml
4
+ prune tests
5
+ prune demo
6
+ prune docs
7
+ prune containers
8
+ global-exclude __pycache__ *.py[cod] .DS_Store
@@ -0,0 +1,4 @@
1
+ gatedtrain
2
+ Copyright 2026 The gatedtrain Authors
3
+
4
+ This product includes third-party material listed in THIRD_PARTY_NOTICES.md.
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: gatedtrain
3
+ Version: 0.3.0
4
+ Summary: Composable post-training framework: launch, consumption ledger, paired gates and impact for external training runs (prototype).
5
+ Author: The gatedtrain Authors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/gatedtrain/gatedtrain
8
+ Project-URL: Source, https://github.com/gatedtrain/gatedtrain
9
+ Project-URL: Issues, https://github.com/gatedtrain/gatedtrain/issues
10
+ Keywords: post-training,reinforcement-learning,fine-tuning,evaluation,statistical-testing,reproducibility,provenance
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: <3.14,>=3.12
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: NOTICE
24
+ License-File: THIRD_PARTY_NOTICES.md
25
+ Requires-Dist: numpy>=2.5.4
26
+ Requires-Dist: scipy>=1.18.1
27
+ Requires-Dist: pyarrow>=26.0.1
28
+ Requires-Dist: duckdb>=2.0.0
29
+ Requires-Dist: pyyaml>=6.0.3
30
+ Provides-Extra: tier-a
31
+ Requires-Dist: torch>=2.15.0; extra == "tier-a"
32
+ Dynamic: license-file
33
+
34
+ # gatedtrain
35
+
36
+ gatedtrain records what went into a model training run and tests whether the resulting checkpoint meets a
37
+ pre-registered evaluation criterion. It works with external trainers and evaluators. You can query the records
38
+ to find which checkpoints may have consumed a training shard, for example after finding a problem in the dataset.
39
+
40
+ This is a prototype. Outputs carry the tags `prototype` and `unpromotable`.
41
+
42
+ ## Install and run the demo
43
+
44
+ From a checkout with Python 3.12 or 3.13, create a virtual environment and validate the demo spec.
45
+
46
+ ```sh
47
+ python -m venv .venv
48
+ . .venv/bin/activate
49
+ python -m pip install -e .
50
+ gatedtrain validate demo/spec.yaml
51
+ ```
52
+
53
+ To run the demo end to end, install the `tier-a` extra for PyTorch. The example trains a small model on two-digit
54
+ addition. Run these commands from the repository root with a fresh `demo/baseline` path.
55
+
56
+ ```sh
57
+ python -m pip install -e '.[tier-a]'
58
+ gatedtrain warmup demo/warmup.yaml --out demo/baseline
59
+ gatedtrain run demo/spec.yaml --runs-root demo/runs
60
+ gatedtrain impact demo/data/train/shard-00003.jsonl --runs-root demo/runs
61
+ ```
62
+
63
+ The `run` command prints its output directory and gate report. See the [CPU quickstart](docs/quickstart.md) for
64
+ the report fields and control runs, or the [Tier B runbook](docs/tier-b-runbook.md) for a GPU run with NeMo RL.
65
+
66
+ ## Commands
67
+
68
+ `gatedtrain` (or `python -m gatedtrain`) has these subcommands:
69
+
70
+ | Command | What it does |
71
+ |---|---|
72
+ | `validate`, `warmup`, `run` | Check the spec and registration, build a baseline, or run the CPU demo. |
73
+ | `export-gsm8k`, `verify-export`, `nel-config`, `merge-eval`, `tierb-collect` | Prepare data and evaluation for a NeMo RL run and collect its results. |
74
+ | `ext-launch` | Check an external run request, write the launch record and print the command for the operator. Use `--recheck` to verify the record before running it. |
75
+ | `ext-from-nel`, `ext-merge-eval`, `ext-arm-fill` | Build and verify the per-item results for each side of the evaluation. |
76
+ | `ext-collect` | Compare the candidate and baseline on the same evaluation items, then write the gate report, consumption ledger and checkpoint lineage. |
77
+ | `impact` | Look up a shard across recorded runs. Each answer reports its precision as `row`, `iteration` or `stage`. |
78
+
79
+ Gates support superiority, non-inferiority and equivalence. The registration fixes the margin, alpha, target
80
+ power and evaluation seeds before the run. The report includes the decision, achieved power and an
81
+ `underpowered` flag.
82
+
83
+ ## Adapter plugins
84
+
85
+ Each external training recipe has an adapter: a pure-Python class that reads the run's outputs (checkpoints,
86
+ consumption logs, evaluation records) without importing the training framework, plus registry rows that describe the
87
+ run (inputs, container paths, pins, evaluators). A recipe package registers them through the Python entry point group
88
+ `gatedtrain.adapters`:
89
+
90
+ ```toml
91
+ [project.entry-points."gatedtrain.adapters"]
92
+ my_adapter = "my_recipe.my_adapter_rows:PLUGIN"
93
+ ```
94
+
95
+ where `PLUGIN = {"adapters": {name: "module:Class"}, "trainer_rows": {name: row}, "evaluator_rows": {id: row}}`
96
+ (`gatedtrain.ext.registry`). Adapters use the helpers of `gatedtrain.ext.sdk` and `gatedtrain.ext.rowkit`.
97
+
98
+ **Conformance kit.** A recipe repository can run the conformance checks with its own tests, so that a plugin that
99
+ registers but would break `ext-launch`, `ext-arm-fill` or `ext-collect` fails before any GPU run:
100
+
101
+ ```python
102
+ import unittest
103
+ from gatedtrain.ext.conformance import AdapterConformance
104
+
105
+ class TestConformance(AdapterConformance, unittest.TestCase):
106
+ ADAPTER = "my_adapter"
107
+ ```
108
+
109
+ `gatedtrain.testing` provides the shared test helpers (canonical JSON and manifest hashes, CLI subprocess runs) and a
110
+ synthetic adapter, `gatedtrain.testing.synthetic`: a complete, small example of the adapter interface that
111
+ gatedtrain's own tests run on. It is registered only when a test asks for it (`install()` in process, or
112
+ `python -m gatedtrain.testing.synthetic <gatedtrain arguments>` for a CLI run), never by an installed distribution.
113
+
114
+ ## Recipe repositories
115
+
116
+ Each recipe ships its own adapter and runtime instructions.
117
+
118
+ | Task | Recipe |
119
+ |---|---|
120
+ | Math reasoning | [TRL GRPO on GSM8K](https://github.com/gatedtrain/gatedtrain-recipe-trl-grpo-gsm8k) |
121
+ | Drone control | [Stable-Baselines3 PPO](https://github.com/gatedtrain/gatedtrain-recipe-sb3-ppo-drone-hover) |
122
+ | Image generation | [DDPO with SD1.5](https://github.com/gatedtrain/gatedtrain-recipe-ddpo-sd15) |
123
+ | Image generation for OCR | [Flow-GRPO with SD3.5](https://github.com/gatedtrain/gatedtrain-recipe-flow-grpo-sd35-ocr) |
124
+ | Video generation | [Flow-GRPO with Wan](https://github.com/gatedtrain/gatedtrain-recipe-flow-grpo-wan-video) |
125
+ | Speech recognition | [Whisper SFT on AMI](https://github.com/gatedtrain/gatedtrain-recipe-whisper-sft-ami) |
126
+ | Text-to-speech | [CosyVoice DPO](https://github.com/gatedtrain/gatedtrain-recipe-cosyvoice-dpo-tts) |
127
+ | CAD | [NeMo RL for CAD](https://github.com/gatedtrain/gatedtrain-recipe-nemo-rl-cad) |
128
+ | Visual reasoning | [NeMo RL on CLEVR](https://github.com/gatedtrain/gatedtrain-recipe-nemo-rl-vlm-clevr) |
129
+ | Robot manipulation | [LeRobot SmolVLA on LIBERO](https://github.com/gatedtrain/gatedtrain-recipe-lerobot-smolvla-libero) |
130
+ | Agentic math | [NeMo RL for agentic math](https://github.com/gatedtrain/gatedtrain-recipe-nemo-rl-agentic-math) |
131
+
132
+ ## Configuration
133
+
134
+ gatedtrain has no built-in host path. The external-run commands read the host layout from a TOML host file,
135
+ `~/.config/gatedtrain/host.toml` or the file named by `GATEDTRAIN_HOST_CONFIG`:
136
+
137
+ ```toml
138
+ host_work = "/srv/gatedtrain/work" # holds bin/gpu-step.sh (the operator's GPU wrapper) and gpu-log.md
139
+ output_root = "/srv/gatedtrain/out" # launches write strictly under this directory
140
+ ```
141
+
142
+ `GATEDTRAIN_EXT_HOST_WORK`, `GATEDTRAIN_EXT_OUTPUT_ROOT` and `GATEDTRAIN_EXT_INPUT_ROOTS` override it. Fixed defaults in
143
+ `gatedtrain.ext.launch` that a host may need to know about:
144
+
145
+ - `DOCKER_CONTEXT = "gatedtrain"`: the printed sidecar commands use `docker --context gatedtrain`; create a Docker
146
+ context of that name for the daemon that runs gatedtrain's containers.
147
+ - `DAEMON_CONFIGS`: `/etc/docker-gatedtrain/daemon.json` (a second daemon dedicated to gatedtrain, where a host runs
148
+ one) and `/etc/docker/daemon.json`; only their `data-root` key is read, so that no engine data directory is ever
149
+ mounted.
150
+ - `SOCKET_PATHS` / `DOCKER_SOCKET_GLOBS`: daemon sockets, including `/run/docker-gatedtrain.sock`; a container never
151
+ runs in a socket's group.
152
+ - A host whose daemons keep their configuration or socket elsewhere lists them in the host file; they are refused
153
+ like the built-in ones and enter the launch record's `host_config_sha256`:
154
+
155
+ ```toml
156
+ extra_daemon_configs = ["/etc/docker-other/daemon.json"] # each one's data-root is never mounted
157
+ extra_daemon_sockets = ["/run/docker-other.sock"] # never mounted; a container never runs in its group
158
+ ```
159
+ - `GPU_CAP_H = 1000`: the GPU-hour budget ceiling passed to `gpu-step.sh` (`GATEDTRAIN_GPU_CAP_H`), high enough not to
160
+ limit runs; hours are still logged in `gpu-log.md` and every full run is preceded by a smoke.
161
+
162
+ `bin/gpu-step.sh` is not part of gatedtrain, and the reference host's script is not published: an operator writes
163
+ their own. `docs/gpu-step.md` gives the interface gatedtrain relies on: how the printed command invokes it, the
164
+ `WORK=` and `LOG=` lines that `ext-launch` and `ext-collect` check, the script's hash pin, and the formats of
165
+ `gpu-guard.log` and `gpu-log.md`.
166
+
167
+ ## Tests
168
+
169
+ From the repository root, with the package and its `tier-a` extra installed in `.venv` (the tests run the CLI with
170
+ the interpreter that runs the suite):
171
+
172
+ ```sh
173
+ .venv/bin/python -m unittest discover -s tests -t tests
174
+ ```
175
+
176
+ The full suite takes about 13 minutes on a CPU. Some tests read external sources and skip, naming the variable, when
177
+ it is unset:
178
+
179
+ | Variable | Contents |
180
+ |---|---|
181
+ | `GATEDTRAIN_DESIGN_DIR` | the design set `gatedtrain-design` |
182
+ | `GATEDTRAIN_NEMO_EVALUATOR_DIR` | a NeMo Evaluator clone at `ea35ba36756abd59de201f60af8a2feba014744d` |
183
+ | `GATEDTRAIN_NEMO_RL_DIR` | a NeMo RL clone at `4f39fd86289a2ffd5aaf5d202702f7fd7185c924` |
184
+ | `GATEDTRAIN_TEST_TIERB_ROOT` | the Tier B host work directory of a host that ran the Tier B run (`bin/gpu-step.sh`, `tierb/`, `runs/`), read only |
185
+ | `GATEDTRAIN_TEST_MM_ROOT` | the runtime and output root of a host that ran the multimodal recipes, read only (for the recipes' tests) |
186
+
187
+ `GATEDTRAIN_SKIP_SLOW=1` skips the slow end-to-end runs. The suite uses a synthetic adapter. See the
188
+ [test reference](tests/README.md) for coverage and fixture details.
189
+
190
+ ## Design references
191
+
192
+ This version implements revision 19 of [gatedtrain-design](https://github.com/gatedtrain/gatedtrain-design).
193
+ The local specifications cover the [CPU demo](MVP-SPEC.md), [Tier B helpers](TIER-B-SPEC.md) and
194
+ [external adapters](MULTIMODAL-SPEC.md). The [findings log](docs/findings.md) records design questions and
195
+ regression fixes.
196
+
197
+ ### Unpublished references
198
+
199
+ Some specifications and test notes cite development decisions, interim rules and review findings by number.
200
+ [Section 9 of the test reference](tests/README.md#9-design-gaps-found-while-writing-the-tests) lists G-1 through G-11.
201
+
202
+ Paths under `<mm-root>` refer to the host layout used for the recipe runs. The matching instructions are in
203
+ `runtime/README.md` in each [recipe repository](#recipe-repositories).
204
+
205
+ | Host directory | Request area | Recipe |
206
+ |---|---|---|
207
+ | `area1-trl` | 1 | TRL GRPO on GSM8K |
208
+ | `area2-drones` | 4 | Stable-Baselines3 PPO |
209
+ | `area3-sd15` | 2, row 2a | DDPO with SD1.5 |
210
+ | `area3-video` | 3 | Flow-GRPO with Wan |
211
+ | `area4-whisper` | 5 | Whisper SFT on AMI |
212
+ | `area5-sd35` | 2, row 2b | Flow-GRPO with SD3.5 |
213
+ | `area6-cad` | 6 | NeMo RL for CAD |
214
+ | `area7-vlm` | 7 | NeMo RL on CLEVR |
215
+ | `area8-vla` | 8 | LeRobot SmolVLA on LIBERO |
216
+ | `area10-agentic` | 10 | NeMo RL for agentic math |
217
+ | `area11-tts` | 11 | CosyVoice DPO |
218
+
219
+ ## Data and licenses
220
+
221
+ - GSM8K (`openai/gsm8k`, MIT, © 2021 OpenAI): downloaded by `export-gsm8k` at a pinned dataset commit. The fixtures
222
+ under `tests/fixtures/tierb/` are synthetic rows in GSM8K's shape; `tests/fixtures/r11/longrun/raw_samples.json`
223
+ quotes one GSM8K test question (see `THIRD_PARTY_NOTICES.md`).
224
+ - NeMo RL and NeMo Evaluator (Apache-2.0): used unchanged as external tools at the pinned commits above; the NeMo RL
225
+ container image is built from NeMo RL's own Dockerfile (`containers/nemo-rl-uid1000/README.md`). gatedtrain quotes
226
+ NeMo Evaluator's GSM8K prompt text so that training and evaluation prompts agree (see `THIRD_PARTY_NOTICES.md`).
227
+ - Qwen3-0.6B (Apache-2.0, Qwen team): the base model of the Tier B run; downloaded by the operator, not
228
+ redistributed (a few of its responses are quoted in `raw_samples.json`).
229
+ - Checkpoints: the external-run commands hash model files and read safetensors headers and JSON; they never unpickle
230
+ a checkpoint. The Tier A stand-in model loads its own checkpoint with `torch.load(..., weights_only=True)`; load
231
+ only checkpoints you produced.
232
+
233
+ ## License
234
+
235
+ gatedtrain is licensed under the Apache License, Version 2.0 (`LICENSE`). See `NOTICE` for the copyright notice and
236
+ `THIRD_PARTY_NOTICES.md` for the third-party material it includes.
237
+
238
+ Names of third-party projects and products are trademarks of their owners; gatedtrain is not affiliated with or
239
+ endorsed by them.
@@ -0,0 +1,206 @@
1
+ # gatedtrain
2
+
3
+ gatedtrain records what went into a model training run and tests whether the resulting checkpoint meets a
4
+ pre-registered evaluation criterion. It works with external trainers and evaluators. You can query the records
5
+ to find which checkpoints may have consumed a training shard, for example after finding a problem in the dataset.
6
+
7
+ This is a prototype. Outputs carry the tags `prototype` and `unpromotable`.
8
+
9
+ ## Install and run the demo
10
+
11
+ From a checkout with Python 3.12 or 3.13, create a virtual environment and validate the demo spec.
12
+
13
+ ```sh
14
+ python -m venv .venv
15
+ . .venv/bin/activate
16
+ python -m pip install -e .
17
+ gatedtrain validate demo/spec.yaml
18
+ ```
19
+
20
+ To run the demo end to end, install the `tier-a` extra for PyTorch. The example trains a small model on two-digit
21
+ addition. Run these commands from the repository root with a fresh `demo/baseline` path.
22
+
23
+ ```sh
24
+ python -m pip install -e '.[tier-a]'
25
+ gatedtrain warmup demo/warmup.yaml --out demo/baseline
26
+ gatedtrain run demo/spec.yaml --runs-root demo/runs
27
+ gatedtrain impact demo/data/train/shard-00003.jsonl --runs-root demo/runs
28
+ ```
29
+
30
+ The `run` command prints its output directory and gate report. See the [CPU quickstart](docs/quickstart.md) for
31
+ the report fields and control runs, or the [Tier B runbook](docs/tier-b-runbook.md) for a GPU run with NeMo RL.
32
+
33
+ ## Commands
34
+
35
+ `gatedtrain` (or `python -m gatedtrain`) has these subcommands:
36
+
37
+ | Command | What it does |
38
+ |---|---|
39
+ | `validate`, `warmup`, `run` | Check the spec and registration, build a baseline, or run the CPU demo. |
40
+ | `export-gsm8k`, `verify-export`, `nel-config`, `merge-eval`, `tierb-collect` | Prepare data and evaluation for a NeMo RL run and collect its results. |
41
+ | `ext-launch` | Check an external run request, write the launch record and print the command for the operator. Use `--recheck` to verify the record before running it. |
42
+ | `ext-from-nel`, `ext-merge-eval`, `ext-arm-fill` | Build and verify the per-item results for each side of the evaluation. |
43
+ | `ext-collect` | Compare the candidate and baseline on the same evaluation items, then write the gate report, consumption ledger and checkpoint lineage. |
44
+ | `impact` | Look up a shard across recorded runs. Each answer reports its precision as `row`, `iteration` or `stage`. |
45
+
46
+ Gates support superiority, non-inferiority and equivalence. The registration fixes the margin, alpha, target
47
+ power and evaluation seeds before the run. The report includes the decision, achieved power and an
48
+ `underpowered` flag.
49
+
50
+ ## Adapter plugins
51
+
52
+ Each external training recipe has an adapter: a pure-Python class that reads the run's outputs (checkpoints,
53
+ consumption logs, evaluation records) without importing the training framework, plus registry rows that describe the
54
+ run (inputs, container paths, pins, evaluators). A recipe package registers them through the Python entry point group
55
+ `gatedtrain.adapters`:
56
+
57
+ ```toml
58
+ [project.entry-points."gatedtrain.adapters"]
59
+ my_adapter = "my_recipe.my_adapter_rows:PLUGIN"
60
+ ```
61
+
62
+ where `PLUGIN = {"adapters": {name: "module:Class"}, "trainer_rows": {name: row}, "evaluator_rows": {id: row}}`
63
+ (`gatedtrain.ext.registry`). Adapters use the helpers of `gatedtrain.ext.sdk` and `gatedtrain.ext.rowkit`.
64
+
65
+ **Conformance kit.** A recipe repository can run the conformance checks with its own tests, so that a plugin that
66
+ registers but would break `ext-launch`, `ext-arm-fill` or `ext-collect` fails before any GPU run:
67
+
68
+ ```python
69
+ import unittest
70
+ from gatedtrain.ext.conformance import AdapterConformance
71
+
72
+ class TestConformance(AdapterConformance, unittest.TestCase):
73
+ ADAPTER = "my_adapter"
74
+ ```
75
+
76
+ `gatedtrain.testing` provides the shared test helpers (canonical JSON and manifest hashes, CLI subprocess runs) and a
77
+ synthetic adapter, `gatedtrain.testing.synthetic`: a complete, small example of the adapter interface that
78
+ gatedtrain's own tests run on. It is registered only when a test asks for it (`install()` in process, or
79
+ `python -m gatedtrain.testing.synthetic <gatedtrain arguments>` for a CLI run), never by an installed distribution.
80
+
81
+ ## Recipe repositories
82
+
83
+ Each recipe ships its own adapter and runtime instructions.
84
+
85
+ | Task | Recipe |
86
+ |---|---|
87
+ | Math reasoning | [TRL GRPO on GSM8K](https://github.com/gatedtrain/gatedtrain-recipe-trl-grpo-gsm8k) |
88
+ | Drone control | [Stable-Baselines3 PPO](https://github.com/gatedtrain/gatedtrain-recipe-sb3-ppo-drone-hover) |
89
+ | Image generation | [DDPO with SD1.5](https://github.com/gatedtrain/gatedtrain-recipe-ddpo-sd15) |
90
+ | Image generation for OCR | [Flow-GRPO with SD3.5](https://github.com/gatedtrain/gatedtrain-recipe-flow-grpo-sd35-ocr) |
91
+ | Video generation | [Flow-GRPO with Wan](https://github.com/gatedtrain/gatedtrain-recipe-flow-grpo-wan-video) |
92
+ | Speech recognition | [Whisper SFT on AMI](https://github.com/gatedtrain/gatedtrain-recipe-whisper-sft-ami) |
93
+ | Text-to-speech | [CosyVoice DPO](https://github.com/gatedtrain/gatedtrain-recipe-cosyvoice-dpo-tts) |
94
+ | CAD | [NeMo RL for CAD](https://github.com/gatedtrain/gatedtrain-recipe-nemo-rl-cad) |
95
+ | Visual reasoning | [NeMo RL on CLEVR](https://github.com/gatedtrain/gatedtrain-recipe-nemo-rl-vlm-clevr) |
96
+ | Robot manipulation | [LeRobot SmolVLA on LIBERO](https://github.com/gatedtrain/gatedtrain-recipe-lerobot-smolvla-libero) |
97
+ | Agentic math | [NeMo RL for agentic math](https://github.com/gatedtrain/gatedtrain-recipe-nemo-rl-agentic-math) |
98
+
99
+ ## Configuration
100
+
101
+ gatedtrain has no built-in host path. The external-run commands read the host layout from a TOML host file,
102
+ `~/.config/gatedtrain/host.toml` or the file named by `GATEDTRAIN_HOST_CONFIG`:
103
+
104
+ ```toml
105
+ host_work = "/srv/gatedtrain/work" # holds bin/gpu-step.sh (the operator's GPU wrapper) and gpu-log.md
106
+ output_root = "/srv/gatedtrain/out" # launches write strictly under this directory
107
+ ```
108
+
109
+ `GATEDTRAIN_EXT_HOST_WORK`, `GATEDTRAIN_EXT_OUTPUT_ROOT` and `GATEDTRAIN_EXT_INPUT_ROOTS` override it. Fixed defaults in
110
+ `gatedtrain.ext.launch` that a host may need to know about:
111
+
112
+ - `DOCKER_CONTEXT = "gatedtrain"`: the printed sidecar commands use `docker --context gatedtrain`; create a Docker
113
+ context of that name for the daemon that runs gatedtrain's containers.
114
+ - `DAEMON_CONFIGS`: `/etc/docker-gatedtrain/daemon.json` (a second daemon dedicated to gatedtrain, where a host runs
115
+ one) and `/etc/docker/daemon.json`; only their `data-root` key is read, so that no engine data directory is ever
116
+ mounted.
117
+ - `SOCKET_PATHS` / `DOCKER_SOCKET_GLOBS`: daemon sockets, including `/run/docker-gatedtrain.sock`; a container never
118
+ runs in a socket's group.
119
+ - A host whose daemons keep their configuration or socket elsewhere lists them in the host file; they are refused
120
+ like the built-in ones and enter the launch record's `host_config_sha256`:
121
+
122
+ ```toml
123
+ extra_daemon_configs = ["/etc/docker-other/daemon.json"] # each one's data-root is never mounted
124
+ extra_daemon_sockets = ["/run/docker-other.sock"] # never mounted; a container never runs in its group
125
+ ```
126
+ - `GPU_CAP_H = 1000`: the GPU-hour budget ceiling passed to `gpu-step.sh` (`GATEDTRAIN_GPU_CAP_H`), high enough not to
127
+ limit runs; hours are still logged in `gpu-log.md` and every full run is preceded by a smoke.
128
+
129
+ `bin/gpu-step.sh` is not part of gatedtrain, and the reference host's script is not published: an operator writes
130
+ their own. `docs/gpu-step.md` gives the interface gatedtrain relies on: how the printed command invokes it, the
131
+ `WORK=` and `LOG=` lines that `ext-launch` and `ext-collect` check, the script's hash pin, and the formats of
132
+ `gpu-guard.log` and `gpu-log.md`.
133
+
134
+ ## Tests
135
+
136
+ From the repository root, with the package and its `tier-a` extra installed in `.venv` (the tests run the CLI with
137
+ the interpreter that runs the suite):
138
+
139
+ ```sh
140
+ .venv/bin/python -m unittest discover -s tests -t tests
141
+ ```
142
+
143
+ The full suite takes about 13 minutes on a CPU. Some tests read external sources and skip, naming the variable, when
144
+ it is unset:
145
+
146
+ | Variable | Contents |
147
+ |---|---|
148
+ | `GATEDTRAIN_DESIGN_DIR` | the design set `gatedtrain-design` |
149
+ | `GATEDTRAIN_NEMO_EVALUATOR_DIR` | a NeMo Evaluator clone at `ea35ba36756abd59de201f60af8a2feba014744d` |
150
+ | `GATEDTRAIN_NEMO_RL_DIR` | a NeMo RL clone at `4f39fd86289a2ffd5aaf5d202702f7fd7185c924` |
151
+ | `GATEDTRAIN_TEST_TIERB_ROOT` | the Tier B host work directory of a host that ran the Tier B run (`bin/gpu-step.sh`, `tierb/`, `runs/`), read only |
152
+ | `GATEDTRAIN_TEST_MM_ROOT` | the runtime and output root of a host that ran the multimodal recipes, read only (for the recipes' tests) |
153
+
154
+ `GATEDTRAIN_SKIP_SLOW=1` skips the slow end-to-end runs. The suite uses a synthetic adapter. See the
155
+ [test reference](tests/README.md) for coverage and fixture details.
156
+
157
+ ## Design references
158
+
159
+ This version implements revision 19 of [gatedtrain-design](https://github.com/gatedtrain/gatedtrain-design).
160
+ The local specifications cover the [CPU demo](MVP-SPEC.md), [Tier B helpers](TIER-B-SPEC.md) and
161
+ [external adapters](MULTIMODAL-SPEC.md). The [findings log](docs/findings.md) records design questions and
162
+ regression fixes.
163
+
164
+ ### Unpublished references
165
+
166
+ Some specifications and test notes cite development decisions, interim rules and review findings by number.
167
+ [Section 9 of the test reference](tests/README.md#9-design-gaps-found-while-writing-the-tests) lists G-1 through G-11.
168
+
169
+ Paths under `<mm-root>` refer to the host layout used for the recipe runs. The matching instructions are in
170
+ `runtime/README.md` in each [recipe repository](#recipe-repositories).
171
+
172
+ | Host directory | Request area | Recipe |
173
+ |---|---|---|
174
+ | `area1-trl` | 1 | TRL GRPO on GSM8K |
175
+ | `area2-drones` | 4 | Stable-Baselines3 PPO |
176
+ | `area3-sd15` | 2, row 2a | DDPO with SD1.5 |
177
+ | `area3-video` | 3 | Flow-GRPO with Wan |
178
+ | `area4-whisper` | 5 | Whisper SFT on AMI |
179
+ | `area5-sd35` | 2, row 2b | Flow-GRPO with SD3.5 |
180
+ | `area6-cad` | 6 | NeMo RL for CAD |
181
+ | `area7-vlm` | 7 | NeMo RL on CLEVR |
182
+ | `area8-vla` | 8 | LeRobot SmolVLA on LIBERO |
183
+ | `area10-agentic` | 10 | NeMo RL for agentic math |
184
+ | `area11-tts` | 11 | CosyVoice DPO |
185
+
186
+ ## Data and licenses
187
+
188
+ - GSM8K (`openai/gsm8k`, MIT, © 2021 OpenAI): downloaded by `export-gsm8k` at a pinned dataset commit. The fixtures
189
+ under `tests/fixtures/tierb/` are synthetic rows in GSM8K's shape; `tests/fixtures/r11/longrun/raw_samples.json`
190
+ quotes one GSM8K test question (see `THIRD_PARTY_NOTICES.md`).
191
+ - NeMo RL and NeMo Evaluator (Apache-2.0): used unchanged as external tools at the pinned commits above; the NeMo RL
192
+ container image is built from NeMo RL's own Dockerfile (`containers/nemo-rl-uid1000/README.md`). gatedtrain quotes
193
+ NeMo Evaluator's GSM8K prompt text so that training and evaluation prompts agree (see `THIRD_PARTY_NOTICES.md`).
194
+ - Qwen3-0.6B (Apache-2.0, Qwen team): the base model of the Tier B run; downloaded by the operator, not
195
+ redistributed (a few of its responses are quoted in `raw_samples.json`).
196
+ - Checkpoints: the external-run commands hash model files and read safetensors headers and JSON; they never unpickle
197
+ a checkpoint. The Tier A stand-in model loads its own checkpoint with `torch.load(..., weights_only=True)`; load
198
+ only checkpoints you produced.
199
+
200
+ ## License
201
+
202
+ gatedtrain is licensed under the Apache License, Version 2.0 (`LICENSE`). See `NOTICE` for the copyright notice and
203
+ `THIRD_PARTY_NOTICES.md` for the third-party material it includes.
204
+
205
+ Names of third-party projects and products are trademarks of their owners; gatedtrain is not affiliated with or
206
+ endorsed by them.