Could you run the code with CUDA_LAUNCH_BLOCKING=1 python script.py and post the stack trace here? This would hopefully point to the line of code, which throws this error.
Also, could you add print(indices.device) before the self.embed(indices) call in MatEmbedding?