I fail to see how your link answers my question, @SimonW. I wasn’t asking about pytorch memory management, I’m asking about tracemalloc-like functionality.
Currently to get the peak GPU RAM used by pytorch, I need to:

Start a thread that monitors gpu used memory every few msecs
Run the real code in the main process
Stop the thread and collect the results.

It works, but it’s awkward and imprecise. And, of course, I have to clear cache to get the actual memory usage.