Skip to content

Delete activation memory buffers proactively in UPipe forward pass#4

Merged
ghadiaravi13 merged 1 commit into
mainfrom
fwd_pass_mem_leaks
May 23, 2026
Merged

Delete activation memory buffers proactively in UPipe forward pass#4
ghadiaravi13 merged 1 commit into
mainfrom
fwd_pass_mem_leaks

Conversation

@ghost

@ghost ghost commented Mar 4, 2026

Copy link
Copy Markdown

This PR removes potential memory leaks in the forward pass of UPipe attention implementation. While it does not affect the overall memory usage because the peak memory is dictated by the backward pass, it is still useful to proactively clean up unused buffers in the forward pass.

In particular, it is useful for inference scenarios such as RL rollouts.

The memory profile for Llama3-8B on a single 8xH100, when training on 128K context length is attached BEFORE and AFTER the cleanup. It can be seen that PyTorch deallocates buffers only when the same buffers are reused in the next stage, which leads to unnecessary memory pressure during the current stage.

Before cleanup:
image

After cleanup:
image

@ghost ghost force-pushed the fwd_pass_mem_leaks branch from db3ff00 to 5ad64ee Compare March 4, 2026 04:03
@ghost ghost changed the title Delete Mem buffers proactively in UPipe forward pass Delete activation memory buffers proactively in UPipe forward pass Mar 6, 2026
@ghadiaravi13 ghadiaravi13 merged commit e465aa8 into main May 23, 2026
1 check passed
@mryab mryab deleted the fwd_pass_mem_leaks branch May 23, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants