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

[XPU] Enable empty cache on XPU device #438

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all 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
6 changes: 3 additions & 3 deletions megatron/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def train_step(forward_step_func, data_iterator,

# Empty unused memory.
if args.empty_unused_memory_level >= 1:
torch.cuda.empty_cache()
get_accelerator().empty_cache()

# Reduce gradients.
if not args.deepspeed:
Expand Down Expand Up @@ -781,7 +781,7 @@ def train_step(forward_step_func, data_iterator,

# Empty unused memory.
if args.empty_unused_memory_level >= 2:
torch.cuda.empty_cache()
get_accelerator().empty_cache()

if mpu.is_pipeline_last_stage(ignore_virtual=True):
# Average loss across microbatches.
Expand Down Expand Up @@ -1437,7 +1437,7 @@ def evaluate(forward_step_func,

# Empty unused memory
if args.empty_unused_memory_level >= 1:
torch.cuda.empty_cache()
get_accelerator().empty_cache()

if mpu.is_pipeline_last_stage(ignore_virtual=True):
# Reduce across processes.
Expand Down