epochmatic 0.1.0a3__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.

Potentially problematic release.


This version of epochmatic might be problematic. Click here for more details.

Files changed (51) hide show
  1. epochmatic-0.1.0a3/.gitignore +23 -0
  2. epochmatic-0.1.0a3/CONTRIBUTING.md +9 -0
  3. epochmatic-0.1.0a3/LICENSE +202 -0
  4. epochmatic-0.1.0a3/PKG-INFO +241 -0
  5. epochmatic-0.1.0a3/README.md +193 -0
  6. epochmatic-0.1.0a3/SECURITY.md +11 -0
  7. epochmatic-0.1.0a3/TESTING.md +170 -0
  8. epochmatic-0.1.0a3/bootstrap.py +77 -0
  9. epochmatic-0.1.0a3/deploy/epochmatic.service +15 -0
  10. epochmatic-0.1.0a3/examples/counter.py +19 -0
  11. epochmatic-0.1.0a3/examples/train_torch.py +28 -0
  12. epochmatic-0.1.0a3/install.py +50 -0
  13. epochmatic-0.1.0a3/pyproject.toml +45 -0
  14. epochmatic-0.1.0a3/scripts/check_install.py +19 -0
  15. epochmatic-0.1.0a3/scripts/check_mcp.py +25 -0
  16. epochmatic-0.1.0a3/scripts/test_release_install.py +37 -0
  17. epochmatic-0.1.0a3/src/epochmatic/__init__.py +3 -0
  18. epochmatic-0.1.0a3/src/epochmatic/__main__.py +3 -0
  19. epochmatic-0.1.0a3/src/epochmatic/cli.py +288 -0
  20. epochmatic-0.1.0a3/src/epochmatic/config.py +66 -0
  21. epochmatic-0.1.0a3/src/epochmatic/db.py +122 -0
  22. epochmatic-0.1.0a3/src/epochmatic/estimate.py +41 -0
  23. epochmatic-0.1.0a3/src/epochmatic/hf.py +67 -0
  24. epochmatic-0.1.0a3/src/epochmatic/intake.py +121 -0
  25. epochmatic-0.1.0a3/src/epochmatic/mcp_server.py +194 -0
  26. epochmatic-0.1.0a3/src/epochmatic/notebook.py +29 -0
  27. epochmatic-0.1.0a3/src/epochmatic/payload.py +53 -0
  28. epochmatic-0.1.0a3/src/epochmatic/planner.py +190 -0
  29. epochmatic-0.1.0a3/src/epochmatic/prompts.py +85 -0
  30. epochmatic-0.1.0a3/src/epochmatic/providers.py +401 -0
  31. epochmatic-0.1.0a3/src/epochmatic/quota.py +125 -0
  32. epochmatic-0.1.0a3/src/epochmatic/remote.py +73 -0
  33. epochmatic-0.1.0a3/src/epochmatic/scheduling.py +80 -0
  34. epochmatic-0.1.0a3/src/epochmatic/sdk.py +184 -0
  35. epochmatic-0.1.0a3/src/epochmatic/service.py +402 -0
  36. epochmatic-0.1.0a3/src/epochmatic/setup.py +280 -0
  37. epochmatic-0.1.0a3/src/epochmatic/storage.py +78 -0
  38. epochmatic-0.1.0a3/src/epochmatic/ui.py +75 -0
  39. epochmatic-0.1.0a3/src/epochmatic/util.py +67 -0
  40. epochmatic-0.1.0a3/src/epochmatic/worker.py +144 -0
  41. epochmatic-0.1.0a3/tests/conftest.py +12 -0
  42. epochmatic-0.1.0a3/tests/test_bootstrap.py +20 -0
  43. epochmatic-0.1.0a3/tests/test_cli_mcp.py +74 -0
  44. epochmatic-0.1.0a3/tests/test_core.py +243 -0
  45. epochmatic-0.1.0a3/tests/test_notebook.py +39 -0
  46. epochmatic-0.1.0a3/tests/test_payload.py +44 -0
  47. epochmatic-0.1.0a3/tests/test_prompts.py +48 -0
  48. epochmatic-0.1.0a3/tests/test_providers.py +120 -0
  49. epochmatic-0.1.0a3/tests/test_scheduling.py +133 -0
  50. epochmatic-0.1.0a3/tests/test_setup_storage.py +130 -0
  51. epochmatic-0.1.0a3/tests/test_worker.py +33 -0
@@ -0,0 +1,23 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ *.egg-info/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ build/
9
+ .epochmatic/
10
+ *.log
11
+ .env
12
+ .env.*
13
+ credentials*.json
14
+ token*.json
15
+ kaggle.json
16
+ .modal.toml
17
+ *.sqlite3
18
+ *.sqlite3-*
19
+ *.db
20
+ rclone.conf
21
+ epochmatic-agent/
22
+ epochmatic-mcp/
23
+ install-smoke/
@@ -0,0 +1,9 @@
1
+ # Contributing
2
+
3
+ Use Python 3.11+ and install `python -m pip install -e '.[dev,mcp,notebook]'` in a virtual environment. Run `ruff check src tests`, `python -m pytest`, and `python -m build` before submitting a change.
4
+
5
+ Core tests use isolated state directories and do not need cloud accounts. Cloud tests should use explicit opt-in and disposable private resources. Never run account-consuming tests in ordinary CI. Document the installed provider CLI/SDK version and the actual account behavior when validating an adapter.
6
+
7
+ Preserve these invariants: no duplicate launch after an ambiguous response; no lost reservation before confirmed worker termination; no checkpoint pointer published before its manifest/files are valid; no claim that Colab has a fixed free daily allowance; no credentials in staged bundles or logs generated by the controller.
8
+
9
+ Changes to agent tools must keep CLI and MCP behavior consistent. New providers need quota/capability semantics, bounded execution, cancellation/reconciliation behavior, checkpoint collection, and tests of uncertain launch outcomes.
@@ -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,241 @@
1
+ Metadata-Version: 2.5
2
+ Name: epochmatic
3
+ Version: 0.1.0a3
4
+ Summary: A persistent, agent-friendly controller for resumable training across GPU providers.
5
+ Project-URL: Homepage, https://github.com/patel-uday/epochmatic
6
+ Project-URL: Repository, https://github.com/patel-uday/epochmatic
7
+ Project-URL: Issues, https://github.com/patel-uday/epochmatic/issues
8
+ Project-URL: Documentation, https://github.com/patel-uday/epochmatic#readme
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: filelock<4,>=3
18
+ Requires-Dist: platformdirs<5,>=4
19
+ Requires-Dist: psutil<8,>=6
20
+ Requires-Dist: questionary<3,>=2
21
+ Requires-Dist: rich<15,>=13
22
+ Requires-Dist: typer<1,>=0.15
23
+ Provides-Extra: all
24
+ Requires-Dist: ipykernel<8,>=6; extra == 'all'
25
+ Requires-Dist: kaggle<3,>=2.2; extra == 'all'
26
+ Requires-Dist: mcp<2,>=1.10; extra == 'all'
27
+ Requires-Dist: modal<2,>=1.6; extra == 'all'
28
+ Requires-Dist: nbclient<1,>=0.10; extra == 'all'
29
+ Requires-Dist: nbformat<6,>=5; extra == 'all'
30
+ Requires-Dist: six<2,>=1.16; extra == 'all'
31
+ Provides-Extra: cloud
32
+ Requires-Dist: kaggle<3,>=2.2; extra == 'cloud'
33
+ Requires-Dist: modal<2,>=1.6; extra == 'cloud'
34
+ Requires-Dist: six<2,>=1.16; extra == 'cloud'
35
+ Provides-Extra: colab
36
+ Requires-Dist: google-colab-cli<1,>=0.8; (sys_platform != 'win32' and python_version >= '3.12') and extra == 'colab'
37
+ Provides-Extra: dev
38
+ Requires-Dist: build<2,>=1; extra == 'dev'
39
+ Requires-Dist: pytest<10,>=8; extra == 'dev'
40
+ Requires-Dist: ruff<1,>=0.9; extra == 'dev'
41
+ Provides-Extra: mcp
42
+ Requires-Dist: mcp<2,>=1.10; extra == 'mcp'
43
+ Provides-Extra: notebook
44
+ Requires-Dist: ipykernel<8,>=6; extra == 'notebook'
45
+ Requires-Dist: nbclient<1,>=0.10; extra == 'notebook'
46
+ Requires-Dist: nbformat<6,>=5; extra == 'notebook'
47
+ Description-Content-Type: text/markdown
48
+
49
+ # Epochmatic
50
+
51
+ A self-hosted CLI and MCP server for resumable Python/notebook training on a persistent computer or VPS.
52
+
53
+ Alpha software. Local execution/recovery and simulated provider chains are covered by automated tests. A real Kaggle CUDA smoke job completed and its model was collected. An operator-assisted Kaggle T4 → local RTX 2050 notebook checkpoint/resume also passed. Fully automatic live cloud-to-cloud handoffs and Modal execution still need validation; the official Colab CLI adapter is experimental. No hosted service, guaranteed free capacity, or published PyPI package is implied by this checkout.
54
+
55
+ For tested behavior, known limitations, and reporting results, see [TESTING.md](https://github.com/patel-uday/epochmatic/blob/main/TESTING.md).
56
+
57
+ ## Install and set up
58
+
59
+ With Python 3.11+ already installed, download the pinned alpha into an isolated environment and open the setup wizard in one command (Windows):
60
+
61
+ ```powershell
62
+ python -c "import urllib.request;exec(urllib.request.urlopen('https://raw.githubusercontent.com/patel-uday/epochmatic/v0.1.0a3/bootstrap.py').read())"
63
+ ```
64
+
65
+ Linux/macOS:
66
+
67
+ ```bash
68
+ python3 -c "import urllib.request;exec(urllib.request.urlopen('https://raw.githubusercontent.com/patel-uday/epochmatic/v0.1.0a3/bootstrap.py').read())"
69
+ ```
70
+
71
+ This executes the published bootstrap code. You can instead download and inspect [bootstrap.py](https://github.com/patel-uday/epochmatic/blob/v0.1.0a3/bootstrap.py) before running it. The bootstrap downloads the version-pinned GitHub release wheel, verifies its SHA-256 against the release checksum file, installs dependencies, and opens setup. It does not require Git or PyPI publishing credentials. A checksum from the same release detects corruption; it is not an independent publisher signature. Python 3.12+ is needed for the optional Colab integration.
72
+
73
+ Alternatively, download the source archive, enter its directory, and run:
74
+
75
+ ```bash
76
+ python3 install.py
77
+ ```
78
+
79
+ On Windows use `python install.py`. The installer creates a user-level virtual environment, installs the package and cloud/notebook/MCP dependencies, creates a launcher, then opens onboarding. It uses no sudo. Python 3.11+ and internet access are required; use Python 3.12+ on Linux/macOS for all three cloud integrations. Add the printed launcher directory to PATH if needed. `--prefix PATH --no-setup` supports an isolated installation.
80
+
81
+ The wizard prints the wordmark and offers a keyboard-driven provider checklist: use arrows to move, Space to select, and Enter to continue. Storage uses a selection menu too. Basic/redirected consoles get numbered options instead. Unsupported Colab configurations are disabled. A failed provider can be retried or skipped while other setup continues; completed steps are saved. Official provider logins still use each provider's own authentication interface.
82
+
83
+ Choose local storage or Google Drive backup through [rclone](https://rclone.org/drive/). The installer can add an official rclone binary into its user-owned environment after checking its published SHA-256 digest. On a headless VPS follow rclone's remote authorization flow. This avoids embedding a developer's OAuth credentials or copying a private Google login into the project.
84
+
85
+ **Storage and compute are independent. Drive backup still allows local CPU execution.** Local storage needs no Google account. Drive backup copies committed checkpoints/results from the controller; it is not a remote worker filesystem and cannot recover an upload that never reached the controller.
86
+
87
+ For development:
88
+
89
+ ```bash
90
+ python -m venv .venv
91
+ # activate .venv using your shell
92
+ python -m pip install -e '.[all,dev]'
93
+ epochmatic init
94
+ ```
95
+
96
+ ## Try a real local recovery run without cloud accounts
97
+
98
+ ```bash
99
+ epochmatic run examples/counter.py --provider local --gpu cpu --segment-seconds 2
100
+ epochmatic status --watch
101
+ ```
102
+
103
+ The example checkpoints at safe points, resumes through bounded segments, and writes `result.txt` with the sum 1 through 80. This is a recovery demonstration, not a GPU benchmark. `epochmatic fetch JOB_ID ./results` copies collected results into a new directory.
104
+
105
+ ## Bring your training
106
+
107
+ ```bash
108
+ epochmatic inspect train.py
109
+ epochmatic plan train.py --provider auto --gpu auto
110
+ epochmatic run train.py --include model.py --include data_config.json
111
+ epochmatic run train.ipynb --provider kaggle --gpu T4
112
+ epochmatic run train.py --provider modal --gpu T4
113
+ epochmatic run train.py --provider local --gpu cpu
114
+ epochmatic quota
115
+ epochmatic status JOB_ID --json
116
+ epochmatic logs JOB_ID
117
+ epochmatic pause JOB_ID
118
+ epochmatic resume JOB_ID
119
+ epochmatic cancel JOB_ID
120
+ ```
121
+
122
+ Use repeated `--arg VALUE` to forward script arguments (for options beginning with a dash, use `--arg=--epochs --arg=10`). Only the entrypoint, sibling `requirements.txt`, and explicitly included supporting files are staged. Notebook outputs are stripped before upload. Credential filenames and common hard-coded secret assignments are rejected; detection is not a substitute for reviewing your inputs. Training code executes with your worker's permissions, so only submit trusted code.
123
+
124
+ Notebook inputs run in a fresh kernel. They must declare dependencies and use an explicit checkpoint integration; arbitrary hidden notebook state cannot migrate. Missing local datasets must be included explicitly or obtained by the job from its own authorized dataset source. Provider-specific dataset mounting/secret setup is currently manual.
125
+
126
+ ### PyTorch checkpoint integration
127
+
128
+ See [examples/train_torch.py](examples/train_torch.py). `Session.save_torch` stores model, optimizer, optional scheduler/scaler, Python/NumPy/PyTorch random state, and caller-supplied extra state. Use extra state for sampler position and other application-specific state. Support is single-GPU; changing GPU count requires explicit adaptation. Resume is not a bitwise reproducibility guarantee across hardware.
129
+
130
+ ```python
131
+ from epochmatic.sdk import Session
132
+ session = Session()
133
+ step, extra = session.restore_torch(model, optimizer)
134
+ # Inside your optimizer-step loop:
135
+ session.report(step, total_steps, loss=float(loss))
136
+ if checkpoint_due or session.should_stop:
137
+ session.save_torch(step, model, optimizer, extra={"sampler": sampler_state})
138
+ if session.should_stop:
139
+ break
140
+ ```
141
+
142
+ Checkpoints publish a manifest and checksums before updating the latest pointer. The controller adopts only matching code identities and refuses backward progress. A weights file without optimizer/application state is not a complete training checkpoint.
143
+
144
+ ### Hugging Face Trainer
145
+
146
+ Before calling `trainer.train()`:
147
+
148
+ ```python
149
+ from epochmatic.hf import integrate
150
+ integrate()
151
+ trainer.train()
152
+ ```
153
+
154
+ This opt-in integration sets a managed output directory, attaches progress and checkpoint callbacks, and supplies the last verified Trainer checkpoint on resume. It disables external Trainer reporting. Keep a normal save strategy enabled. Validate the integration with a short stop/resume before a long run. This adapter has not been tested against a real GPU Trainer workload in this checkout.
155
+
156
+ `--non-resumable` explicitly permits a one-segment process without automatic recovery. There is no transparent arbitrary-Python snapshotting.
157
+
158
+ ## Planning and estimates
159
+
160
+ The controller selects feasible free allocations in Kaggle → Colab → Modal → local GPU preference order, honoring explicit overrides, configured managed slots, atomic reservations, safe segment deadlines, and compatibility. An automatic GPU job waits when GPUs are unavailable; CPU execution requires an explicit local/CPU choice. Independent jobs can run in parallel within separate slots. It replans at boundaries; it does not interrupt a healthy job merely because a quota reset occurred.
161
+
162
+ The initial scheduler is deliberately conservative, not a globally optimal solver. It does not yet rank devices using learned throughput, run a separate automatic benchmark, or promise a complete multi-day schedule. Initial estimates say measuring. Representative SDK steps then provide a smoothed remaining-compute forecast and conditional local finish time. Startup timing is excluded. GPU/segment changes reset calibration. Unmeasured evaluation, transfer, and queues remain explicitly outside that forecast. No LLM or paid AI API is needed.
163
+
164
+ ## Quotas and free-only limits
165
+
166
+ - **Kaggle:** official `kaggle quota --csv` weekly GPU hours and provider reset time. Slots and session limits are account-dependent. Reservations include a safety margin. A graceful bounded stop is important: abrupt provider termination can lose outputs not yet downloaded. Kaggle code and bundle datasets are private. Current cancellation may require Versions → Cancel in the provider UI; the tool never silently deletes notebooks. Segment datasets/notebooks remain until you explicitly remove them.
167
+ - **Colab:** free remaining capacity and reset are unknown. Show an unknown bar and observed usage from this controller over the last 24h, never a fabricated daily allowance. The official CLI is Linux/macOS only. Enable it only for an eligible account under current rules. Allocation refusal/uncertain launch stops retries and retains the reservation. No anti-idle tricks, SSH bypass, or multi-account quota evasion.
168
+ - **Modal:** reported monthly workspace metered cost against your configured included allowance. Setup asks you to verify a **$0 out-of-pocket provider spend limit** before launch. Conservative hourly upper bounds include GPU, CPU, memory, and setup/collection margin. Reservations are retained conservatively in the monthly ledger, so short runs may leave some credit unused. Billing may lag and other workspace jobs count. The software alone is not a zero-charge guarantee. Sandbox CPU/memory pricing differs from Functions; review current rates. Only explicitly configured GPU bounds are eligible.
169
+ - **Local:** your CPU/GPU is not metered by Epochmatic; hosting/electricity can still cost.
170
+
171
+ Provider changes may require adapter updates. Links: [Kaggle CLI](https://github.com/Kaggle/kaggle-cli), [Colab FAQ](https://research.google.com/colaboratory/faq.html), [Colab CLI](https://github.com/googlecolab/google-colab-cli), [Modal billing controls](https://modal.com/docs/guide/budgets), [Modal pricing](https://modal.com/pricing).
172
+
173
+ ## Connect an AI assistant
174
+
175
+ For an installed local Claude Code or Codex CLI, register MCP with one command on the controller host:
176
+
177
+ ```bash
178
+ epochmatic connect claude
179
+ # or: epochmatic connect codex
180
+ ```
181
+
182
+ This invokes the client's public MCP registration command and preserves the selected Epochmatic state directory. Reload the client and accept its tool permissions. Registration adapters are contract-tested with mocked CLIs; a live client session still needs an installation-specific check. For other stdio MCP clients, export configuration:
183
+
184
+ ```bash
185
+ epochmatic mcp-config ./epochmatic-mcp
186
+ ```
187
+
188
+ Import the generated `mcp.json` into a client supporting local stdio MCP. No skill installation is required: tool descriptions and argument schemas describe the operations. The Python executable path is generated from your installation. Exporting files does not edit client settings; `connect` registers the named server through the selected client's CLI. Ask: "Use Epochmatic to inspect and train this notebook using my free allocations."
189
+
190
+ Claude Code and Codex are registration shortcuts, not an exclusive client list. Other MCP applications, including T3 configurations that support stdio servers, can import the generated configuration or launch `epochmatic mcp`. For a remote controller, a client can launch that command through its own authenticated SSH connection. A portal accepting only an HTTPS URL cannot connect directly: this alpha has no hosted or authenticated HTTP MCP endpoint.
191
+
192
+ Tools: inspect_training, plan_training, plan_trainings, get_quota, start_training, start_trainings, get_status, list_jobs, pause_training, resume_training, cancel_training. Long-running work belongs to the controller; MCP returns job IDs. A queued job is not reported as already training. Client permissions still apply. Browser-hosted clients may need an authenticated remote bridge; this release does not expose an unauthenticated web endpoint or automatically connect every chat product.
193
+
194
+ ## Parallel jobs, checkpoint chains and scheduling
195
+
196
+ Independent jobs can run concurrently on the same or different enabled providers, subject to configured slots and shared quota reservations. Kaggle defaults to two managed slots; accounts may have additional provider-side restrictions. This is independent training, not distributed multi-GPU training of one model.
197
+
198
+ For a supported resumable script or notebook, explicitly cycle through providers at segment boundaries:
199
+
200
+ ```bash
201
+ epochmatic plan train.py --chain kaggle,modal --estimated-hours 20
202
+ epochmatic run train.py --chain kaggle,modal --segment-seconds 36000
203
+ ```
204
+
205
+ The first segment uses Kaggle, the next eligible segment uses Modal, then Kaggle again until complete. Unavailable members are skipped; if none are eligible the job waits and rechecks. Verified advancing checkpoints are copied to the next provider and the worker must acknowledge restoration. Handoffs happen after termination/collection, never by running the same model on two providers simultaneously. `--provider` pins a job to one provider and cannot be combined with `--chain`. Without a chain, automatic jobs replan at each boundary. Colab remains conditional on official CLI eligibility; its free capacity/reset are unknown, so no fixed daily allowance is promised.
206
+
207
+ For MCP, call `plan_trainings` then, when authorized, `start_trainings` with a `jobs` array. Example tool arguments for two Kaggle notebooks and one Modal notebook:
208
+
209
+ ```json
210
+ {"jobs": [
211
+ {"path": "/work/a.ipynb", "provider": "kaggle", "estimated_seconds": 36000},
212
+ {"path": "/work/b.ipynb", "provider": "kaggle", "estimated_seconds": 36000},
213
+ {"path": "/work/c.ipynb", "provider": "modal", "estimated_seconds": 36000}
214
+ ]}
215
+ ```
216
+
217
+ Each request accepts `gpu`, supporting `includes`, script `args`, `segment_seconds`, and an optional `chain` such as `["kaggle", "modal"]`. Mix in `{"path":"/work/d.py","provider":"local","gpu":"cpu"}` for CPU execution, or a separately configured Colab job. Source files must be on the controller host and integrate SDK/HF checkpointing. A batch is limited to 32 jobs; all inputs stage before any member is queued. Each job returns its own ID. Insufficient slots or allocation cause waiting, not a paid fallback.
218
+
219
+ The scheduler uses math, without an AI model. Supply `estimated_seconds` (or CLI `--estimated-hours`) for a full-job estimate, or MCP `provider_estimates`, e.g. `{"kaggle":7200,"modal":3600}` for different measured/expected speeds. It enumerates provider routes using available compute budgets and 600 seconds of assumed overhead per segment, choosing the lowest predicted completion time **among those routes**. If no route can finish, it labels the plan partial. Per-provider estimates override equal-speed fallback estimates. Short estimates reduce reservations with a 20% + 30-second runtime margin; underestimated jobs checkpoint and replan. Measured step rates update remaining-work estimates at subsequent boundaries.
220
+
221
+ Explicit chains take precedence over completion optimization. Without estimates, the fallback is conservative free-first. Batch planning greedily admits jobs in request order and shares reservations; it is not a globally optimal multi-job scheduler. No future quota reset, unknown Colab capacity, queue time or arbitrary notebook runtime is invented. The model is conditional on compatible code/data/dependencies and stable measured speeds.
222
+
223
+ ## Keep the VPS controller running
224
+
225
+ `run` starts a detached controller automatically. For reboot recovery on Linux use the supplied systemd user-service template in `deploy/epochmatic.service`; replace the executable path, then install it under `~/.config/systemd/user/` and enable it with `systemctl --user enable --now epochmatic`. A user service may need administrator-enabled lingering to run after logout. No system service is installed automatically. A file lock prevents two controllers from scheduling the same state directory.
226
+
227
+ State defaults to the OS user-data directory; override with `EPOCHMATIC_HOME`. Do not point two machines at the same SQLite database. Checkpoints/results remain local even when Drive backup is selected. Keep that directory private; raw training logs may contain data printed by your code. Credentials remain in official provider/rclone stores and are never bundled into remote workers.
228
+
229
+ After a controller restart, persisted remote handles are reconciled. Ambiguous launches retain reservations rather than duplicating work. `epochmatic reconcile JOB --handle-file handle.json` attaches a recovered handle. `--ended` is an operator assertion: use it only after verifying the remote session ended. Cloud workers enforce deadlines even if the controller is offline. Modal and Colab adapters attempt periodic committed-checkpoint downloads while running; Kaggle relies on graceful end-of-segment output retrieval. Modal has a bounded collection window; being offline through it can lose outputs.
230
+
231
+ ## Development and release status
232
+
233
+ ```bash
234
+ python -m pytest
235
+ ruff check src tests
236
+ python -m build
237
+ ```
238
+
239
+ CI runs local recovery/security/scheduling tests on Linux and Windows. Ordinary tests do not consume cloud quota. Separate opt-in GPU smoke tests are recorded in TESTING.md. Before promoting additional cloud integrations, validate account-specific authentication, launch, forced-checkpoint resume, cancellation, quota-exhaustion, and cleanup behavior.
240
+
241
+ Apache-2.0. No personal watchdog scripts or third-party project source were copied into this implementation.