Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SwissArmyTransformer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
thukeg
SwissArmyTransformer
Commits
7c35e218
Commit
7c35e218
authored
3 years ago
by
Zhengxiao Du
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into glm
parents
d9a54331
52077b84
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
model/mixins.py
+1
-1
1 addition, 1 deletion
model/mixins.py
training/deepspeed_training.py
+2
-2
2 additions, 2 deletions
training/deepspeed_training.py
training/model_io.py
+3
-3
3 additions, 3 deletions
training/model_io.py
with
6 additions
and
6 deletions
model/mixins.py
+
1
−
1
View file @
7c35e218
...
...
@@ -26,7 +26,7 @@ class BaseMixin(torch.nn.Module):
class
PositionEmbeddingMixin
(
BaseMixin
):
def
__init__
(
self
,
additional_sequence_length
,
hidden_size
,
init_method_std
=
0.02
,
reinit_slice
=
(
-
1024
,
None
)
init_method_std
=
0.02
,
reinit_slice
=
slice
(
-
1024
,
None
)
):
super
(
PositionEmbeddingMixin
,
self
).
__init__
()
self
.
reinit_slice
=
reinit_slice
...
...
This diff is collapsed.
Click to expand it.
training/deepspeed_training.py
+
2
−
2
View file @
7c35e218
...
...
@@ -337,10 +337,10 @@ def train_step(data_iterator, model, optimizer, lr_scheduler,
# and all reduce metrics by the way
loss_checker
=
lm_loss
.
detach
()
for
name
in
metrics
:
metrics
[
name
]
=
metrics
[
name
].
detach
()
metrics
[
name
]
=
metrics
[
name
].
detach
()
.
clone
()
torch
.
distributed
.
all_reduce
(
metrics
[
name
].
data
)
metrics
[
name
].
data
/=
args
.
world_size
loss_checker
+
=
metrics
[
name
]
loss_checker
=
loss_checker
+
metrics
[
name
]
if
loss_checker
.
isnan
().
any
()
or
loss_checker
.
isinf
().
any
():
print
(
'
Skipping backward and optimizer step for nan or inf in forwarding metrics/loss!
'
)
return
lm_loss
.
detach
(),
1
,
metrics
...
...
This diff is collapsed.
Click to expand it.
training/model_io.py
+
3
−
3
View file @
7c35e218
...
...
@@ -39,7 +39,9 @@ def save_checkpoint(iteration, model, optimizer,
lr_scheduler
,
args
):
"""
Save a model checkpoint.
"""
if
args
.
deepspeed
:
save_ds_checkpoint
(
iteration
,
model
,
lr_scheduler
,
args
)
if
mpu
.
get_data_parallel_rank
()
==
0
:
print
(
'
Saving Model...
'
)
save_ds_checkpoint
(
iteration
,
model
,
lr_scheduler
,
args
)
else
:
raise
ValueError
(
"
training without deepspeed is not supported.
"
)
# Wait so everyone is done (necessary)
...
...
@@ -74,8 +76,6 @@ def save_ds_checkpoint_no_optim(model, save_dir, tag=None, client_state={}, save
os
.
makedirs
(
save_dir
,
exist_ok
=
True
)
# Ensure tag is a string
tag
=
str
(
tag
)
# Ensure checkpoint tag is consistent across ranks
model
.
_checkpoint_tag_validation
(
tag
)
# Real save via deepspeed
model
.
_create_checkpoint_file
(
save_dir
,
tag
,
False
)
model
.
_save_checkpoint
(
save_dir
,
tag
,
client_state
=
client_state
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment