mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-20 00:55:29 +00:00
[util] fixed activation checkpointing on torch 1.9 (#719)
This commit is contained in:
@@ -68,6 +68,9 @@ class CheckpointFunction(torch.autograd.Function):
|
|||||||
else:
|
else:
|
||||||
ctx.inputs.append(arg)
|
ctx.inputs.append(arg)
|
||||||
|
|
||||||
|
if activation_offload:
|
||||||
|
ctx.tensor_inputs = tensor_inputs
|
||||||
|
else:
|
||||||
ctx.save_for_backward(*tensor_inputs)
|
ctx.save_for_backward(*tensor_inputs)
|
||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
@@ -79,6 +82,10 @@ class CheckpointFunction(torch.autograd.Function):
|
|||||||
# Copy the list to avoid modifying original list.
|
# Copy the list to avoid modifying original list.
|
||||||
inputs = list(ctx.inputs)
|
inputs = list(ctx.inputs)
|
||||||
tensor_indices = ctx.tensor_indices
|
tensor_indices = ctx.tensor_indices
|
||||||
|
|
||||||
|
if ctx.activation_offload:
|
||||||
|
tensors = ctx.tensor_inputs
|
||||||
|
else:
|
||||||
tensors = ctx.saved_tensors
|
tensors = ctx.saved_tensors
|
||||||
|
|
||||||
# store the current states
|
# store the current states
|
||||||
|
Reference in New Issue
Block a user