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

Added offloading support FP8 attention #1131

Merged
merged 5 commits into from
Sep 5, 2024
Merged
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
11 changes: 9 additions & 2 deletions transformer_engine/pytorch/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -5698,16 +5698,23 @@ def forward(
out_save = out_ret
fp8_tensors = (None, None, None, None, None, None)

ctx.fp8 = fp8 and int(os.getenv("NVTE_FP8_DPA_BWD", "1"))

from .cpu_offload import CPUOffloadEnabled

if CPUOffloadEnabled:
tensor_list = [q, k, v, out_save, cu_seqlens_q, cu_seqlens_kv]
if ctx.fp8:
tensor_list = fp8_tensors
else:
tensor_list = [q, k, v, out_save]

tensor_list.extend(aux_ctx_tensors)

qkv_layout = "sbhd_sbhd_sbhd"
for tensor in tensor_list:
if tensor is not None:
tensor.activation_offloading = True

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