LoopState#

class pyqit.core.callbacks.LoopState(model: Any, datamodule: Any, history: Any, reporter: Any, max_epochs: int, epoch: int = -1, metrics: dict[str, float]=<factory>, stop: bool = False, optimizer: Any = None, optimizer_state: Any = None)[source]#

Bases: object

Everything a callback may read, and the one flag it may write.

model#

The model being trained.

Type:

BaseModel

datamodule#

The data it is training on, already set up.

Type:

DataModule

history#

Metrics recorded so far this run.

Type:

TrainingHistory

reporter#

Console output, for callbacks that announce something.

Type:

Reporter

max_epochs#

Epoch budget for the run.

Type:

int

epoch#

Zero-based index of the epoch just finished; -1 before the first.

Type:

int

metrics#

This epoch’s metrics, keyed train_loss, val_loss, train_acc, val_acc, epoch_time.

Type:

dict of {str: float}

stop#

Set by a callback to end training after this epoch. Both loops check it; the Lightning loop forwards it to trainer.should_stop.

Type:

bool

optimizer#

The live optimizer, once the loop has built it: a qml optimizer or a torch.optim one. None during on_fit_start.

Type:

object

optimizer_state#

Set during on_fit_start by a callback restoring a run; the loop loads it into the optimizer it builds. Backend-specific.

Type:

object