Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't save fp8 q/k/v/out tensors when using bf16 bprop #1139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions transformer_engine/pytorch/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -4727,6 +4727,7 @@ def forward(

ctx.fp8 = fp8 and int(os.getenv("NVTE_FP8_DPA_BWD", "1"))
qkvo_tensors = (qkv, out_save) if not ctx.fp8 else (None, None)
fp8_tensors = fp8_tensors if ctx.fp8 else (None, None, None, None)
ctx.save_for_backward(
*qkvo_tensors, cu_seqlens, cu_seqlens_padded, *fp8_tensors, *aux_ctx_tensors
)
Expand Down Expand Up @@ -5115,6 +5116,7 @@ def forward(

ctx.fp8 = fp8 and int(os.getenv("NVTE_FP8_DPA_BWD", "1"))
qkvo_tensors = (q, kv, out_save) if not ctx.fp8 else (None, None, None)
fp8_tensors = fp8_tensors if ctx.fp8 else (None, None, None, None, None)
ctx.save_for_backward(
*qkvo_tensors,
cu_seqlens_q,
Expand Down Expand Up @@ -5627,6 +5629,7 @@ def forward(

ctx.fp8 = fp8 and int(os.getenv("NVTE_FP8_DPA_BWD", "1"))
qkvo_tensors = (q, k, v, out_save) if not ctx.fp8 else (None, None, None, None)
fp8_tensors = fp8_tensors if ctx.fp8 else (None, None, None, None, None, None)
ctx.save_for_backward(
*qkvo_tensors,
cu_seqlens_q,
Expand Down
Loading