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
TransformerEngine
Commits
d19a5a44
Commit
d19a5a44
authored
Aug 19, 2025
by
evt_fugx1
Browse files
add swap env
parent
c4bb6049
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
transformer_engine/pytorch/module/layernorm_linear.py
transformer_engine/pytorch/module/layernorm_linear.py
+2
-2
transformer_engine/pytorch/module/linear.py
transformer_engine/pytorch/module/linear.py
+2
-2
No files found.
transformer_engine/pytorch/module/layernorm_linear.py
View file @
d19a5a44
...
@@ -427,7 +427,7 @@ class _LayerNormLinear(torch.autograd.Function):
...
@@ -427,7 +427,7 @@ class _LayerNormLinear(torch.autograd.Function):
)
)
nvtx_range_pop
(
f
"
{
nvtx_label
}
.fsdp_scatter"
)
nvtx_range_pop
(
f
"
{
nvtx_label
}
.fsdp_scatter"
)
if
cpu_offloading
:
if
cpu_offloading
or
int
(
os
.
getenv
(
"NVTE_SWAP_OVERLAP_GRAD"
,
"0"
))
:
ctx
.
grad_added_to_main_grad
=
hasattr
(
weight
,
"grad_added_to_main_grad"
)
ctx
.
grad_added_to_main_grad
=
hasattr
(
weight
,
"grad_added_to_main_grad"
)
if
ctx
.
grad_added_to_main_grad
:
if
ctx
.
grad_added_to_main_grad
:
...
@@ -556,7 +556,7 @@ class _LayerNormLinear(torch.autograd.Function):
...
@@ -556,7 +556,7 @@ class _LayerNormLinear(torch.autograd.Function):
# For CPU offloading, we offloaded weight and weight.main_grad to different tensors,
# For CPU offloading, we offloaded weight and weight.main_grad to different tensors,
# we need to connect them into one.
# we need to connect them into one.
if
ctx
.
cpu_offloading
:
if
ctx
.
cpu_offloading
or
int
(
os
.
getenv
(
"NVTE_SWAP_OVERLAP_GRAD"
,
"0"
))
:
if
ctx
.
grad_added_to_main_grad
:
if
ctx
.
grad_added_to_main_grad
:
origin_weight
=
ctx
.
weight_object
origin_weight
=
ctx
.
weight_object
if
ctx
.
requires_wgrad
and
ctx
.
fuse_wgrad_accumulation
:
if
ctx
.
requires_wgrad
and
ctx
.
fuse_wgrad_accumulation
:
...
...
transformer_engine/pytorch/module/linear.py
View file @
d19a5a44
...
@@ -368,7 +368,7 @@ class _Linear(torch.autograd.Function):
...
@@ -368,7 +368,7 @@ class _Linear(torch.autograd.Function):
)
)
nvtx_range_pop
(
f
"
{
nvtx_label
}
.fsdp_scatter"
)
nvtx_range_pop
(
f
"
{
nvtx_label
}
.fsdp_scatter"
)
if
cpu_offloading
:
if
cpu_offloading
or
int
(
os
.
getenv
(
"NVTE_SWAP_OVERLAP_GRAD"
,
"0"
))
:
ctx
.
grad_added_to_main_grad
=
hasattr
(
weight
,
"grad_added_to_main_grad"
)
ctx
.
grad_added_to_main_grad
=
hasattr
(
weight
,
"grad_added_to_main_grad"
)
if
ctx
.
grad_added_to_main_grad
:
if
ctx
.
grad_added_to_main_grad
:
...
@@ -459,7 +459,7 @@ class _Linear(torch.autograd.Function):
...
@@ -459,7 +459,7 @@ class _Linear(torch.autograd.Function):
else
None
else
None
)
)
if
ctx
.
cpu_offloading
:
if
ctx
.
cpu_offloading
or
int
(
os
.
getenv
(
"NVTE_SWAP_OVERLAP_GRAD"
,
"0"
))
:
if
ctx
.
grad_added_to_main_grad
:
if
ctx
.
grad_added_to_main_grad
:
weight
=
ctx
.
weight_object
weight
=
ctx
.
weight_object
if
ctx
.
requires_wgrad
and
ctx
.
fuse_wgrad_accumulation
:
if
ctx
.
requires_wgrad
and
ctx
.
fuse_wgrad_accumulation
:
...
...
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