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
Megatron-LM
Commits
17035d6c
Commit
17035d6c
authored
Nov 17, 2020
by
Jared Casper
Browse files
Replace deprecated torch.norm with torch.linalg.norm.
parent
e7c7a78f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
megatron/mpu/grads.py
megatron/mpu/grads.py
+1
-1
megatron/utils.py
megatron/utils.py
+1
-1
No files found.
megatron/mpu/grads.py
View file @
17035d6c
...
...
@@ -112,7 +112,7 @@ def clip_grad_norm(parameters, max_norm, norm_type=2):
total_norm
=
0
for
p
in
parameters
:
if
p
.
model_parallel
or
(
get_model_parallel_rank
()
==
0
):
param_norm
=
p
.
grad
.
data
.
norm
(
norm_type
)
param_norm
=
torch
.
linalg
.
norm
(
p
.
grad
.
data
.
flatten
(),
norm_type
)
total_norm
+=
param_norm
.
item
()
**
norm_type
# Sum across all model parallel GPUs.
total_norm_cuda
=
torch
.
cuda
.
FloatTensor
([
float
(
total_norm
)])
...
...
megatron/utils.py
View file @
17035d6c
...
...
@@ -65,7 +65,7 @@ def print_params_min_max_norm(optimizer, iteration):
index
+=
1
min_
=
param
.
data
.
min
()
max_
=
param
.
data
.
max
()
norm
=
param
.
data
.
norm
(
)
norm
=
torch
.
linalg
.
norm
(
param
.
data
)
string
+=
'{:7d}, {:4d}, {:4d}, {:2d}, '
.
format
(
iteration
,
rank
,
index
,
int
(
param
.
model_parallel
))
string
+=
'{:.6E}, {:.6E}, {:.6E}
\n
'
.
format
(
min_
,
max_
,
norm
)
...
...
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