T5ForConditionalGeneration to Trainer.fit()
Model I am using (MT5ForConditionalGeneration ('google/mt5-base')):
The problem arises when passing
pl.LightningDataModule with T5ForConditionalGeneration to Trainer.fit()
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/connectors/model_connector.py in copy_trainer_model_properties(self, model)
AttributeError: 'QAModel' object has no attribute 'automatic_optimization'
<!— A clear and concise description of what the bug is. —>
class QAModel(pl.LightningDataModule):

[def __init__(self):
super().__init__()
self.model = MT5ForConditionalGeneration.from_pretrained(MODEL_NAME, return_dict=True)

def forward(self, input_ids, attention_mask, labels=None):
output = self.model(
input_ids=input_ids,
attention_mask=attention_mask,
labels=labels
)

return output.loss, output.logits

def training_step(self, batch, batch_idx):
input_ids = batch['input_ids']
attention_mask = batch['attention_mask']
labels = batch['labels']
loss, outputs = self(input_ids, attention_mask, labels)
self.log('train_loss', loss, prog_bar=True, logger=True)
return loss

def validation_step(self, batch, batch_idx):
input_ids = batch['input_ids']
attention_mask = batch['attention_mask']
labels = batch['labels']
loss, outputs = self(input_ids, attention_mask, labels)
self.log('val_loss', loss, prog_bar=True, logger=True)
return loss

def test_step(self, batch, batch_idx):
input_ids = batch['input_ids']
attention_mask = batch['attention_mask']
labels = batch['labels']
loss, outputs = self(input_ids, attention_mask, labels)
self.log('train_loss', loss, prog_bar=True, logger=True)
return loss

def configure_optimizers(self):
print('done')
return AdamW(self.parameters(), lr=0.0001)]
model = QAModel()
trainer.fit(model, data_module)

<!— Please paste your BoringModel colab link here. —>
To Reproduce
Use following - https://colab.research.google.com/drive/1wRYnuQhkO8Uv..
<!— If you could not reproduce using the BoringModel and still think there's a bug, please post here —>
Expected behavior
Environment

transformers version: 4.3.2
Platform: google colab
pytorch-lightning version (GPU?): 1.2.0

Additional context
<!— Add any other context about the problem here. —>
trainer.fit
Trainer.fit