Skip to content

Gradient accumulation may requires scaling before backward #761

@yonghanyu

Description

@yonghanyu

In function train_one_epoch, in the file src/training/train.py from line 156 to 162, as shown below:

                    losses = loss(**inputs, **inputs_no_accum, output_dict=True)
                    del inputs
                    del inputs_no_accum
                    total_loss = sum(losses.values())
                    losses["loss"] = total_loss

                backward(total_loss, scaler)

Shouldn't we take the average of loss for gradient accumulation before calling backward()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions