Fix exception when serialize the checkpoint data and add device to the task header.