Skip to content

Commit

Permalink
Misplaced global variable warned (microsoft#5725)
Browse files Browse the repository at this point in the history
Move the global variable `warned` from
`deepspeed.runtime.zero.parameter_offload.py` to
`deepspeed.runtime.zero.utils.py` to avoid `NameError: name 'warned' is
not defined` when calling `ap
ply_to_tensors_only()` (defined in `deepspeed.runtime.zero.utils.py`).

Co-authored-by: Logan Adams <[email protected]>
  • Loading branch information
anferico and loadams authored Jul 20, 2024
1 parent 6a163e0 commit 879c6cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions deepspeed/runtime/zero/parameter_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FWD_MODULE_STACK = list()

# ensure we only warn once, otherwise every iteration will trigger a warning
warned = False


#for each tensor in outputs run the forward_function and register backward_function as hook
def _apply_forward_and_backward_to_tensors_only(module, forward_function, backward_function, outputs):
Expand Down
3 changes: 3 additions & 0 deletions deepspeed/runtime/zero/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from deepspeed.utils.nvtx import instrument_w_nvtx
from deepspeed.accelerator import get_accelerator

# ensure we only warn once, otherwise every iteration will trigger a warning
warned = False


def _initialize_parameter_parallel_groups(parameter_parallel_size=None):
data_parallel_size = int(dist.get_world_size())
Expand Down

0 comments on commit 879c6cd

Please sign in to comment.