Metadata-Version: 2.5
Name: rampgate
Version: 0.2.0
Summary: Decides when memory-ramping jobs, such as GPU training, may start: serializes warm-ups, reserves observed peaks, learns from OOMs. Pure Python, zero dependencies, with a deterministic simulator.
Project-URL: Homepage, https://github.com/KebanFiru/rampgate
Project-URL: Documentation, https://kebanfiru.github.io/rampgate/
Project-URL: Source, https://github.com/KebanFiru/rampgate
Project-URL: Changelog, https://github.com/KebanFiru/rampgate/blob/main/packages/rampgate/CHANGELOG.md
Project-URL: Issues, https://github.com/KebanFiru/rampgate/issues
Author: Hakan Bağıç
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: admission control,gpu,machine learning,oom,scheduler,simulator
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Distributed Computing
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# rampgate

> *ramp* + *gate*: hold each job's warm-up ramp at the gate, measure what it really uses, then reserve exactly that.

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:

- **Probation:** at most one warming job without a trusted estimate per device, so ramp-ups never race.
- **Observed-peak reservation:** reserve `observed_peak × safety_margin`, growing if the peak grows.
- **OOM feedback:** an OOM grows the estimate and requeues the job; with a runner that checkpoints, completed epochs are not lost.

It is not a cluster manager. You keep your executor (Docker, a process pool, a batch system), your control loop and your clock; rampgate tells you when to start and stop what, and explains why a job is waiting.

## Install

```sh
pip install rampgate
```

Python 3.11 or newer. The core imports only the standard library.

## Quickstart

Three jobs that ramp to 9 GB each on one 24 GB GPU, in rampgate's deterministic simulator:

```python
from rampgate import Device, FifoPolicy, Job, MarkStable, Resources, Start
from rampgate.sim import RampPlateau, Scenario, SimJob, simulate

gpu = Device("gpu0", Resources(vram=24))  # GB here; any unit works
ramp = RampPlateau(load_s=20, ramp_s=40, plateau=Resources(vram=9), duration_s=300)
jobs = tuple(SimJob(Job(f"train-{i}", {"gpu0": None}), ramp, submit_at=0) for i in range(3))

trace = simulate(Scenario((gpu,), jobs), FifoPolicy(), max_time=3000)
for tick in trace.ticks:
    for action in tick.decision.actions:
        if isinstance(action, Start | MarkStable):
            print(f"t={tick.now:5.0f}  {type(action).__name__:10} {action.job_id}")
print("OOM kills:", trace.world.oom_count, " finished at t =", trace.ticks[-1].now)
```

The jobs ramp one at a time and are reserved at their observed peaks. The third has no history, so it starts in the room that is left, is OOM-killed once (a first-contact OOM), and is requeued until it really fits (with a runner that checkpoints, completed epochs are not lost).

## On real machines

Drive the same `Engine` from your own loop: feed it observations, call `tick`, and apply the actions it returns. See [Integrating rampgate in your scheduler](https://kebanfiru.github.io/rampgate/integrating/). Adapters:

- [`rampgate-nvml`](https://pypi.org/project/rampgate-nvml/): NVIDIA GPU memory, per-process usage
- [`rampgate-psutil`](https://pypi.org/project/rampgate-psutil/): host RAM and CPU
- [`rampgate-docker`](https://pypi.org/project/rampgate-docker/): runs jobs as containers, classifies their exits

## Results and limits

In six simulated scenarios (freeze 2, held-out seeds 2000–2019), rampgate had no OOMs except a few first-contact ones (a median of 0–1 per run, all in cold runs) and finished in 0.12–0.75× the makespan of `Serial`, the other strategy that is OOM-free in every scenario. The price is makespan: warm rampgate took 1.07–1.59× as long as `GreedyFree` (per-seed medians), which OOMs hundreds of times per run in five of the six scenarios, and it missed its own ≤ 1.2× target (ratio of medians) in four of six. In the TrainQ-like scenario (e) no strategy OOMs, so rampgate's extra makespan (1.20× warm, 1.50× cold) buys nothing there; this scenario likely has too little memory pressure.

All benchmark results are from rampgate's deterministic simulator. Demonstrated (not benchmarked) on one laptop GPU (RTX 4050, 6 GB) with synthetic memory-hog containers: probation, a Rule V vacate and an OOM→Rule O cycle, checked by script. Not yet tested: multiple GPUs, gang jobs, CPU devices, a real framework's caching allocator, orchestrator restart, sub-second spikes.

Status: alpha. The API may change while the version is 0.x. The first held-out evaluation failed its gates (6 OOMs); the second passed after the fixes listed in the [benchmark methodology](https://kebanfiru.github.io/rampgate/benchmark/#methodology).

## Links

[Documentation](https://kebanfiru.github.io/rampgate/) · [Source](https://github.com/KebanFiru/rampgate) · [Changelog](https://github.com/KebanFiru/rampgate/blob/main/packages/rampgate/CHANGELOG.md)

Apache-2.0.
