pfnet/pytorch-pfn-extras

Consumption of 'autocast' option not properly performed due to 'get' operation on line 195 not being 'pop'

Closed this issue · 2 comments

https://github.com/pfnet/pytorch-pfn-extras/blob/master/pytorch_pfn_extras/handler/_logic.py#L195

Since the 'get' operation on this line (line 195) is not 'pop', the consumption of the 'autocast' option is not being performed properly.

is this causing errors?

small example

from pytorch_pfn_extras.engine import create_trainer
import pytorch_pfn_extras as ppe
import torch.nn as nn
import torch.optim as o

class Model(nn.Module):

    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.l0 = nn.Linear(64, 64)

    def forward(self, x):
        return self.l0(x)

model = Model()
optimizer = o.SGD(model.parameters(), lr=0.1, momentum=0.9)
trainer = create_trainer(
    models=model,
    optimizers=optimizer,
    max_epochs=2,
    options={
        "autocast": True,
    }
)

result

ValueError: ('Unknown options: ', {'autocast': True})

An error occurs at the following point because the option is not being consumed properly.

if len(options) > 0:
raise ValueError('Unknown options: ', options)