module adabmDCA.training_control
Shared lifecycle primitives for DCA training routines.
The numerical algorithms live in adabmDCA.training. This module owns the algorithm-independent parts of a run: counters, limits, history, progress reporting, cancellation, and checkpoint scheduling.
Global Variables
- HISTORY_KEYS
class StopReason
Reason why a training strategy stopped.
class TrainingCancelled
Internal cancellation signal raised by the shared controller.
class TrainingLimits
Step budgets of a training run; None means no limit.
Attributes:
max_gradient_steps: Largest number of accepted parameter updates.max_structure_steps: Largest number of graph activations or decimations.
method __init__
__init__(
max_gradient_steps: 'int | None' = None,
max_structure_steps: 'int | None' = None
) → None
class TrainingCounters
Progress counters of a training run.
Attributes:
gradient_steps: Accepted parameter updates.structure_steps: Graph activations or decimations.sweeps: Monte Carlo sweeps performed, including diagnostics.stage: Current training phase.
method __init__
__init__(
gradient_steps: 'int' = 0,
structure_steps: 'int' = 0,
sweeps: 'int' = 0,
stage: 'str' = 'optimization'
) → None
class TrainingMetrics
Common metrics emitted after a meaningful training step.
method __init__
__init__(
pearson: 'Any',
slope: 'Any',
pearson_val: 'Any',
slope_val: 'Any',
density: 'Any',
elapsed_time: 'float',
ll_train: 'Any' = None,
ll_val: 'Any' = None,
entropy: 'Any' = None,
extra: 'dict[str, Any]' = <factory>
) → None
method as_record
as_record(epoch: 'int') → dict[str, Any]
class CheckpointStore
Persistence interface used by the training controller.
method check
check(updates: 'int') → bool
method log
log(record: 'dict[str, Any]') → None
method save
save(**snapshot: 'Any') → None
class StageProgress
Transient stage update; separate from committed metric records.
method __init__
__init__(
stage: 'str',
kind: 'str',
gradient_steps: 'int',
current: 'int | None' = None,
total: 'int | None' = None,
details: 'dict[str, Any]' = <factory>
) → None
class TrainingController
Coordinate one training run without owning its numerical updates.
method __init__
__init__(
limits: 'TrainingLimits | None' = None,
checkpoint: 'CheckpointStore | None' = None,
observer: 'RecordObserver | None' = None,
stage_observer: 'StageObserver | None' = None,
is_cancelled: 'CancellationHook | None' = None
) → None
method add_gradient_steps
add_gradient_steps(count: 'int', sweeps_per_step: 'int' = 0) → None
method add_structure_step
add_structure_step(sweeps: 'int' = 0) → None
method begin_stage
begin_stage(stage: 'str', **metadata: 'Any') → None
Publish a phase change without coupling algorithms to a renderer.
method check_cancellation
check_cancellation() → None
method finalize
finalize(snapshot: 'Mapping[str, Any] | None' = None) → None
Persist the final state once, without duplicating a history row.
method gradient_limit_reached
gradient_limit_reached() → bool
method history_changed
history_changed() → None
Propagate a retroactive history change (resume, rollback) to the saved history.
method record
record(
metrics: 'TrainingMetrics',
epoch: 'int',
snapshot: 'Mapping[str, Any] | None' = None
) → dict[str, Any]
Append and publish exactly one metrics record.
method remaining_gradient_steps
remaining_gradient_steps() → int | None
method report_stage_event
report_stage_event(stage: 'str', **details: 'Any') → None
method report_stage_progress
report_stage_progress(
stage: 'str',
current: 'int',
total: 'int',
**details: 'Any'
) → None
Report completed work without modifying log rows or counters.
method save_snapshot
save_snapshot(snapshot: 'Mapping[str, Any]') → None
Persist an explicit phase-boundary snapshot when configured.
method set_stop_reason
set_stop_reason(reason: 'StopReason') → StopReason
method structure_limit_reached
structure_limit_reached() → bool
This file was automatically generated via lazydocs.