deepspeedai / deepspeedai/DeepSpeed

[BUG] Exception raised at the end of training with deepcompile enabled

Open
#7,578 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug training
Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

Describe the bug

With a training script like the following:

import deepspeed
import deepspeed.comm as dist

def main(args):
    deepspeed.init_distributed()
    model = Model()
    ......
    model.destroy()
    dist.destroy_process_group()

The following exception is raised at the end of the training process if and only if deepcompile is enabled:

Exception ignored in: <function DeepSpeedEngine.__del__ at 0x7f241b4fe830>
Traceback (most recent call last):
  File "/mnt/engines/deepspeed/deepspeed/runtime/engine.py", line 519, in __del__
    self.destroy()
  File "/mnt/engines/deepspeed/deepspeed/runtime/engine.py", line 523, in destroy
    self.optimizer.destroy()
  File "/mnt/engines/deepspeed/deepspeed/runtime/zero/stage3.py", line 468, in destroy
    self.parameter_offload.destroy()
  File "/mnt/engines/deepspeed/deepspeed/runtime/zero/parameter_offload.py", line 227, in destroy
    self._remove_module_hooks()
  File "/mnt/engines/deepspeed/deepspeed/runtime/zero/parameter_offload.py", line 241, in _remove_module_hooks
    print_rank_0(f'Deleted module hooks: forward = {num_forward_hooks}, backward = {num_backward_hooks}',
  File "/mnt/engines/deepspeed/deepspeed/runtime/zero/partition_parameters.py", line 113, in print_rank_0
    rank = dist.get_rank()
  File "/mnt/engines/deepspeed/deepspeed/comm/comm.py", line 720, in get_rank
    assert cdb is not None and cdb.is_initialized(
AssertionError: DeepSpeed backend not set, please initialize it using init_process_group()

To Reproduce

Steps to reproduce the behavior:

  1. Run https://gist.github.com/eternalNight/3c2cf8c703f1e9e7742d3b7f9e1edae3 with deepspeed --num_gpus=N openvla-like.py -c

Expected behavior
No exception is raised.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the linked openvla-like.py command and deepcompile enabled. Trace the teardown path through deepspeed/runtime/engine.py, deepspeed/runtime/zero/stage3.py, deepspeed/runtime/zero/parameter_offload.py, and deepspeed/runtime/zero/partition_parameters.py, focusing on destruction after dist.destroy_process_group(). Done means the training process exits without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.