The knnQuery is always running on GPU since it is a compiled GPU library. I will implement the functions with pure pytorch functions and check if the error still appears. I do not use any REPL environment. Thank you for the recommendations.