Enhance optimizer state loading with runtime overrides (#3720)