Skip to content

Simplest FitLoop customization doesn't work #10393

@whaowhao

Description

@whaowhao

🐛 Bug

Setting trainer.fit_loop to default FitLoop causes error

To Reproduce

Take any trainer and model, and add one line that sets trainer.fit_loop to default FitLoop causes error

... code before
from pytorch_lightning.loops import FitLoop
trainer.fit_loop = FitLoop()
... code after

Exception has occurred: AttributeError       (note: full exception trace is shown but execution is paused at: <module>)
'NoneType' object has no attribute '_results'
  File "/home/whao/.virtualenv/mixedclassify/lib/python3.6/site-packages/pytorch_lightning/loops/fit_loop.py", line 145, in _results
    return self.epoch_loop._results
  File "/home/whao/.virtualenv/mixedclassify/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 2143, in _results
    return active_loop._results
  File "/home/whao/.virtualenv/mixedclassify/lib/python3.6/site-packages/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py", line 308, in reset_results
    if self.trainer._results is not None:
  File "/home/whao/.virtualenv/mixedclassify/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 1174, in _run
    self.logger_connector.reset_results()
  File "/home/whao/.virtualenv/mixedclassify/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 770, in _fit_impl
    self._run(model, ckpt_path=ckpt_path)
  File "/home/whao/.virtualenv/mixedclassify/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 682, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/whao/.virtualenv/mixedclassify/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 736, in fit
    self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
  File "/home/whao/whao/MultiHead/multihead/cli.py", line 153, in run_active_learn
    trainer.fit(model)

Expected behavior

Nothing should change since we set fitloop to default FitLoop

Environment

pl==1.5.0

cc @tchaton @carmocca @justusschock

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingloopsRelated to the Loop APIpriority: 1Medium priority task

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions