rampgate 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 (56) hide show
  1. rampgate-0.1.0/.gitignore +27 -0
  2. rampgate-0.1.0/CHANGELOG.md +54 -0
  3. rampgate-0.1.0/LICENSE +202 -0
  4. rampgate-0.1.0/NOTICE +4 -0
  5. rampgate-0.1.0/PKG-INFO +58 -0
  6. rampgate-0.1.0/README.md +31 -0
  7. rampgate-0.1.0/pyproject.toml +37 -0
  8. rampgate-0.1.0/src/rampgate/__init__.py +234 -0
  9. rampgate-0.1.0/src/rampgate/actions.py +316 -0
  10. rampgate-0.1.0/src/rampgate/config.py +101 -0
  11. rampgate-0.1.0/src/rampgate/decide.py +652 -0
  12. rampgate-0.1.0/src/rampgate/engine.py +322 -0
  13. rampgate-0.1.0/src/rampgate/estimators.py +406 -0
  14. rampgate-0.1.0/src/rampgate/events.py +190 -0
  15. rampgate-0.1.0/src/rampgate/explain.py +126 -0
  16. rampgate-0.1.0/src/rampgate/model.py +363 -0
  17. rampgate-0.1.0/src/rampgate/policies/__init__.py +16 -0
  18. rampgate-0.1.0/src/rampgate/policies/base.py +57 -0
  19. rampgate-0.1.0/src/rampgate/policies/fifo.py +22 -0
  20. rampgate-0.1.0/src/rampgate/policies/priority.py +34 -0
  21. rampgate-0.1.0/src/rampgate/policies/stage.py +132 -0
  22. rampgate-0.1.0/src/rampgate/py.typed +0 -0
  23. rampgate-0.1.0/src/rampgate/reducer.py +832 -0
  24. rampgate-0.1.0/src/rampgate/resources.py +192 -0
  25. rampgate-0.1.0/src/rampgate/serialization.py +225 -0
  26. rampgate-0.1.0/src/rampgate/sim/__init__.py +63 -0
  27. rampgate-0.1.0/src/rampgate/sim/baselines.py +187 -0
  28. rampgate-0.1.0/src/rampgate/sim/clock.py +21 -0
  29. rampgate-0.1.0/src/rampgate/sim/executor.py +303 -0
  30. rampgate-0.1.0/src/rampgate/sim/report.py +281 -0
  31. rampgate-0.1.0/src/rampgate/sim/scenario.py +297 -0
  32. rampgate-0.1.0/src/rampgate/sim/workloads.py +121 -0
  33. rampgate-0.1.0/src/rampgate/stability.py +77 -0
  34. rampgate-0.1.0/tests/conftest.py +17 -0
  35. rampgate-0.1.0/tests/rampgate_testkit.py +195 -0
  36. rampgate-0.1.0/tests/test_baselines.py +209 -0
  37. rampgate-0.1.0/tests/test_benchmark_smoke.py +87 -0
  38. rampgate-0.1.0/tests/test_decide.py +604 -0
  39. rampgate-0.1.0/tests/test_dedup.py +139 -0
  40. rampgate-0.1.0/tests/test_estimators.py +298 -0
  41. rampgate-0.1.0/tests/test_heldout_regressions.py +66 -0
  42. rampgate-0.1.0/tests/test_invariants.py +592 -0
  43. rampgate-0.1.0/tests/test_model.py +194 -0
  44. rampgate-0.1.0/tests/test_persistence.py +516 -0
  45. rampgate-0.1.0/tests/test_policies.py +116 -0
  46. rampgate-0.1.0/tests/test_reducer_properties.py +185 -0
  47. rampgate-0.1.0/tests/test_reducer_stopping.py +113 -0
  48. rampgate-0.1.0/tests/test_reducer_transitions.py +598 -0
  49. rampgate-0.1.0/tests/test_report.py +275 -0
  50. rampgate-0.1.0/tests/test_reservation.py +53 -0
  51. rampgate-0.1.0/tests/test_resources.py +238 -0
  52. rampgate-0.1.0/tests/test_rule_o.py +190 -0
  53. rampgate-0.1.0/tests/test_sampling_and_floor.py +316 -0
  54. rampgate-0.1.0/tests/test_sim.py +384 -0
  55. rampgate-0.1.0/tests/test_stability.py +116 -0
  56. rampgate-0.1.0/tests/test_vacate_isolation.py +210 -0
@@ -0,0 +1,27 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .coverage
8
+ coverage.xml
9
+ htmlcov/
10
+ .pytest_cache/
11
+ .mypy_cache/
12
+ .ruff_cache/
13
+ .hypothesis/
14
+
15
+ # real-hardware runs: hog checkpoints are scratch
16
+ docs/real-run/runs/*/ckpt/
17
+ site/
18
+
19
+ # local scratch: diagnostics, benchmark runs, worktrees
20
+ .diag/
21
+ .bench-*/
22
+
23
+ # private design document, kept outside the repository
24
+ SPEC.md
25
+
26
+ # real-hardware runs: the hogs' raw container logs stay private
27
+ docs/real-run/runs/*/hog-logs/
@@ -0,0 +1,54 @@
1
+ # Changelog — rampgate
2
+
3
+ ## Unreleased
4
+
5
+ ### Fixed
6
+ - An isolation hold on a device takes precedence over head-of-line holds there: under `FifoPolicy(strict=True)` or `PriorityPolicy`, a job queued ahead of an isolation retry and kept out by its hold no longer closes the device for the holder (a mutual hold that left both PENDING forever). Found by hypothesis in CI after held-out evaluation 2; the benchmark's policies were not affected. New liveness invariant I20.
7
+
8
+ ### Added
9
+ - `Engine.observe_sample(device_id, t, used_total, per_job)` and `JobSample`: one device sample applied atomically, the jobs' usage before the device total, so a growing job's growth is never counted as foreign (the L5 harness bug). `observe` documents the ordering requirement. A job absent from a sample keeps its last known usage (L6).
10
+ - `Config.missing_samples_warn` (default 5) and `Warn(JobNotObserved(job_id, attempt, device_id))`, edge-triggered, after that many consecutive device samples without the job (L6).
11
+ - Rule S usage floor: `Device.stable_min_usage` (default off). A job that never reported steps is not marked STABLE on a device before its usage there exceeded the floor; `max_warmup_s` does not override it, and `Warn(NoUsageObserved(job_id, attempt, device_id))` is raised at `max_warmup_s` instead. Crossing the floor starts the warm-up (`JobRuntime.floor_crossed_t`): `min_warmup_s`, the quiet window and `max_warmup_s` count from there, so a job that keeps growing after a long data-loading phase is STABLE at the crossing + `max_warmup_s` at the latest (L6).
12
+ - Simulator workloads take `reports_steps=False` (a process without a step counter).
13
+ - State schema v5: `Device.stable_min_usage`, `DeviceState.samples`, `JobRuntime.obs_sample` (migration from v4: floor off, no samples counted).
14
+ - State schema v6: `JobRuntime.floor_crossed_t` (migration from v5: unknown, so warm-up keeps counting from `warm_start`).
15
+ - Rule A: `Config.min_trusted_observations` (default 3). `trusted_margin` applies only when the level-0 key holds that many complete observations (`HistoryEntry.observation_count`, `EstimateResult.observations`, `Snapshot.observations`, `Start.observations`); with fewer, a trusted job counts with `safety_margin`. State schema v3 (migration from v2: no observations, i.e. `safety_margin`) (docs/algorithm.md).
16
+ - `Config.trusted_margin` (default 1.05): a trusted STARTING/WARMING job counts as `max(E × trusted_margin, usage)`; `safety_margin` (1.15) stays for reservations from one observation (docs/algorithm.md; changed after the first benchmark results).
17
+ - `Report.ooms_per_job`, `max_job_ooms`, `repeat_device_ooms`; `TimelineEntry.device` names the device of an OOM kill.
18
+ - `Report.first_contact_unknown` / `first_contact_hint`: first-contact means no observation-based estimate (no history record at any level, first attempt); a job admitted on its declared hint alone counts (the L4 gate clarification).
19
+ - `Warn(HintExceeded(job_id, attempt, device_id, hint, observed))`: edge-triggered, raised once per attempt when a running job's observed peak exceeds its declared hint, cleared when the attempt ends. Informational; admission ignores it (docs/concepts.md, I16).
20
+ - Simulator & benchmark (L4): `Report` (with first-contact OOMs), `run`, `quantile`/`summarize`, baselines `GreedyFree`, `DeclaredReservation`, `Serial` and the ablations as `Strategy` rows (`MAIN`, `ABLATIONS`, `WARM`), `Admission` / `PROBATION` / `measured_free`, `RejectedByAdmission`, executor ground truth (`WorldStats`: lost work, usage integrals, overcommit, timeline), `ckpt_save_s`, foreign-load schedules, `SimJob.after`. `Resources` arithmetic skips re-validation (about 3x faster simulations, identical results).
21
+ - Package skeleton (L0).
22
+ - `Resources`: immutable non-negative resource vector with `+`, `-` (raises on underflow, eps-snapping), `sub(clamp=True)`, `scale`, `max`, `min`, `fits_in`, `exceeds`, `is_zero`, JSON round-trip; `KiB`/`MiB`/`GiB`/`TiB` constants (L0).
23
+ - `Config` with every docs/algorithm.md threshold, plus `max_lost_retries` and `foreign_tolerance` (L1).
24
+ - Model: `Device`, `Job`, `JobState`, `ExitKind`, `StopReason`, and the immutable reducer `State` / `JobRuntime` / `DeviceState` (L1).
25
+ - Events (docs/concepts.md) including `JobExited.oom_dims` and an optional `JobObserved.attempt` (L1).
26
+ - Actions (docs/concepts.md) with deterministic `action_id`; `Start.admitted_free`, `UncleanStop`, `EXCEEDS_DEVICE_CAPACITY`, `LOST_RETRIES_EXHAUSTED` (L1).
27
+ - Pure `reduce(state, message, config)`: the full lifecycle, Rule S helpers (`is_stable`, `is_peak_growth`), steps baselining, monotone reservations, Rule O with `admitted_free`, LOST handling, the STOPPING exit table, stale/duplicate/out-of-order handling with `ignored_events`, the action outbox, and `drain` (L1).
28
+ - `decide(snapshot, now, config, policy) -> Decision`: Rules P and A (compared directly against capacity), gang all-or-nothing, per-device head-of-line blocking, start timeouts (`Start.issued_at`), `Stop` emission, `MarkStable`, warnings with dedup (`CapacityExceeded`, `Overcommitted`, `ForeignUsageHigh`, `QueueStopped`), `GroupCompleted`, and explanations for every waiting job (L2).
29
+ - Explanations: `WaitingForWarmup`, `InsufficientResources`, `GroupBarrier`, `EnginePaused`, `UnknownEstimateBlocked`, `GangPartiallyBlocked`, `DeviceHeldFor`, `AwaitingResume` (L2).
30
+ - Policies: `StagePolicy` (backfill, `STOP_QUEUE`), `FifoPolicy`, `PriorityPolicy` (aging, blocking), `BasePolicy` (L2).
31
+ - Estimators: `HistoryEstimator`, `InMemoryHistoryStore`, `NullEstimator`, `StaticEstimator`, `resolve_estimates`, `apply_history` (L2).
32
+ - Rule S epoch gate (`JobObserved.epoch`, `Config.stable_requires_epoch`); `JobSubmitted.t` for aging (L2).
33
+ - `rampgate.sim`: workloads (`RampPlateau`, `StepProfile`, `Spiky`, `EpochEval`), `SimExecutor` with the OOM model, `Scenario` and `simulate` (L2).
34
+
35
+ - `Engine` (L3): the docs/concepts.md API, `tick` with estimator I/O, `apply`, `unreconciled()`, versioned `dump`/`load` (L3).
36
+ - `dump_state` / `load_state`: lossless, allowlisted, versioned JSON for the whole state, with a migration table and `UnsupportedSchema` (L3).
37
+ - `InMemoryHistoryStore.to_json` / `from_json`; `simulate(..., restart_at=...)` runs through the Engine and can restart mid-run (L3).
38
+ - `Start.estimate`; `unknown_min_free` as a fraction of capacity (default 10 %); edge-triggered warnings with `WarnCleared`; `BlockedByForeignUsage` (L2 follow-up).
39
+
40
+ - `Engine.confirm`, `Config.reconcile_grace_s` and the edge-triggered `Warn(Unreconciled)`; `HistoryRecord.record_id` and idempotent `HistoryStore.put`; `simulate(restart_at=[...], downtime=[...])` (L3 follow-up).
41
+
42
+ ### Changed
43
+ - **Breaking (`HistoryStore` protocol):** `get` returns `HistoryEntry(complete, lower_bound)`; stores keep each record's `lower_bound` flag and an arrival order (bumped only when a put changes a record). A lower bound counts only if it is newer than the newest complete record of its key; if it exceeds the complete value, the estimate is untrusted. `LOWER_BOUND_SUFFIX` is gone. `InMemoryHistoryStore` JSON has a new format; the old one still loads (docs/estimators.md).
44
+ - An estimate is trusted only if its level-0 key has a complete observation (`peak` or `running` record); OOM/stop lower bounds alone give the same value, untrusted (`EstimateResult.complete`). `HistoryEstimator` stores lower bounds under `key + LOWER_BOUND_SUFFIX`; Rule H running records are written with `lower_bound=False` (docs/algorithm.md, docs/estimators.md; changed after the first benchmark results).
45
+ - Rule P applies only to jobs without a trusted estimate (`Config.probation = "untrusted_only"`, default; `"all"` keeps the old behavior). An estimate is trusted when the estimator answered from the most specific fingerprint level (`EstimateResult(value, level)`, level 0) and the job has not OOMed. A trusted warming job takes no probation slot and counts as `max(E × safety_margin, usage)`; an untrusted one as `max(E, usage)`. `Start.trusted`, `JobRuntime.trusted`; `Estimator.estimate` returns `EstimateResult`; `Snapshot.trusted`. A job marked STABLE keeps its probation slot until the next tick (`MarkStable.issued_at`, `JobRuntime.stable_at`), so a sibling sees its running history record first (L4).
46
+ - Rule H also writes a `running` history record (lower bound) when a job becomes STABLE, and rewrites it with the same `record_id` when its reservation grows. `HistoryStore.put` max-merges by `record_id` (idempotent and order-independent); `InMemoryHistoryStore` keeps the merged value per record and still reads the L3 JSON format (L4).
47
+ - Rule O uses the room the device had left at OOM time (`C − F − Σ neighbours' usage`, max over `foreign_window_s`) instead of `admitted_free`, both for the lower bound and for `Fail(EXCEEDS_DEVICE_CAPACITY)`. A STABLE job that spikes next to a later neighbour now retries with growth instead of failing. `JobRuntime.usage_samples` keeps the window; state schema v2, with a migration from v1 (L4).
48
+ - `Fail(EXCEEDS_DEVICE_CAPACITY)` is decided from evidence only: the job OOMed while it had effectively the whole device free (L3 follow-up).
49
+ - Only observations naming the current attempt reconcile a job after a load (L3 follow-up).
50
+ - Unknown-estimate jobs use Rule A's direct comparison against `unknown_min_free` and are refused on overcommitted devices (L2 follow-up).
51
+ - `CapacityExceeded`, `Overcommitted` and `ForeignUsageHigh` are edge-triggered; `ForeignUsageHigh` is keyed by device and lists the blocked jobs (L2 follow-up).
52
+ - `max_lost_retries` now counts retries, like `max_oom_retries` (fails on the 4th consecutive LOST by default) (L2).
53
+ - `DeviceRemoved` of an already removed device is ignored as a duplicate (L2).
54
+
rampgate-0.1.0/LICENSE ADDED
@@ -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.
rampgate-0.1.0/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ rampgate
2
+ Copyright 2026 The rampgate authors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.5
2
+ Name: rampgate
3
+ Version: 0.1.0
4
+ Summary: Observation-based admission scheduler: serialized warm-up, observed-peak reservations, OOM feedback. Pure Python, zero dependencies.
5
+ Project-URL: Homepage, https://github.com/KebanFiru/rampgate
6
+ Project-URL: Documentation, https://kebanfiru.github.io/rampgate/
7
+ Project-URL: Source, https://github.com/KebanFiru/rampgate
8
+ Project-URL: Changelog, https://github.com/KebanFiru/rampgate/blob/main/packages/rampgate/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/KebanFiru/rampgate/issues
10
+ Author: Hakan Bağıç
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Keywords: admission control,gpu,machine learning,oom,scheduler,simulator
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: System :: Distributed Computing
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Description-Content-Type: text/markdown
27
+
28
+ # rampgate
29
+
30
+ > *ramp* + *gate*: hold each job's warm-up ramp at the gate, measure what it really uses, then reserve exactly that.
31
+
32
+ rampgate is an **observation-based admission scheduler**: a small, embeddable, pure-Python library with **zero runtime dependencies**. It decides **when** a job may start on a device the caller chose:
33
+
34
+ - **Probation:** at most one warming job without a trusted estimate per device, so ramp-ups never race.
35
+ - **Observed-peak reservation:** reserve `observed_peak × safety_margin`, growing if the peak grows.
36
+ - **OOM feedback:** an OOM grows the estimate and re-queues the job to resume from its checkpoint.
37
+
38
+ ## Quickstart
39
+
40
+ ```python
41
+ from rampgate import Device, FifoPolicy, Job, MarkStable, Resources, Start
42
+ from rampgate.sim import RampPlateau, Scenario, SimJob, simulate
43
+
44
+ gpu = Device("gpu0", Resources(vram=24)) # GB here; any unit works
45
+ ramp = RampPlateau(load_s=20, ramp_s=40, plateau=Resources(vram=9), duration_s=300)
46
+ jobs = tuple(SimJob(Job(f"train-{i}", {"gpu0": None}), ramp, submit_at=0) for i in range(3))
47
+
48
+ trace = simulate(Scenario((gpu,), jobs), FifoPolicy(), max_time=3000)
49
+ for tick in trace.ticks:
50
+ for action in tick.decision.actions:
51
+ if isinstance(action, Start | MarkStable):
52
+ print(f"t={tick.now:5.0f} {type(action).__name__:10} {action.job_id}")
53
+ print("OOM kills:", trace.world.oom_count, " finished at t =", trace.ticks[-1].now)
54
+ ```
55
+
56
+ Adapters for real machines: [`rampgate-nvml`](https://pypi.org/project/rampgate-nvml/) (NVIDIA GPUs), [`rampgate-psutil`](https://pypi.org/project/rampgate-psutil/) (host RAM/CPU), [`rampgate-docker`](https://pypi.org/project/rampgate-docker/) (Docker executor).
57
+
58
+ Status: alpha. All benchmark results come from rampgate's deterministic simulator; a demonstration on one laptop GPU is described in the [repository](https://github.com/KebanFiru/rampgate), along with the benchmark, its methodology and the limits of what was tested.
@@ -0,0 +1,31 @@
1
+ # rampgate
2
+
3
+ > *ramp* + *gate*: hold each job's warm-up ramp at the gate, measure what it really uses, then reserve exactly that.
4
+
5
+ rampgate is an **observation-based admission scheduler**: a small, embeddable, pure-Python library with **zero runtime dependencies**. It decides **when** a job may start on a device the caller chose:
6
+
7
+ - **Probation:** at most one warming job without a trusted estimate per device, so ramp-ups never race.
8
+ - **Observed-peak reservation:** reserve `observed_peak × safety_margin`, growing if the peak grows.
9
+ - **OOM feedback:** an OOM grows the estimate and re-queues the job to resume from its checkpoint.
10
+
11
+ ## Quickstart
12
+
13
+ ```python
14
+ from rampgate import Device, FifoPolicy, Job, MarkStable, Resources, Start
15
+ from rampgate.sim import RampPlateau, Scenario, SimJob, simulate
16
+
17
+ gpu = Device("gpu0", Resources(vram=24)) # GB here; any unit works
18
+ ramp = RampPlateau(load_s=20, ramp_s=40, plateau=Resources(vram=9), duration_s=300)
19
+ jobs = tuple(SimJob(Job(f"train-{i}", {"gpu0": None}), ramp, submit_at=0) for i in range(3))
20
+
21
+ trace = simulate(Scenario((gpu,), jobs), FifoPolicy(), max_time=3000)
22
+ for tick in trace.ticks:
23
+ for action in tick.decision.actions:
24
+ if isinstance(action, Start | MarkStable):
25
+ print(f"t={tick.now:5.0f} {type(action).__name__:10} {action.job_id}")
26
+ print("OOM kills:", trace.world.oom_count, " finished at t =", trace.ticks[-1].now)
27
+ ```
28
+
29
+ Adapters for real machines: [`rampgate-nvml`](https://pypi.org/project/rampgate-nvml/) (NVIDIA GPUs), [`rampgate-psutil`](https://pypi.org/project/rampgate-psutil/) (host RAM/CPU), [`rampgate-docker`](https://pypi.org/project/rampgate-docker/) (Docker executor).
30
+
31
+ Status: alpha. All benchmark results come from rampgate's deterministic simulator; a demonstration on one laptop GPU is described in the [repository](https://github.com/KebanFiru/rampgate), along with the benchmark, its methodology and the limits of what was tested.
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "rampgate"
3
+ version = "0.1.0"
4
+ description = "Observation-based admission scheduler: serialized warm-up, observed-peak reservations, OOM feedback. Pure Python, zero dependencies."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE", "NOTICE"]
8
+ authors = [{ name = "Hakan Bağıç" }]
9
+ requires-python = ">=3.11"
10
+ dependencies = []
11
+ keywords = ["scheduler", "gpu", "admission control", "oom", "machine learning", "simulator"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "Intended Audience :: Science/Research",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: System :: Distributed Computing",
22
+ "Typing :: Typed",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/KebanFiru/rampgate"
27
+ Documentation = "https://kebanfiru.github.io/rampgate/"
28
+ Source = "https://github.com/KebanFiru/rampgate"
29
+ Changelog = "https://github.com/KebanFiru/rampgate/blob/main/packages/rampgate/CHANGELOG.md"
30
+ Issues = "https://github.com/KebanFiru/rampgate/issues"
31
+
32
+ [build-system]
33
+ requires = ["hatchling>=1.26"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/rampgate"]
@@ -0,0 +1,234 @@
1
+ """rampgate: observe-then-reserve admission scheduler."""
2
+
3
+ from rampgate.actions import (
4
+ Action,
5
+ CapacityExceeded,
6
+ Fail,
7
+ FailReason,
8
+ ForeignUsageHigh,
9
+ GroupCompleted,
10
+ GroupOutcome,
11
+ HintExceeded,
12
+ JobNotObserved,
13
+ MarkStable,
14
+ NoUsageObserved,
15
+ Overcommitted,
16
+ QueueStopped,
17
+ Requeue,
18
+ RequeueReason,
19
+ Start,
20
+ Stop,
21
+ UncleanStop,
22
+ Unreconciled,
23
+ UpdateReservation,
24
+ Warn,
25
+ WarnCleared,
26
+ WarningKind,
27
+ is_edge_triggered,
28
+ key_id,
29
+ warning_key,
30
+ )
31
+ from rampgate.config import Config
32
+ from rampgate.decide import (
33
+ PROBATION,
34
+ Admission,
35
+ Decision,
36
+ DeviceLoad,
37
+ ProbationAdmission,
38
+ decide,
39
+ device_loads,
40
+ measured_free,
41
+ )
42
+ from rampgate.engine import Engine, JobSample
43
+ from rampgate.estimators import (
44
+ EstimateResult,
45
+ Estimator,
46
+ HistoryEntry,
47
+ HistoryEstimator,
48
+ HistoryStore,
49
+ InMemoryHistoryStore,
50
+ NullEstimator,
51
+ StaticEstimator,
52
+ apply_history,
53
+ resolve_estimates,
54
+ )
55
+ from rampgate.events import (
56
+ UNSET,
57
+ CancelRequested,
58
+ DeviceAdded,
59
+ DeviceObserved,
60
+ DeviceRemoved,
61
+ Event,
62
+ JobExited,
63
+ JobObserved,
64
+ JobStarted,
65
+ JobSubmitted,
66
+ JobUpdated,
67
+ Paused,
68
+ PreemptRequested,
69
+ ResumeRequested,
70
+ Unpaused,
71
+ )
72
+ from rampgate.explain import (
73
+ AwaitingResume,
74
+ BlockedByForeignUsage,
75
+ DeviceHeldFor,
76
+ EnginePaused,
77
+ Explanation,
78
+ GangPartiallyBlocked,
79
+ GroupBarrier,
80
+ InsufficientResources,
81
+ RejectedByAdmission,
82
+ UnknownEstimateBlocked,
83
+ WaitingForIsolation,
84
+ WaitingForWarmup,
85
+ )
86
+ from rampgate.model import (
87
+ ACTIVE_STATES,
88
+ TERMINAL_STATES,
89
+ Device,
90
+ DeviceId,
91
+ DeviceState,
92
+ ExitKind,
93
+ GroupId,
94
+ HistoryRecord,
95
+ Job,
96
+ JobId,
97
+ JobRuntime,
98
+ JobState,
99
+ Snapshot,
100
+ State,
101
+ StopReason,
102
+ )
103
+ from rampgate.policies import (
104
+ BasePolicy,
105
+ FailurePolicy,
106
+ FifoPolicy,
107
+ OrderingPolicy,
108
+ PriorityPolicy,
109
+ StagePolicy,
110
+ StateView,
111
+ )
112
+ from rampgate.reducer import IgnoredEvent, IgnoreReason, InvalidTransition, Message, drain, reduce
113
+ from rampgate.resources import GiB, KiB, MiB, Number, Resources, TiB
114
+ from rampgate.serialization import UnsupportedSchema, dump_state, load_state
115
+ from rampgate.stability import is_peak_growth, is_stable
116
+
117
+ __version__ = "0.1.0"
118
+
119
+ __all__ = [
120
+ "ACTIVE_STATES",
121
+ "PROBATION",
122
+ "TERMINAL_STATES",
123
+ "UNSET",
124
+ "Action",
125
+ "Admission",
126
+ "AwaitingResume",
127
+ "BasePolicy",
128
+ "BlockedByForeignUsage",
129
+ "CancelRequested",
130
+ "CapacityExceeded",
131
+ "Config",
132
+ "Decision",
133
+ "Device",
134
+ "DeviceAdded",
135
+ "DeviceHeldFor",
136
+ "DeviceId",
137
+ "DeviceLoad",
138
+ "DeviceObserved",
139
+ "DeviceRemoved",
140
+ "DeviceState",
141
+ "Engine",
142
+ "EnginePaused",
143
+ "EstimateResult",
144
+ "Estimator",
145
+ "Event",
146
+ "ExitKind",
147
+ "Explanation",
148
+ "Fail",
149
+ "FailReason",
150
+ "FailurePolicy",
151
+ "FifoPolicy",
152
+ "ForeignUsageHigh",
153
+ "GangPartiallyBlocked",
154
+ "GiB",
155
+ "GroupBarrier",
156
+ "GroupCompleted",
157
+ "GroupId",
158
+ "GroupOutcome",
159
+ "HintExceeded",
160
+ "HistoryEntry",
161
+ "HistoryEstimator",
162
+ "HistoryRecord",
163
+ "HistoryStore",
164
+ "IgnoreReason",
165
+ "IgnoredEvent",
166
+ "InMemoryHistoryStore",
167
+ "InsufficientResources",
168
+ "InvalidTransition",
169
+ "Job",
170
+ "JobExited",
171
+ "JobId",
172
+ "JobNotObserved",
173
+ "JobObserved",
174
+ "JobRuntime",
175
+ "JobSample",
176
+ "JobStarted",
177
+ "JobState",
178
+ "JobSubmitted",
179
+ "JobUpdated",
180
+ "KiB",
181
+ "MarkStable",
182
+ "Message",
183
+ "MiB",
184
+ "NoUsageObserved",
185
+ "NullEstimator",
186
+ "Number",
187
+ "OrderingPolicy",
188
+ "Overcommitted",
189
+ "Paused",
190
+ "PreemptRequested",
191
+ "PriorityPolicy",
192
+ "ProbationAdmission",
193
+ "QueueStopped",
194
+ "RejectedByAdmission",
195
+ "Requeue",
196
+ "RequeueReason",
197
+ "Resources",
198
+ "ResumeRequested",
199
+ "Snapshot",
200
+ "StagePolicy",
201
+ "Start",
202
+ "State",
203
+ "StateView",
204
+ "StaticEstimator",
205
+ "Stop",
206
+ "StopReason",
207
+ "TiB",
208
+ "UncleanStop",
209
+ "UnknownEstimateBlocked",
210
+ "Unpaused",
211
+ "Unreconciled",
212
+ "UnsupportedSchema",
213
+ "UpdateReservation",
214
+ "WaitingForIsolation",
215
+ "WaitingForWarmup",
216
+ "Warn",
217
+ "WarnCleared",
218
+ "WarningKind",
219
+ "__version__",
220
+ "apply_history",
221
+ "decide",
222
+ "device_loads",
223
+ "drain",
224
+ "dump_state",
225
+ "is_edge_triggered",
226
+ "is_peak_growth",
227
+ "is_stable",
228
+ "key_id",
229
+ "load_state",
230
+ "measured_free",
231
+ "reduce",
232
+ "resolve_estimates",
233
+ "warning_key",
234
+ ]