Looks like there is a leak.
For RRef, there is an internal API _rref_context_get_debug_info to check the number of living OwerRRefs (with key num_owner_rrefs). Here are examples in tests 2.
Similarly, distributed autograd can also show the number of living backward passes. [example 2]
BTW, which version of PyTorch are you using? I recall we fixed some memory leaks after v1.4 release, e.g., this PR.