You can .chunk() or .split() out the portion of the tensor you’re interested in calculating loss on. Post some code and we can dive deeper into suggested examples. Recompiling should not be necessary for your suggested use case.