I’m posting this in case someone finds it helpful.
If you are debugging a module built with torch.utils.ffi (or cffi), enable debugging symbols (-g) and set the -O0 flag, as it will override the default -O3 from distutils.unixccompiler.py. In my case, it was something like:
CC=g++ CFLAGS="-O0 -g" python build.py

Then, execute gdb python. At the gdb prompt, run your script:
(gdb) run test_module.py

I’m not using python-dbg, so I interrupt the execution with Ctrl+c, then I set a breakpoint at the C++ function I want to debug:
(gdb) b my_conv2d

Then, hit c to continue.