Concepts¶
Resources¶
Resources is an immutable mapping from a dimension name to a non-negative number: Resources(vram=9, ram=32). A missing dimension is 0. rampgate does not know units: use GB, MiB or bytes, but use the same unit everywhere for a dimension. KiB, MiB and GiB are exported as byte constants for convenience.
Device¶
Device(id, capacity, labels={}, stable_min_usage=Resources(), alloc_granularity=Resources())
capacity: everything the device has, e.g. a GPU's total memory.labels: free-form. The history estimator useslabels["kind"]to group devices of the same kind.stable_min_usage: the Rule S usage floor (see Algorithm). A job that reports no steps is not considered stable on this device before its usage there has exceeded the floor. It is off by default.rampgate-nvmlsets 256 MiB; without that adapter, set it yourself.alloc_granularity:q_d, the device's allocation granularity (see Rule A). A job's usage on the device is its continuous demand rounded up to a multiple ofq_d(or carries a rounding excess belowq_dper allocator segment), so the charge of a trusted estimate addsq_donce. It is off (0) by default because rampgate does not know the device's units or the framework's allocator.rampgate-nvmlsets 20 MiB ofvram(alloc_granularity_mib; not yet validated on real hardware).
Job¶
Job(id, placement, group=None, position=0, priority=0, fingerprint=(), force=False, metadata={})
placement: device id → declared hint (Resources) orNone. The caller chooses the devices; rampgate only decides when. Several devices make a gang, which starts on all of them or none.fingerprint: keys from most to least specific (e.g.("resnet50-bs256", "resnet50")). The history estimator learns peaks per key.force: skip capacity checks (Rule A), not probation.
Lifecycle¶
stateDiagram-v2
[*] --> PENDING
PENDING --> STARTING: Start
STARTING --> WARMING: on_started
WARMING --> STABLE: Rule S
WARMING --> PENDING: OOM (requeued for retry)
STABLE --> PENDING: OOM, or Rule V vacate
STABLE --> SUCCEEDED: exit 0
WARMING --> FAILED: failure / retries exhausted
STARTING --> STOPPING: Stop
WARMING --> STOPPING: Stop
STABLE --> STOPPING: Stop
STOPPING --> PREEMPTED: exit
STOPPING --> CANCELLED: exit
PREEMPTED --> PENDING: resume
Each new run of a job is an attempt, numbered from 1. Events and actions carry the attempt, so stale events from an earlier attempt are recognized and ignored.
Events in, actions out¶
You feed the Engine events:
- Facts:
JobStarted,JobExited(kind),JobObserved(a job's usage on a device),DeviceObserved(a device's total usage). Apply a device sample withobserve_sample(see Integrating). - Commands:
submit,update,preempt,resume,cancel,pause,unpause,add_device,remove_device.
engine.tick(now) returns a Decision with actions for your executor:
Start,Stop.MarkStable,UpdateReservation,Requeue,Fail,GroupCompleted.Warn/WarnCleared.
Every action has a deterministic action_id, so applying it twice is detectable.
Explanations¶
decision.explanations says why each waiting job waits. Examples:
WaitingForWarmup(device, job): another job without a trusted estimate is ramping there.InsufficientResources(device, dim, need, available).BlockedByForeignUsage: memory used by processes rampgate does not manage.DeviceHeldFor(device, job): an earlier job in the queue, or an isolation retry, holds the device.WaitingForExclusiveDevice(device): a trusted job whose charge is capped on the device (E × m + q > C − F: it can only run alone there) waits for the other managed jobs to finish. Not a warning.WaitingForSibling(job): a job with the same template died before its peak was measured; this one waits until the measured peak reaches the estimator (jobis the sibling whose run will measure it).
Warnings¶
Edge-triggered warnings are raised once with Warn when their condition starts, and end with WarnCleared:
CapacityExceeded,Overcommitted,ForeignUsageHigh,HintExceeded,Unreconciled.NoUsageObserved: a job without steps reachedmax_warmup_swithout passing the usage floor.JobNotObserved: a running job is missing fromConfig.missing_samples_warnsamples in a row.
UncleanStop and QueueStopped are one-shot.