Skip to content

Fix HIP memory leaks in RNN kernels#727

Draft
magaonka-amd wants to merge 1 commit intoROCm:rocm-jaxlib-v0.8.0from
magaonka-amd:fix/rnn-hip-memleak-v0.8.0
Draft

Fix HIP memory leaks in RNN kernels#727
magaonka-amd wants to merge 1 commit intoROCm:rocm-jaxlib-v0.8.0from
magaonka-amd:fix/rnn-hip-memleak-v0.8.0

Conversation

@magaonka-amd
Copy link

@magaonka-amd magaonka-amd commented Mar 5, 2026

Free dropout_states_dev GPU memory allocated via gpuMalloc in the HIP paths of DoRnnComputeWorkspaceReserveSpaceSizes, DnnRNNForward_, and DnnRNNBackward_.

Upstream PR: jax-ml#35638

Free dropout_states_dev GPU memory allocated via gpuMalloc in the HIP
paths of DoRnnComputeWorkspaceReserveSpaceSizes, DnnRNNForward_, and
DnnRNNBackward_. Also destroy the leaked miopenTensorDescriptor in
the forward and backward functions.
@magaonka-amd magaonka-amd force-pushed the fix/rnn-hip-memleak-v0.8.0 branch from 171f15a to 559571d Compare March 5, 2026 16:50
#define GPU_STREAM_NON_BLOCKING hipStreamNonBlocking

#define gpuMalloc hipMalloc
#define gpuFree hipFree
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't believe it's not there yet...

Note, a corresponding entry is needed for CUDA too, and this needs to be upstreamed too

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, saw the upstream link in the descipriton, awesome. Then just an update for CUDA is needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep very funny to me aswell. looks like we have unlimited memory no need to free it. just keep using it :).
okay I'll update upstream aswell. thanks.

@magaonka-amd magaonka-amd marked this pull request as draft March 5, 2026 17:44
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