Skip to content

CUDA out of memory when quantizing llama3.1-405b on 80GiBx8 H100 instance #36

@sfc-gh-zhwang

Description

@sfc-gh-zhwang
Some parameters are on the meta device device because they were offloaded to the cpu.
Quantizing weights:   0%|          | 0/1771 [00:00<?, ?it/s]
Quantizing weights:   9%|▉         | 160/1771 [00:00<00:01, 1008.71it/s]
Traceback (most recent call last):
  File "/home/corvo/quantize.py", line 25, in <module>
    main()
  File "/home/corvo/quantize.py", line 20, in main
    model.quantize(examples)
  File "/home/corvo/AutoFP8/auto_fp8/modeling.py", line 113, in quantize
    quantize_weights(self.model, self.quantize_config)
  File "/home/corvo/AutoFP8/auto_fp8/quantize.py", line 237, in quantize_weights
    quant_weight, weight_scale = per_tensor_quantize(linear.weight)
  File "/home/corvo/AutoFP8/auto_fp8/quantize.py", line 56, in per_tensor_quantize
    qweight = (tensor * scale).clamp(min=finfo.min, max=finfo.max)
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 512.00 MiB. GPU 1 has a total capacity of 79.11 GiB of which 4.88 MiB is free. Including non-PyTorch memory, this process has 0 bytes memory in use. Of the allocated memory 78.50 GiB is allocated by PyTorch, and 1.18 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.  See documentation for Memory Management  (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

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