Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
2412429d
Unverified
Commit
2412429d
authored
Apr 12, 2022
by
Frank Lee
Committed by
GitHub
Apr 12, 2022
Browse files
[util] fixed activation checkpointing on torch 1.9 (#719)
parent
04ff5ea5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
colossalai/utils/activation_checkpoint.py
colossalai/utils/activation_checkpoint.py
+9
-2
No files found.
colossalai/utils/activation_checkpoint.py
View file @
2412429d
...
@@ -68,7 +68,10 @@ class CheckpointFunction(torch.autograd.Function):
...
@@ -68,7 +68,10 @@ class CheckpointFunction(torch.autograd.Function):
else
:
else
:
ctx
.
inputs
.
append
(
arg
)
ctx
.
inputs
.
append
(
arg
)
ctx
.
save_for_backward
(
*
tensor_inputs
)
if
activation_offload
:
ctx
.
tensor_inputs
=
tensor_inputs
else
:
ctx
.
save_for_backward
(
*
tensor_inputs
)
return
outputs
return
outputs
@
staticmethod
@
staticmethod
...
@@ -79,7 +82,11 @@ class CheckpointFunction(torch.autograd.Function):
...
@@ -79,7 +82,11 @@ 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
tensors
=
ctx
.
saved_tensors
if
ctx
.
activation_offload
:
tensors
=
ctx
.
tensor_inputs
else
:
tensors
=
ctx
.
saved_tensors
# store the current states
# store the current states
bwd_cpu_rng_state
=
torch
.
get_rng_state
()
bwd_cpu_rng_state
=
torch
.
get_rng_state
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment