Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

estimate_zero2_model_states_mem_needs: fixing memory estiamtion #5099

Merged
merged 6 commits into from
Jun 4, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deepspeed/runtime/zero/stage_1_and_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2427,7 +2427,9 @@ def estimate_zero2_model_states_mem_needs(total_params,
gpu_mem = 2 * total_params
cpu_mem = total_params * max(4 * total_gpus, 16) * additional_buffer_factor
else:
gpu_mem = 4 * total_params + int(16 * total_params / total_gpus)
# GPU's total_params multipliers: 2 = params_16bit,
# 14 = 2_grads_16bit + 4_params_32bit + 8_optimizer_states_32bit(momentum and variance)
tjruwase marked this conversation as resolved.
Show resolved Hide resolved
nelyahu marked this conversation as resolved.
Show resolved Hide resolved
gpu_mem = 2 * total_params + int(14 * total_params / total_gpus)
nelyahu marked this conversation as resolved.
Show resolved Hide resolved
cpu_mem = total_params * 4 * num_gpus_per_node * additional_buffer_factor

return int(cpu_mem), int(gpu_mem)
Expand Down
Loading