Wrap the device move in an equality guard so Dynamo can DCE it under fullgraph=True (model.to() goes through _parse_to, which returns a non-Tensor torch.device that Dynamo can't trace). The model is already placed on the target device by prepare_for_compile, so the guard is a runtime no-op. Also drop the orig_device save/restore — the encoder should stay resident on the compute device between calls. Co-authored-by: Junda (David) Su <90978028+Davids048@users.noreply.github.com> Co-authored-by: Matthew Noto <99706358+RandNMR73@users.noreply.github.com> Co-authored-by: XOR-op <17672363+XOR-op@users.noreply.github.com> Co-authored-by: Zhang Peiyuan <42993249+jzhang38@users.noreply.github.com>