Skip to content
Discussion options

You must be logged in to vote

I think I figured this out - you need to pass a plugin to the trainer class that implements mixed precision, and give the plugin your preferred scaler.

Yaml:

trainer:
    precision: 16
    amp_backend: 'native'
    amp_level: null

    plugins:
        - class_path: pytorch_lightning.plugins.precision.NativeMixedPrecisionPlugin
          init_args:
              precision: 16
              device: 'cuda'
              scaler:
                  class_path: torch.cuda.amp.GradScaler
                  init_args:
                      # the default scale of 2**16 overflows early in training
                      # and makes the gradient unstable
                      init_scale: 256

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wwbrannon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment