Struct Budget
#[non_exhaustive]pub struct Budget {
pub max_trials: Option<u64>,
pub max_fidelity_units: Option<u64>,
pub deadline_millis: Option<u64>,
}Expand description
What a study is allowed to spend.
Every field is optional; None means unbounded. Budgets are enforced at
ask time and exposed to objectives through
TrialCtx::budget, because an RL run
legitimately needs to know how many environment steps it may use (the
budget).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_trials: Option<u64>Maximum number of trials to create.
max_fidelity_units: Option<u64>Cooperative maximum total fidelity, in the study’s ResourceUnit,
summed over durable trial reports.
The gate is evaluated from a storage snapshot before new work starts. Already-running trials may therefore carry the durable total past this value when multiple handles execute concurrently. Use it as a stop signal, not as an atomic cross-process reservation.
The overshoot is bounded, not unknown. Admission stops the instant the
durable total reaches the limit, so everything above it is work that was
already in flight: with at most P trials in flight at once, across all
handles and each handle’s
parallelism workers, and a
per-trial charge of at most F units, the total can exceed the limit by
at most P * F. A handle running one trial at a time, alone, therefore
overshoots by at most the one trial that crossed the line.
A hard atomic reservation was considered and deliberately not built: it would need an owning cross-process protocol to reserve and settle units before every evaluation, and this budget stops a search rather than metering a paid resource, so the bound above is what the contract owes.
deadline_millis: Option<u64>Wall-clock deadline, in the study clock’s milliseconds. Compared
against a Clock; never read from the OS here.
Implementations§
§impl Budget
impl Budget
pub const fn new() -> Self
pub const fn new() -> Self
An unbounded budget.
pub const fn new_with_trials(max_trials: u64) -> Self
pub const fn new_with_trials(max_trials: u64) -> Self
A budget of max_trials trials.
pub const fn with_fidelity_units(self, units: u64) -> Self
pub const fn with_fidelity_units(self, units: u64) -> Self
Sets the cooperative fidelity budget.
This is an ask-time stop signal based on durable reports, not an atomic reservation. Concurrent in-flight trials can overshoot it.
pub const fn with_deadline_millis(self, millis: u64) -> Self
pub const fn with_deadline_millis(self, millis: u64) -> Self
Sets the deadline, in the study clock’s milliseconds.
pub const fn is_unbounded(&self) -> bool
pub const fn is_unbounded(&self) -> bool
true if nothing is limited.