Skip to content

[BUG] DS Inference Bloom OOM / get_sd_loader_json() missing 1 argument #2222

Description

@oborchers

Describe the bug

When loading the bloom model the loader tries to allocate too much to a single GPU. Therefore, the script OOMs.

I think this is also related to: #2169

Hardware

5x A100 80G + 512G ram (should be enough as it is working with plain accelerate).

To Reproduce

Copied and mildly adapted from

Run with:

deepspeed --num_gpus 5 script.py

(Deepspeed it built from main branch)

Case 1:

dtype = torch.float16
dschf = HfDeepSpeedConfig(ds_config)

with deepspeed.OnDevice(dtype=dtype, device='meta'):
    model = AutoModelForCausalLM.from_config(self.config, torch_dtype=torch.bfloat16)
model = model.eval()

ds_engine = deepspeed.initialize(model=model, config_params=ds_config)[0]
ds_engine.module.eval()
model = ds_engine.module

dist.barrier()

model = deepspeed.init_inference(model, 
                         mp_size=1,
                         dtype=dtype,
                         checkpoint='/workspace/bloom-176B.json', 
                         replace_with_kernel_inject=True
                         )
self.model = model.module

Results in

RuntimeError: CUDA out of memory. Tried to allocate 1.53 GiB (GPU 2; 79.17 GiB total capacity; 76.57 GiB already allocated; 932.00 MiB free; 77.14 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Note, that this is CUDA device 2 out of 5!

Case 2:

Based on #2169

injection_policy={transformers.models.bloom.modeling_bloom.BloomBlock: ('self_attention.dense', 'mlp.dense_4h_to_h')}
replace_with_kernel_inject=False

results in:

TypeErrorTypeError: : get_sd_loader_json() missing 1 required positional argument: 'checkpoint_engine'get_sd_loader_json() missing 1 required positional argument: 'checkpoint_engine'

    model.load()
  File "/workspace/bloom.py", line 106, in load
    injection_policy={transformers.models.bloom.modeling_bloom.BloomBlock: ('self_attention.dense', 'mlp.dense_4h_to_h')}
  File "/opt/conda/lib/python3.7/site-packages/deepspeed/__init__.py", line 312, in init_inference
    save_mp_checkpoint_path)
  File "/opt/conda/lib/python3.7/site-packages/deepspeed/inference/engine.py", line 104, in __init__
    self._load_checkpoint(self.checkpoint)
  File "/opt/conda/lib/python3.7/site-packages/deepspeed/inference/engine.py", line 394, in _load_checkpoint
    sd_loader = SDLoaderFactory.get_sd_loader_json(load_dir)
TypeError: get_sd_loader_json() missing 1 required positional argument: 'checkpoint_engine'

Tagging @RezaYazdaniAminabadi because I know of his active involvement in this one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions