You won’t need to do python3 setup.py clean before rebuilding, build PyTorch again using ccache, then make your changes, then build it again straight away.
I’d recommend you to run precisely the script in the ccache link above, I always do this without thinking and it works like a charm.
Specifically, in the terminal, I go to the PyTorch folder, I copy & paste all the code between then and fi in the ccache link, then I run export PATH=~/ccache/lib:$PATH. It works a 100% of times, in several machines, I never spent any second trying to understand why !
BTW, whenever you close the terminal, you should run export PATH=~/ccache/lib:$PATH again for ccache to work.