class
SushiAI::Optim::LossScaleState
Host-side state machine tracking dynamic loss scale adjustments.
- Declared in
include/SushiAI/optim/loss_scaler.hpp
Public member functions
explicit LossScaleState(LossScaleOptions options={})Builds a state machine over options.
Parameters
optionsThe four constants; all must be powers of two.
Exceptions
ErrorIf a constant is not a power of two, if the bounds do not bracket the initial scale, if growth is below one or backoff is not in (0, 1].
void observe(bool overflow) noexceptFolds one step's verdict into the state.
Parameters
overflowWhether any gradient came back non-finite.
double scale() const noexceptThe scale the next step will run at.
double inverse_scale() const noexcept1 / scale, exactly.
Exact because the scale is a power of two, which is the property the whole design is arranged around: the unscale is a change of exponent and nothing else.
bool last_step_skipped() const noexceptWhether the step just observed was thrown away.
std::uint64_t consecutive_good_steps() const noexceptHow many clean steps have run since the last overflow or growth.
std::uint64_t skipped_steps() const noexceptHow many steps have been thrown away in total.
std::uint64_t backoffs() const noexceptHow many times the scale has halved.
std::uint64_t growths() const noexceptHow many times the scale has doubled.
const LossScaleOptions & options() const noexceptThe options in force.

