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
3d55652b
Commit
3d55652b
authored
3 years ago
by
Ming Ding
Browse files
Options
Downloads
Patches
Plain Diff
fix glm mask bug
parent
f8d2632a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inference_glm.py
+3
-2
3 additions, 2 deletions
inference_glm.py
training/deepspeed_training.py
+6
-0
6 additions, 0 deletions
training/deepspeed_training.py
with
9 additions
and
2 deletions
inference_glm.py
+
3
−
2
View file @
3d55652b
...
...
@@ -32,6 +32,7 @@ def get_masks_and_position_ids_glm(seq, mask_position, context_length):
attention_mask
=
torch
.
ones
((
1
,
len
(
seq
),
len
(
seq
)),
device
=
tokens
.
device
)
attention_mask
.
tril_
()
attention_mask
[...,
:
context_length
]
=
1
attention_mask
.
unsqueeze_
(
1
)
position_ids
=
torch
.
zeros
(
2
,
len
(
seq
),
device
=
tokens
.
device
,
dtype
=
torch
.
long
)
...
...
@@ -71,7 +72,7 @@ def main(args):
seq
=
[
tokenizer
.
get_command
(
'
ENC
'
).
Id
]
+
seq
if
not
raw_text
.
endswith
(
'
MASK]
'
):
seq
=
seq
+
[
tokenizer
.
get_command
(
'
eos
'
).
Id
]
print
(
'
raw text:
'
,
raw_text
)
print
(
'
raw text:
{}
\n
'
.
format
(
raw_text
)
)
if
len
(
seq
)
>
args
.
max_sequence_length
:
raise
ValueError
(
'
text too long.
'
)
...
...
@@ -112,7 +113,7 @@ def main(args):
except
ValueError
:
unfinished
=
len
(
output
)
bog
=
output
.
index
(
tokenizer
.
get_command
(
'
sop
'
).
Id
)
output_list
[
i
]
=
output
[:
mask_position
]
+
output
[
bog
+
1
:
unfinished
]
+
output
[
mask_position
+
1
:
bog
]
output_list
[
i
]
=
output
[:
mask_position
]
+
output
[
bog
:
unfinished
]
+
output
[
mask_position
+
1
:
bog
]
# prepare the next auto-regressive generation
if
mp_idx
<
len
(
mask_positions
)
-
1
:
...
...
This diff is collapsed.
Click to expand it.
training/deepspeed_training.py
+
6
−
0
View file @
3d55652b
...
...
@@ -203,6 +203,12 @@ def get_params_for_weight_decay_optimization(module):
no_weight_decay_params
[
'
params
'
].
extend
(
[
p
for
n
,
p
in
list
(
module_
.
_parameters
.
items
())
if
p
is
not
None
and
n
==
'
bias
'
and
p
.
requires_grad
])
if
len
(
weight_decay_params
[
'
params
'
])
==
0
:
return
tuple
(
no_weight_decay_params
)
elif
len
(
no_weight_decay_params
[
'
params
'
])
==
0
:
return
tuple
(
weight_decay_params
)
return
weight_decay_params
,
no_weight_decay_params
def
get_optimizer_param_groups
(
model
):
...
...
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