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
f1fa1a67
Commit
f1fa1a67
authored
Apr 18, 2022
by
ver217
Browse files
fix grad offload when enabling reuse_fp16_shard
parent
4b01da24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
colossalai/zero/sharded_optim/sharded_optim_v2.py
colossalai/zero/sharded_optim/sharded_optim_v2.py
+3
-0
No files found.
colossalai/zero/sharded_optim/sharded_optim_v2.py
View file @
f1fa1a67
...
@@ -290,6 +290,9 @@ class ShardedOptimizerV2(ColossalaiOptimizer):
...
@@ -290,6 +290,9 @@ class ShardedOptimizerV2(ColossalaiOptimizer):
if
p
.
colo_attr
.
saved_grad
.
is_null
():
if
p
.
colo_attr
.
saved_grad
.
is_null
():
continue
continue
p
.
colo_attr
.
saved_grad
.
trans_state
(
TensorState
.
COMPUTE
)
p
.
colo_attr
.
saved_grad
.
trans_state
(
TensorState
.
COMPUTE
)
# If reuse_fp16_shard, grad fp16 which wasn't be offloaded may be evicted to CPU
if
not
p
.
colo_attr
.
offload_grad
:
colo_model_data_tensor_move_inline
(
p
.
colo_attr
.
grad_payload
,
torch
.
cuda
.
current_device
())
# FIXME(ver217): p.data here is an empty tensor on CUDA and has no useful infomation
# FIXME(ver217): p.data here is an empty tensor on CUDA and has no useful infomation
# If we change p.grad directly
# If we change p.grad directly
# it may raise error because of different shape/dtype/device of p.data and p.grad
# it may raise error because of different shape/dtype/device of p.data and p.grad
...
...
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