may i know why Adam need to load the optimizer state while SGD not?

This is the result of optimizer internal design. Adam has two tracking status m_t and v_t to store historical information, while SGD doesn’t. And that’s why Adam optimizer takes more memory than SGD.

So, in my case, I used Adam, then the example code i give will not resume training correctly?

A correct way is saving the optimizer states with optimizer.state_dict() when saving the checkpoint. Then resume by optimizer.load_state_dict(...).