Skip to content

[BUG] pipeline engine is_gradient_accumulation_boundary is not set correctly #3911

Description

@BacharL

Pipeline engine overrides deepspeed.runtime.engine.is_gradient_accumulation_boundary()
https://github.com/microsoft/DeepSpeed/blob/7e8bcc07d6532a380a7a439741609b058f083ed6/deepspeed/runtime/pipe/engine.py#L560
In this implementation is_gradient_accumulation_boundary will return True only when the pipe is executing _exec_optimizer_step or _exec_reduce_grads. It will return False during forward and backward calls. Additionally it will ignore calls to set_gradient_accumulation_boundary.

This behavior leads to multiple issue in deepspeed.runtine.engine.backward

  1. loss list grows indefinitely
    https://github.com/microsoft/DeepSpeed/blob/7e8bcc07d6532a380a7a439741609b058f083ed6/deepspeed/runtime/engine.py#L1884

  2. If zero is enabled optimizer is called with incorrect state of is_gradient_accumulation_boundary
    https://github.com/microsoft/DeepSpeed/blob/7e8bcc07d6532a380a7a439741609b058f083ed6/deepspeed/runtime/engine.py#L1894

  3. amp loss scaling incorrect.
    https://github.com/microsoft/DeepSpeed/blob/7e8bcc07d6532a380a7a439741609b058f083ed6/deepspeed/runtime/engine.py#L1899C13-L1899C27

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtraining

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions